mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-03 12:24:27 +01:00
Contracts: wire up the contract view command
contract view was in the CLI help but the command returned Not implemented, and there was no owner API entry point for the existing libwallet implementation. Add owner::contract_view through to the CLI and the owner RPC, with a display for the result. The slate is taken from --input or prompted for, as receive does. is_executed was hardcoded to false. Derive it from our own tx log entry for the slate, which is confirmed once the contract has executed.
This commit is contained in:
+12
-1
@@ -25,7 +25,7 @@ use crate::libwallet::api_impl::types::update_tx_slate_state;
|
||||
use crate::libwallet::api_impl::{owner, owner_updater};
|
||||
use crate::libwallet::contract::proofs::InvoiceProof;
|
||||
use crate::libwallet::contract::types::{
|
||||
ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI,
|
||||
ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI, ContractView,
|
||||
};
|
||||
use crate::libwallet::{
|
||||
AcctPathMapping, BuiltOutput, Error, InitTxArgs, IssueInvoiceTxArgs, NodeClient,
|
||||
@@ -815,6 +815,17 @@ where
|
||||
owner::contract_new(w, keychain_mask, args)
|
||||
}
|
||||
|
||||
/// Summarise a contract slate, including its participants, signatures and net change.
|
||||
pub fn contract_view(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
slate: &Slate,
|
||||
) -> Result<ContractView, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
owner::contract_view(w, keychain_mask, slate)
|
||||
}
|
||||
|
||||
/// Sign a contract, running setup first if it has not been done yet.
|
||||
pub fn contract_sign(
|
||||
&self,
|
||||
|
||||
+11
-1
@@ -22,7 +22,7 @@ use crate::core::core::OutputFeatures;
|
||||
use crate::core::global;
|
||||
use crate::keychain::{Identifier, Keychain};
|
||||
use crate::libwallet::contract::types::{
|
||||
ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI,
|
||||
ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI, ContractView,
|
||||
};
|
||||
use crate::libwallet::{
|
||||
mwixnet::MixnetReqCreationParams, AcctPathMapping, Amount, BuiltOutput, Error, InitTxArgs,
|
||||
@@ -547,6 +547,12 @@ pub trait OwnerRpc {
|
||||
TODO: Full docs once API has stabilised
|
||||
*/
|
||||
|
||||
fn contract_view(&self, token: Token, slate: VersionedSlate) -> Result<ContractView, Error>;
|
||||
|
||||
/**
|
||||
TODO: Full docs once API has stabilised
|
||||
*/
|
||||
|
||||
fn contract_revoke(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -2187,6 +2193,10 @@ where
|
||||
VersionedSlate::into_version(slate, version)
|
||||
}
|
||||
|
||||
fn contract_view(&self, token: Token, slate: VersionedSlate) -> Result<ContractView, Error> {
|
||||
Owner::contract_view(self, (&token.keychain_mask).as_ref(), &Slate::from(slate))
|
||||
}
|
||||
|
||||
fn contract_revoke(
|
||||
&self,
|
||||
token: Token,
|
||||
|
||||
Reference in New Issue
Block a user