Revert "[CONTRACTS] Contracts branch update for 1.80 (#718)"
This reverts commit cdd63fb565.
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
use crate::config::TorConfig;
|
||||
use crate::keychain::Keychain;
|
||||
use crate::libwallet::api_impl::foreign;
|
||||
use crate::libwallet::contract::proofs::InvoiceProof;
|
||||
use crate::libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
|
||||
use crate::libwallet::{
|
||||
BlockFees, CbData, Error, NodeClient, NodeVersionInfo, Slate, VersionInfo, WalletInst,
|
||||
WalletLCProvider,
|
||||
@@ -26,7 +24,6 @@ use crate::libwallet::{
|
||||
use crate::try_slatepack_sync_workflow;
|
||||
use crate::util::secp::key::SecretKey;
|
||||
use crate::util::Mutex;
|
||||
use ed25519_dalek::PublicKey as DalekPublicKey;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// ForeignAPI Middleware Check callback
|
||||
@@ -453,43 +450,6 @@ where
|
||||
post_automatically,
|
||||
)
|
||||
}
|
||||
|
||||
// Below is a foreign wrapper around owner calls to 'new' and 'sign' which are only executed
|
||||
// if this is a receiving contract. This preserves the ability to receive on a foreign interface.
|
||||
/// TODO
|
||||
pub fn contract_new(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
args: &ContractNewArgsAPI,
|
||||
) -> Result<Slate, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
// TODO: self.doctest_mode ?
|
||||
foreign::contract_new(&mut **w, keychain_mask, &args)
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn contract_sign(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
slate: &Slate,
|
||||
args: &ContractSetupArgsAPI,
|
||||
) -> Result<Slate, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
foreign::contract_sign(&mut **w, keychain_mask, &args, &slate)
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn verify_payment_proof_invoice(
|
||||
&self,
|
||||
recipient_address: &DalekPublicKey,
|
||||
proof: &InvoiceProof,
|
||||
) -> Result<(), Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
foreign::verify_payment_proof_invoice(&mut **w, recipient_address, proof)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
|
||||
@@ -52,7 +52,6 @@ pub trait ForeignRpc {
|
||||
"Ok": {
|
||||
"foreign_api_version": 2,
|
||||
"supported_slate_versions": [
|
||||
"V5",
|
||||
"V4"
|
||||
]
|
||||
}
|
||||
@@ -142,7 +141,7 @@ pub trait ForeignRpc {
|
||||
}
|
||||
],
|
||||
"sta": "S1",
|
||||
"ver": "5:2"
|
||||
"ver": "4:2"
|
||||
},
|
||||
null,
|
||||
null
|
||||
@@ -177,7 +176,7 @@ pub trait ForeignRpc {
|
||||
}
|
||||
],
|
||||
"sta": "S2",
|
||||
"ver": "5:2"
|
||||
"ver": "4:2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,7 +205,7 @@ pub trait ForeignRpc {
|
||||
"method": "finalize_tx",
|
||||
"id": 1,
|
||||
"params": [{
|
||||
"ver": "5:2",
|
||||
"ver": "4:2",
|
||||
"id": "0436430c-2b02-624c-2032-570501212b00",
|
||||
"sta": "I2",
|
||||
"off": "383bc9df0dd332629520a0a72f8dd7f0e97d579dccb4dbdc8592aa3d424c846c",
|
||||
@@ -276,7 +275,7 @@ pub trait ForeignRpc {
|
||||
}
|
||||
],
|
||||
"sta": "I3",
|
||||
"ver": "5:2"
|
||||
"ver": "4:2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
use chrono::prelude::*;
|
||||
use ed25519_dalek::SecretKey as DalekSecretKey;
|
||||
use grin_wallet_libwallet::contract::proofs::InvoiceProof;
|
||||
use grin_wallet_libwallet::RetrieveTxQueryArgs;
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -28,10 +27,6 @@ use crate::impls::SlateSender as _;
|
||||
use crate::keychain::{Identifier, Keychain};
|
||||
use crate::libwallet::api_impl::owner_updater::{start_updater_log_thread, StatusMessage};
|
||||
use crate::libwallet::api_impl::{owner, owner_updater};
|
||||
use crate::libwallet::contract::types::{
|
||||
ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI,
|
||||
};
|
||||
use crate::libwallet::mwmixnet::types::{MixnetReqCreationParams, SwapReq};
|
||||
use crate::libwallet::{
|
||||
AcctPathMapping, BuiltOutput, Error, InitTxArgs, IssueInvoiceTxArgs, NodeClient,
|
||||
NodeHeightResult, OutputCommitMapping, PaymentProof, Slate, Slatepack, SlatepackAddress,
|
||||
@@ -771,78 +766,6 @@ where
|
||||
owner::issue_invoice_tx(&mut **w, keychain_mask, args, self.doctest_mode)
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn contract_new(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
args: &ContractNewArgsAPI,
|
||||
) -> Result<Slate, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
// TODO: self.doctest_mode ?
|
||||
owner::contract_new(&mut **w, keychain_mask, &args)
|
||||
}
|
||||
|
||||
// /// TODO
|
||||
// pub fn contract_setup(
|
||||
// &self,
|
||||
// keychain_mask: Option<&SecretKey>,
|
||||
// slate: &Slate,
|
||||
// args: &ContractSetupArgsAPI,
|
||||
// ) -> Result<Slate, Error> {
|
||||
// let mut w_lock = self.wallet_inst.lock();
|
||||
// let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
// // TODO: self.doctest_mode ?
|
||||
// owner::contract_setup(&mut **w, keychain_mask, &args, &slate)
|
||||
// }
|
||||
|
||||
/// TODO
|
||||
pub fn contract_sign(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
slate: &Slate,
|
||||
args: &ContractSetupArgsAPI,
|
||||
) -> Result<Slate, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
owner::contract_sign(&mut **w, keychain_mask, &args, &slate)
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn get_slate_index_matching_my_context(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
slate: &Slate,
|
||||
) -> Result<usize, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
owner::get_slate_index_matching_my_context(&mut **w, keychain_mask, &slate)
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn contract_revoke(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
args: &ContractRevokeArgsAPI,
|
||||
) -> Result<Option<Slate>, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
owner::contract_revoke(&mut **w, keychain_mask, &args)
|
||||
}
|
||||
|
||||
/// Create MXMixnet request
|
||||
pub fn create_mwmixnet_req(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
params: &MixnetReqCreationParams,
|
||||
slate: &Slate,
|
||||
// use_test_rng: bool,
|
||||
) -> Result<SwapReq, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
owner::create_mwmixnet_req(&mut **w, keychain_mask, params, slate)
|
||||
}
|
||||
|
||||
/// Processes an invoice tranaction created by another party, essentially
|
||||
/// a `request for payment`. The incoming slate should contain a requested
|
||||
/// amount, an output created by the invoicer convering the amount, and
|
||||
@@ -2432,32 +2355,6 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
/// TODO: Temporary, likely should merge with above
|
||||
pub fn retrieve_payment_proof_invoice(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
refresh_from_node: bool,
|
||||
tx_id: Option<u32>,
|
||||
tx_slate_id: Option<Uuid>,
|
||||
) -> Result<InvoiceProof, Error> {
|
||||
let tx = {
|
||||
let t = self.status_tx.lock();
|
||||
t.clone()
|
||||
};
|
||||
let refresh_from_node = match self.updater_running.load(Ordering::Relaxed) {
|
||||
true => false,
|
||||
false => refresh_from_node,
|
||||
};
|
||||
owner::retrieve_payment_proof_invoice(
|
||||
self.wallet_inst.clone(),
|
||||
keychain_mask,
|
||||
&tx,
|
||||
refresh_from_node,
|
||||
tx_id,
|
||||
tx_slate_id,
|
||||
)
|
||||
}
|
||||
|
||||
/// Verifies a [PaymentProof](../grin_wallet_libwallet/api_impl/types/struct.PaymentProof.html)
|
||||
/// This process entails:
|
||||
///
|
||||
|
||||
+3
-106
@@ -20,9 +20,6 @@ use crate::config::{TorConfig, WalletConfig};
|
||||
use crate::core::core::OutputFeatures;
|
||||
use crate::core::global;
|
||||
use crate::keychain::{Identifier, Keychain};
|
||||
use crate::libwallet::contract::types::{
|
||||
ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI,
|
||||
};
|
||||
use crate::libwallet::{
|
||||
AcctPathMapping, Amount, BuiltOutput, Error, InitTxArgs, IssueInvoiceTxArgs, NodeClient,
|
||||
NodeHeightResult, OutputCommitMapping, PaymentProof, Slate, SlateVersion, Slatepack,
|
||||
@@ -504,7 +501,7 @@ pub trait OwnerRpc {
|
||||
}
|
||||
],
|
||||
"sta": "S1",
|
||||
"ver": "5:2"
|
||||
"ver": "4:2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -513,49 +510,8 @@ pub trait OwnerRpc {
|
||||
```
|
||||
*/
|
||||
|
||||
/**
|
||||
TODO: Full docs once API has stabilised
|
||||
*/
|
||||
fn init_send_tx(&self, token: Token, args: InitTxArgs) -> Result<VersionedSlate, Error>;
|
||||
|
||||
/**
|
||||
TODO: Implement
|
||||
*/
|
||||
// fn contract_setup(
|
||||
// &self,
|
||||
// token: Token,
|
||||
// slate: VersionedSlate,
|
||||
// args: ContractSetupArgsAPI,
|
||||
// ) -> Result<VersionedSlate, Error>;
|
||||
|
||||
/**
|
||||
TODO: Full docs once API has stabilised
|
||||
*/
|
||||
|
||||
fn contract_new(&self, token: Token, args: ContractNewArgsAPI)
|
||||
-> Result<VersionedSlate, Error>;
|
||||
|
||||
/**
|
||||
TODO: Full docs once API has stabilised
|
||||
*/
|
||||
|
||||
fn contract_sign(
|
||||
&self,
|
||||
token: Token,
|
||||
slate: VersionedSlate,
|
||||
args: ContractSetupArgsAPI,
|
||||
) -> Result<VersionedSlate, Error>;
|
||||
|
||||
/**
|
||||
TODO: Full docs once API has stabilised
|
||||
*/
|
||||
|
||||
fn contract_revoke(
|
||||
&self,
|
||||
token: Token,
|
||||
args: ContractRevokeArgsAPI,
|
||||
) -> Result<Option<VersionedSlate>, Error>;
|
||||
|
||||
/**
|
||||
;Networked version of [Owner::issue_invoice_tx](struct.Owner.html#method.issue_invoice_tx).
|
||||
|
||||
@@ -592,7 +548,7 @@ pub trait OwnerRpc {
|
||||
}
|
||||
],
|
||||
"sta": "I1",
|
||||
"ver": "5:2"
|
||||
"ver": "4:2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -963,7 +919,7 @@ pub trait OwnerRpc {
|
||||
"id": "0436430c-2b02-624c-2032-570501212b00",
|
||||
"sigs": [],
|
||||
"sta": "S3",
|
||||
"ver": "5:3"
|
||||
"ver": "4:3"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2096,65 +2052,6 @@ where
|
||||
VersionedSlate::into_version(slate, version)
|
||||
}
|
||||
|
||||
fn contract_new(
|
||||
&self,
|
||||
token: Token,
|
||||
args: ContractNewArgsAPI,
|
||||
) -> Result<VersionedSlate, Error> {
|
||||
let slate = Owner::contract_new(self, (&token.keychain_mask).as_ref(), &args)?;
|
||||
let version = SlateVersion::V4;
|
||||
VersionedSlate::into_version(slate, version)
|
||||
}
|
||||
|
||||
// fn contract_setup(
|
||||
// &self,
|
||||
// token: Token,
|
||||
// in_slate: VersionedSlate,
|
||||
// args: ContractSetupArgsAPI,
|
||||
// ) -> Result<VersionedSlate, Error> {
|
||||
// let slate = Owner::contract_setup(
|
||||
// self,
|
||||
// (&token.keychain_mask).as_ref(),
|
||||
// &Slate::from(in_slate),
|
||||
// &args,
|
||||
// )?;
|
||||
// let version = SlateVersion::V4;
|
||||
// VersionedSlate::into_version(slate, version)
|
||||
// }
|
||||
|
||||
fn contract_sign(
|
||||
&self,
|
||||
token: Token,
|
||||
in_slate: VersionedSlate,
|
||||
args: ContractSetupArgsAPI,
|
||||
) -> Result<VersionedSlate, Error> {
|
||||
let slate = Owner::contract_sign(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
&Slate::from(in_slate),
|
||||
&args,
|
||||
)?;
|
||||
let version = SlateVersion::V4;
|
||||
VersionedSlate::into_version(slate, version)
|
||||
}
|
||||
|
||||
fn contract_revoke(
|
||||
&self,
|
||||
token: Token,
|
||||
args: ContractRevokeArgsAPI,
|
||||
) -> Result<Option<VersionedSlate>, Error> {
|
||||
let slate_opt = Owner::contract_revoke(self, (&token.keychain_mask).as_ref(), &args)?;
|
||||
let version = SlateVersion::V4;
|
||||
// We return a slate only when we had to perform a self-spend safe cancel
|
||||
if slate_opt.is_some() {
|
||||
return Ok(Some(VersionedSlate::into_version(
|
||||
slate_opt.unwrap(),
|
||||
version,
|
||||
)?));
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn issue_invoice_tx(
|
||||
&self,
|
||||
token: Token,
|
||||
|
||||
Reference in New Issue
Block a user