mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-03 12:24:27 +01:00
merge staging
This commit is contained in:
+8
-8
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "grin_wallet_api"
|
||||
version = "5.5.0"
|
||||
version = "5.5.1"
|
||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||
description = "Grin Wallet API"
|
||||
license = "Apache-2.0"
|
||||
@@ -22,16 +22,16 @@ ring = "0.17.14"
|
||||
base64 = "0.12"
|
||||
ed25519-dalek = "2"
|
||||
|
||||
grin_wallet_libwallet = { path = "../libwallet", version = "5.5.0" }
|
||||
grin_wallet_config = { path = "../config", version = "5.5.0" }
|
||||
grin_wallet_impls = { path = "../impls", version = "5.5.0" }
|
||||
grin_wallet_util = { path = "../util", version = "5.5.0" }
|
||||
grin_wallet_libwallet = { path = "../libwallet", version = "5.5.1" }
|
||||
grin_wallet_config = { path = "../config", version = "5.5.1" }
|
||||
grin_wallet_impls = { path = "../impls", version = "5.5.1" }
|
||||
grin_wallet_util = { path = "../util", version = "5.5.1" }
|
||||
|
||||
##### Grin Imports
|
||||
|
||||
grin_core = { path = "../grin/core"}
|
||||
grin_keychain = { path = "../grin/keychain"}
|
||||
grin_util = { path = "../grin/util"}
|
||||
grin_core = { workspace = true }
|
||||
grin_keychain = { workspace = true }
|
||||
grin_util = { workspace = true }
|
||||
|
||||
#####
|
||||
|
||||
|
||||
+26
-35
@@ -20,15 +20,12 @@ use crate::libwallet::api_impl::types::update_tx_slate_state;
|
||||
use crate::libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
|
||||
use crate::libwallet::EarlyPaymentProof;
|
||||
use crate::libwallet::{
|
||||
BlockFees, CbData, Error, NodeClient, NodeVersionInfo, Slate, VersionInfo, WalletInst,
|
||||
WalletLCProvider,
|
||||
BlockFees, CbData, Error, NodeClient, NodeVersionInfo, Slate, VersionInfo, WalletLCProvider,
|
||||
};
|
||||
use crate::try_slatepack_sync_workflow;
|
||||
use crate::util::secp::key::SecretKey;
|
||||
use crate::util::Mutex;
|
||||
use ed25519_dalek::VerifyingKey as DalekPublicKey;
|
||||
use libwallet::SlatepackAddress;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// ForeignAPI Middleware Check callback
|
||||
pub type ForeignCheckMiddleware =
|
||||
@@ -58,15 +55,14 @@ pub enum ForeignCheckMiddlewareFn {
|
||||
/// called the ['Owner'](struct.Owner.html) and ['Foreign'](struct.Foreign.html) APIs
|
||||
///
|
||||
/// * The 'Foreign' API contains methods that other wallets will
|
||||
/// use to interact with the owner's wallet. This API can be exposed
|
||||
/// to the outside world, with the consideration as to how that can
|
||||
/// be done securely up to the implementor.
|
||||
/// use to interact with the owner's wallet. This API can be exposed
|
||||
/// to the outside world, with the consideration as to how that can
|
||||
/// be done securely up to the implementor.
|
||||
///
|
||||
/// Methods in both APIs are intended to be 'single use', that is to say each
|
||||
/// method will 'open' the wallet (load the keychain with its master seed), perform
|
||||
/// its operation, then 'close' the wallet (unloading references to the keychain and master
|
||||
/// seed).
|
||||
|
||||
pub struct Foreign<'a, L, C, K>
|
||||
where
|
||||
L: WalletLCProvider<'a, C, K>,
|
||||
@@ -74,7 +70,7 @@ where
|
||||
K: Keychain + 'a,
|
||||
{
|
||||
/// Wallet instance
|
||||
pub wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
|
||||
pub wallet_inst: grin_wallet_libwallet::WalletHandle<'a, L, C, K>,
|
||||
/// Wallet configuration path
|
||||
config_path: crate::ConfigPath,
|
||||
/// Flag to normalize some output during testing. Can mostly be ignored.
|
||||
@@ -101,13 +97,13 @@ where
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `wallet_in` - A reference-counted mutex containing an implementation of the
|
||||
/// [`WalletBackend`](../grin_wallet_libwallet/types/trait.WalletBackend.html) trait.
|
||||
/// [`WalletBackend`](../grin_wallet_libwallet/types/trait.WalletBackend.html) trait.
|
||||
/// * `config_path` - Path to the wallet configuration file
|
||||
/// * `keychain_mask` - Mask value stored internally to use when calling a wallet
|
||||
/// whose seed has been XORed with a token value (such as when running the foreign
|
||||
/// and owner listeners in the same instance)
|
||||
/// whose seed has been XORed with a token value (such as when running the foreign
|
||||
/// and owner listeners in the same instance)
|
||||
/// * middleware - Option middleware which containts the NodeVersionInfo and can call
|
||||
/// a predefined function with the slate to check if the operation should continue
|
||||
/// a predefined function with the slate to check if the operation should continue
|
||||
///
|
||||
/// # Returns
|
||||
/// * An instance of the ForeignApi holding a reference to the provided wallet
|
||||
@@ -177,9 +173,8 @@ where
|
||||
/// // .. perform wallet operations
|
||||
///
|
||||
/// ```
|
||||
|
||||
pub fn new<P>(
|
||||
wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
|
||||
wallet_inst: grin_wallet_libwallet::WalletHandle<'a, L, C, K>,
|
||||
config_path: P,
|
||||
keychain_mask: Option<SecretKey>,
|
||||
middleware: Option<ForeignCheckMiddleware>,
|
||||
@@ -212,7 +207,6 @@ where
|
||||
/// let version_info = api_foreign.check_version();
|
||||
/// // check and proceed accordingly
|
||||
/// ```
|
||||
|
||||
pub fn check_version(&self) -> Result<VersionInfo, Error> {
|
||||
if let Some(m) = self.middleware.as_ref() {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
@@ -238,7 +232,7 @@ where
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `block_fees` - A [`BlockFees`](../grin_wallet_libwallet/api_impl/types/struct.BlockFees.html)
|
||||
/// struct, set up as follows:
|
||||
/// struct, set up as follows:
|
||||
///
|
||||
/// `fees` - should contain the sum of all transaction fees included in the potential
|
||||
/// block
|
||||
@@ -251,7 +245,7 @@ where
|
||||
///
|
||||
/// # Returns
|
||||
/// * `Ok`([`cb_data`](../grin_wallet_libwallet/api_impl/types/struct.CbData.html)`)` if successful. This
|
||||
/// will contain the corresponding output, kernel and keyID used to create the coinbase output.
|
||||
/// will contain the corresponding output, kernel and keyID used to create the coinbase output.
|
||||
/// * or [`libwallet::Error`](../grin_wallet_libwallet/struct.Error.html) if an error is encountered.
|
||||
///
|
||||
/// # Example
|
||||
@@ -275,7 +269,6 @@ where
|
||||
/// // ...
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
pub fn build_coinbase(&self, block_fees: &BlockFees) -> Result<CbData, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
@@ -288,7 +281,7 @@ where
|
||||
}
|
||||
foreign::build_coinbase(
|
||||
w,
|
||||
(&self.keychain_mask).as_ref(),
|
||||
self.keychain_mask.as_ref(),
|
||||
block_fees,
|
||||
self.doctest_mode,
|
||||
)
|
||||
@@ -311,18 +304,18 @@ where
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `slate` - The transaction [`Slate`](../grin_wallet_libwallet/slate/struct.Slate.html).
|
||||
/// The slate should contain the results of the sender's round 1 (e.g, public nonce and public
|
||||
/// excess value).
|
||||
/// The slate should contain the results of the sender's round 1 (e.g, public nonce and public
|
||||
/// excess value).
|
||||
/// * `dest_acct_name` - The name of the account into which the slate should be received. If
|
||||
/// `None`, the default account is used.
|
||||
/// `None`, the default account is used.
|
||||
/// * `r_addr` - If included, attempt to send the slate back to the sender using the slatepack sync
|
||||
/// send (TOR). If providing this argument, check the `state` field of the slate to see if the
|
||||
/// sync_send was successful (it should be S3 if the synced send sent successfully).
|
||||
/// send (TOR). If providing this argument, check the `state` field of the slate to see if the
|
||||
/// sync_send was successful (it should be S3 if the synced send sent successfully).
|
||||
///
|
||||
/// # Returns
|
||||
/// * a result containing:
|
||||
/// * `Ok`([`slate`](../grin_wallet_libwallet/slate/struct.Slate.html)`)` if successful,
|
||||
/// containing the new slate updated with the recipient's output and public signing information.
|
||||
/// containing the new slate updated with the recipient's output and public signing information.
|
||||
/// * or [`libwallet::Error`](../grin_wallet_libwallet/struct.Error.html) if an error is encountered.
|
||||
///
|
||||
/// # Remarks
|
||||
@@ -346,7 +339,6 @@ where
|
||||
/// // ...
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
pub fn receive_tx(
|
||||
&self,
|
||||
slate: &Slate,
|
||||
@@ -368,7 +360,7 @@ where
|
||||
}
|
||||
let ret_slate = foreign::receive_tx(
|
||||
w,
|
||||
(&self.keychain_mask).as_ref(),
|
||||
self.keychain_mask.as_ref(),
|
||||
slate,
|
||||
dest_acct_name,
|
||||
self.doctest_mode,
|
||||
@@ -388,7 +380,7 @@ where
|
||||
let parent_key_id = w.parent_key_id();
|
||||
match update_tx_slate_state(
|
||||
w,
|
||||
(&self.keychain_mask).as_ref(),
|
||||
self.keychain_mask.as_ref(),
|
||||
&parent_key_id,
|
||||
&s,
|
||||
) {
|
||||
@@ -423,11 +415,11 @@ where
|
||||
/// # Arguments
|
||||
/// * `slate` - The transaction [`Slate`](../grin_wallet_libwallet/slate/struct.Slate.html). The
|
||||
/// * `post_automatically` - If true, post the finalized transaction to the configured listening
|
||||
/// node
|
||||
/// node
|
||||
///
|
||||
/// # Returns
|
||||
/// * Ok([`slate`](../grin_wallet_libwallet/slate/struct.Slate.html)) if successful,
|
||||
/// containing the new finalized slate.
|
||||
/// containing the new finalized slate.
|
||||
/// * or [`libwallet::Error`](../grin_wallet_libwallet/struct.Error.html) if an error is encountered.
|
||||
///
|
||||
/// # Example
|
||||
@@ -454,7 +446,6 @@ where
|
||||
/// let slate = api_foreign.finalize_tx(&slate, true);
|
||||
/// // if okay, then post via the owner API
|
||||
/// ```
|
||||
|
||||
pub fn finalize_tx(&self, slate: &Slate, post_automatically: bool) -> Result<Slate, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
@@ -469,7 +460,7 @@ where
|
||||
true => false,
|
||||
false => post_automatically,
|
||||
};
|
||||
foreign::finalize_tx(w, (&self.keychain_mask).as_ref(), slate, post_automatically)
|
||||
foreign::finalize_tx(w, self.keychain_mask.as_ref(), slate, post_automatically)
|
||||
}
|
||||
|
||||
// Below is a foreign wrapper around owner calls to 'new' and 'sign' which are only executed
|
||||
@@ -511,7 +502,7 @@ where
|
||||
None,
|
||||
)?;
|
||||
}
|
||||
foreign::contract_new(w, (&self.keychain_mask).as_ref(), args)
|
||||
foreign::contract_new(w, self.keychain_mask.as_ref(), args)
|
||||
}
|
||||
|
||||
/// Sign the receiving side of a contract through the foreign API.
|
||||
@@ -557,7 +548,7 @@ where
|
||||
Some(slate),
|
||||
)?;
|
||||
}
|
||||
foreign::contract_sign(w, (&self.keychain_mask).as_ref(), args, slate)
|
||||
foreign::contract_sign(w, self.keychain_mask.as_ref(), args, slate)
|
||||
}
|
||||
|
||||
/// Verify an early payment proof against the chain
|
||||
|
||||
+11
-23
@@ -20,7 +20,6 @@ use crate::libwallet::{
|
||||
Slate, SlateVersion, VersionInfo, VersionedCoinbase, VersionedSlate, WalletLCProvider,
|
||||
};
|
||||
use crate::{Foreign, ForeignCheckMiddlewareFn};
|
||||
use easy_jsonrpc_mw;
|
||||
use grin_wallet_config::initial_setup_wallet;
|
||||
use libwallet::SlatepackAddress;
|
||||
use std::path::PathBuf;
|
||||
@@ -113,7 +112,6 @@ pub trait ForeignRpc {
|
||||
# ,false, 4, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn build_coinbase(&self, block_fees: &BlockFees) -> Result<VersionedCoinbase, Error>;
|
||||
|
||||
/**
|
||||
@@ -323,19 +321,14 @@ where
|
||||
}
|
||||
},
|
||||
};
|
||||
let out_slate = Foreign::receive_tx(
|
||||
self,
|
||||
&slate_from,
|
||||
dest_acct_name.as_ref().map(String::as_str),
|
||||
dest,
|
||||
)?;
|
||||
Ok(VersionedSlate::into_version(out_slate, version)?)
|
||||
let out_slate = Foreign::receive_tx(self, &slate_from, dest_acct_name.as_deref(), dest)?;
|
||||
VersionedSlate::into_version(out_slate, version)
|
||||
}
|
||||
|
||||
fn finalize_tx(&self, in_slate: VersionedSlate) -> Result<VersionedSlate, Error> {
|
||||
let version = in_slate.version();
|
||||
let out_slate = Foreign::finalize_tx(self, &Slate::from(in_slate), true)?;
|
||||
Ok(VersionedSlate::into_version(out_slate, version)?)
|
||||
VersionedSlate::into_version(out_slate, version)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,19 +459,14 @@ pub fn run_doctest_foreign(
|
||||
let _ = test_framework::award_blocks_to_wallet(
|
||||
&chain,
|
||||
wallet1.clone(),
|
||||
(&mask1).as_ref(),
|
||||
1 as usize,
|
||||
mask1.as_ref(),
|
||||
1_usize,
|
||||
false,
|
||||
);
|
||||
//update local outputs after each block, so transaction IDs stay consistent
|
||||
let (wallet_refreshed, _) = api_impl::owner::retrieve_summary_info(
|
||||
wallet1.clone(),
|
||||
(&mask1).as_ref(),
|
||||
&None,
|
||||
true,
|
||||
1,
|
||||
)
|
||||
.unwrap();
|
||||
let (wallet_refreshed, _) =
|
||||
api_impl::owner::retrieve_summary_info(wallet1.clone(), mask1.as_ref(), &None, true, 1)
|
||||
.unwrap();
|
||||
assert!(wallet_refreshed);
|
||||
}
|
||||
|
||||
@@ -491,7 +479,7 @@ pub fn run_doctest_foreign(
|
||||
amount,
|
||||
..Default::default()
|
||||
};
|
||||
api_impl::owner::issue_invoice_tx(w, (&mask2).as_ref(), args, true).unwrap()
|
||||
api_impl::owner::issue_invoice_tx(w, mask2.as_ref(), args, true).unwrap()
|
||||
};
|
||||
slate = {
|
||||
let mut w_lock = wallet1.lock();
|
||||
@@ -505,7 +493,7 @@ pub fn run_doctest_foreign(
|
||||
selection_strategy_is_use_all: true,
|
||||
..Default::default()
|
||||
};
|
||||
api_impl::owner::process_invoice_tx(w, (&mask1).as_ref(), &slate, args, true).unwrap()
|
||||
api_impl::owner::process_invoice_tx(w, mask1.as_ref(), &slate, args, true).unwrap()
|
||||
};
|
||||
println!("INIT INVOICE SLATE");
|
||||
// Spit out slate for input to finalize_tx
|
||||
@@ -525,7 +513,7 @@ pub fn run_doctest_foreign(
|
||||
selection_strategy_is_use_all: true,
|
||||
..Default::default()
|
||||
};
|
||||
let slate = api_impl::owner::init_send_tx(w, (&mask1).as_ref(), args, true).unwrap();
|
||||
let slate = api_impl::owner::init_send_tx(w, mask1.as_ref(), args, true).unwrap();
|
||||
println!("INIT SLATE");
|
||||
// Spit out slate for input to finalize_tx
|
||||
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
|
||||
|
||||
+413
-319
File diff suppressed because it is too large
Load Diff
+169
-150
@@ -14,7 +14,7 @@
|
||||
|
||||
//! JSON-RPC Stub generation for the Owner API
|
||||
use grin_wallet_libwallet::RetrieveTxQueryArgs;
|
||||
use libwallet::mwixnet::SwapReq;
|
||||
use libwallet::mwixnet::MwixnetReqCreationResult;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::config::{TorConfig, WalletConfig};
|
||||
@@ -25,18 +25,19 @@ use crate::libwallet::contract::types::{
|
||||
ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI, ContractView,
|
||||
};
|
||||
use crate::libwallet::{
|
||||
mwixnet::MixnetReqCreationParams, AcctPathMapping, Amount, BuiltOutput, Error, InitTxArgs,
|
||||
IssueInvoiceTxArgs, NodeClient, NodeHeightResult, OutputCommitMapping, PaymentProof, Slate,
|
||||
SlateVersion, Slatepack, SlatepackAddress, StatusMessage, TxLogEntry, VersionedSlate,
|
||||
ViewWallet, WalletInfo, WalletLCProvider,
|
||||
mwixnet::{MixnetReqCreationParams, MwixnetServerPublicKey},
|
||||
AcctPathMapping, Amount, BuiltOutput, Error, InitTxArgs, IssueInvoiceTxArgs, NodeClient,
|
||||
NodeHeightResult, OutputCommitMapping, PaymentProof, Slate, SlateVersion, Slatepack,
|
||||
SlatepackAddress, StatusMessage, TxLogEntry, VersionedSlate, ViewWallet, WalletInfo,
|
||||
WalletLCProvider,
|
||||
};
|
||||
use crate::util::logger::LoggingConfig;
|
||||
use crate::util::secp::key::{PublicKey, SecretKey};
|
||||
use crate::util::secp::pedersen::Commitment;
|
||||
use crate::util::{from_hex, static_secp_instance, Mutex, ZeroingString};
|
||||
use crate::{ECDHPubkey, Ed25519SecretKey, Owner, Token};
|
||||
use easy_jsonrpc_mw;
|
||||
use grin_wallet_util::OnionV3Address;
|
||||
use libwallet::slatepack::SlatepackAddressIndex;
|
||||
use rand::thread_rng;
|
||||
use std::convert::TryFrom;
|
||||
use std::path::PathBuf;
|
||||
@@ -51,7 +52,7 @@ use std::time::Duration;
|
||||
#[easy_jsonrpc_mw::rpc]
|
||||
pub trait OwnerRpc {
|
||||
/**
|
||||
Networked version of [Owner::accounts](struct.Owner.html#method.accounts).
|
||||
Networked version of [Owner::accounts](struct.Owner.html#method.accounts). Returns account mappings without balances.
|
||||
|
||||
# Json rpc example
|
||||
|
||||
@@ -75,7 +76,9 @@ pub trait OwnerRpc {
|
||||
"Ok": [
|
||||
{
|
||||
"label": "default",
|
||||
"path": "0200000000000000000000000000000000"
|
||||
"path": "0200000000000000000000000000000000",
|
||||
"info": null,
|
||||
"current": true
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -87,6 +90,60 @@ pub trait OwnerRpc {
|
||||
*/
|
||||
fn accounts(&self, token: Token) -> Result<Vec<AcctPathMapping>, Error>;
|
||||
|
||||
/**
|
||||
Networked version of [Owner::accounts_info](struct.Owner.html#method.accounts_info). Returns balances from locally stored state without refreshing from the node.
|
||||
|
||||
# Json rpc example
|
||||
|
||||
```
|
||||
# grin_wallet_api::doctest_helper_json_rpc_owner_assert_response!(
|
||||
# r#"
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "accounts_info",
|
||||
"params": {
|
||||
"token": "d202964900000000d302964900000000d402964900000000d502964900000000",
|
||||
"minimum_confirmations": 1
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
# "#
|
||||
# ,
|
||||
# r#"
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"Ok": [
|
||||
{
|
||||
"label": "default",
|
||||
"path": "0200000000000000000000000000000000",
|
||||
"info": {
|
||||
"amount_awaiting_confirmation": "0",
|
||||
"amount_awaiting_finalization": "0",
|
||||
"amount_currently_spendable": "60000000000",
|
||||
"amount_immature": "180000000000",
|
||||
"amount_locked": "0",
|
||||
"amount_reverted": "0",
|
||||
"last_confirmed_height": "4",
|
||||
"minimum_confirmations": "1",
|
||||
"total": "240000000000"
|
||||
},
|
||||
"current": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
# "#
|
||||
# , 4, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
fn accounts_info(
|
||||
&self,
|
||||
token: Token,
|
||||
minimum_confirmations: u64,
|
||||
) -> Result<Vec<AcctPathMapping>, Error>;
|
||||
|
||||
/**
|
||||
Networked version of [Owner::create_account_path](struct.Owner.html#method.create_account_path).
|
||||
|
||||
@@ -118,10 +175,12 @@ pub trait OwnerRpc {
|
||||
# , 4, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
#[allow(clippy::ptr_arg)]
|
||||
fn create_account_path(&self, token: Token, label: &String) -> Result<Identifier, Error>;
|
||||
|
||||
/**
|
||||
Networked version of [Owner::set_active_account](struct.Owner.html#method.set_active_account).
|
||||
The account selection is saved across wallet restarts
|
||||
|
||||
# Json rpc example
|
||||
|
||||
@@ -151,6 +210,7 @@ pub trait OwnerRpc {
|
||||
# , 4, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
#[allow(clippy::ptr_arg)]
|
||||
fn set_active_account(&self, token: Token, label: &String) -> Result<(), Error>;
|
||||
|
||||
/**
|
||||
@@ -222,7 +282,6 @@ pub trait OwnerRpc {
|
||||
# , 2, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn retrieve_outputs(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -268,7 +327,6 @@ pub trait OwnerRpc {
|
||||
# , 4, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn estimate_max_sendable(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -306,6 +364,7 @@ pub trait OwnerRpc {
|
||||
true,
|
||||
[
|
||||
{
|
||||
"address_index": null,
|
||||
"amount_credited": "60000000000",
|
||||
"amount_debited": "0",
|
||||
"confirmation_ts": "2019-01-15T16:01:26Z",
|
||||
@@ -327,6 +386,7 @@ pub trait OwnerRpc {
|
||||
"tx_type": "ConfirmedCoinbase"
|
||||
},
|
||||
{
|
||||
"address_index": null,
|
||||
"amount_credited": "60000000000",
|
||||
"amount_debited": "0",
|
||||
"confirmation_ts": "2019-01-15T16:01:26Z",
|
||||
@@ -355,7 +415,6 @@ pub trait OwnerRpc {
|
||||
# , 2, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn retrieve_txs(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -399,6 +458,7 @@ pub trait OwnerRpc {
|
||||
true,
|
||||
[
|
||||
{
|
||||
"address_index": null,
|
||||
"amount_credited": "60000000000",
|
||||
"amount_debited": "0",
|
||||
"confirmation_ts": "2019-01-15T16:01:26Z",
|
||||
@@ -420,6 +480,7 @@ pub trait OwnerRpc {
|
||||
"tx_type": "ConfirmedCoinbase"
|
||||
},
|
||||
{
|
||||
"address_index": null,
|
||||
"amount_credited": "60000000000",
|
||||
"amount_debited": "0",
|
||||
"confirmation_ts": "2019-01-15T16:01:26Z",
|
||||
@@ -449,7 +510,6 @@ pub trait OwnerRpc {
|
||||
```
|
||||
|
||||
*/
|
||||
|
||||
fn query_txs(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -500,7 +560,6 @@ pub trait OwnerRpc {
|
||||
# , 4, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn retrieve_summary_info(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -548,7 +607,7 @@ pub trait OwnerRpc {
|
||||
"id": "0436430c-2b02-624c-2032-570501212b00",
|
||||
"proof": {
|
||||
"raddr": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3",
|
||||
"saddr": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3"
|
||||
"saddr": "4b2adcc4efc1d547c08ed7c9f7d987ff085f1788d62805e73c8f632e4b065039"
|
||||
},
|
||||
"sigs": [
|
||||
{
|
||||
@@ -565,7 +624,6 @@ pub trait OwnerRpc {
|
||||
# , 4, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn init_send_tx(&self, token: Token, args: InitTxArgs) -> Result<VersionedSlate, Error>;
|
||||
|
||||
/**
|
||||
@@ -875,7 +933,6 @@ pub trait OwnerRpc {
|
||||
# , 4, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn issue_invoice_tx(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -959,7 +1016,6 @@ pub trait OwnerRpc {
|
||||
# , 4, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn process_invoice_tx(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -1164,7 +1220,6 @@ pub trait OwnerRpc {
|
||||
# , 5, true, true, true, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn post_tx(&self, token: Token, slate: VersionedSlate, fluff: bool) -> Result<(), Error>;
|
||||
|
||||
/**
|
||||
@@ -1486,7 +1541,6 @@ pub trait OwnerRpc {
|
||||
```
|
||||
|
||||
*/
|
||||
|
||||
fn init_secure_api(&self, ecdh_pubkey: ECDHPubkey) -> Result<ECDHPubkey, Error>;
|
||||
|
||||
/**
|
||||
@@ -1516,7 +1570,6 @@ pub trait OwnerRpc {
|
||||
# , 5, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn get_top_level_directory(&self) -> Result<String, Error>;
|
||||
|
||||
/**
|
||||
@@ -1549,7 +1602,6 @@ pub trait OwnerRpc {
|
||||
# , 5, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn set_top_level_directory(&self, dir: String) -> Result<(), Error>;
|
||||
|
||||
/**
|
||||
@@ -1652,7 +1704,6 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn create_wallet(
|
||||
&self,
|
||||
name: Option<String>,
|
||||
@@ -1689,7 +1740,6 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn open_wallet(&self, name: Option<String>, password: String) -> Result<Token, Error>;
|
||||
|
||||
/**
|
||||
@@ -1719,7 +1769,6 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn close_wallet(&self, name: Option<String>) -> Result<(), Error>;
|
||||
|
||||
/**
|
||||
@@ -1750,7 +1799,6 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn get_mnemonic(&self, name: Option<String>, password: String) -> Result<String, Error>;
|
||||
|
||||
/**
|
||||
@@ -1841,7 +1889,6 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn start_updater(&self, token: Token, frequency: u32) -> Result<(), Error>;
|
||||
|
||||
/**
|
||||
@@ -1898,7 +1945,6 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn get_updater_messages(&self, count: u32) -> Result<Vec<StatusMessage>, Error>;
|
||||
|
||||
/**
|
||||
@@ -1929,11 +1975,10 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn get_slatepack_address(
|
||||
&self,
|
||||
token: Token,
|
||||
derivation_index: u32,
|
||||
derivation_index: SlatepackAddressIndex,
|
||||
) -> Result<SlatepackAddress, Error>;
|
||||
|
||||
/**
|
||||
@@ -1964,11 +2009,10 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn get_slatepack_secret_key(
|
||||
&self,
|
||||
token: Token,
|
||||
derivation_index: u32,
|
||||
derivation_index: SlatepackAddressIndex,
|
||||
) -> Result<Ed25519SecretKey, Error>;
|
||||
|
||||
/**
|
||||
@@ -2014,12 +2058,11 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn create_slatepack_message(
|
||||
&self,
|
||||
token: Token,
|
||||
slate: VersionedSlate,
|
||||
sender_index: Option<u32>,
|
||||
sender_index: Option<SlatepackAddressIndex>,
|
||||
recipients: Vec<SlatepackAddress>,
|
||||
) -> Result<String, Error>;
|
||||
|
||||
@@ -2069,12 +2112,11 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn slate_from_slatepack_message(
|
||||
&self,
|
||||
token: Token,
|
||||
message: String,
|
||||
secret_indices: Vec<u32>,
|
||||
secret_indices: Vec<SlatepackAddressIndex>,
|
||||
) -> Result<VersionedSlate, Error>;
|
||||
|
||||
/**
|
||||
@@ -2111,12 +2153,11 @@ pub trait OwnerRpc {
|
||||
# , 0, false, false, false, false);
|
||||
```
|
||||
*/
|
||||
|
||||
fn decode_slatepack_message(
|
||||
&self,
|
||||
token: Token,
|
||||
message: String,
|
||||
secret_indices: Vec<u32>,
|
||||
secret_indices: Vec<SlatepackAddressIndex>,
|
||||
) -> Result<Slatepack, Error>;
|
||||
|
||||
/**
|
||||
@@ -2148,6 +2189,7 @@ pub trait OwnerRpc {
|
||||
"recipient_address": "tgrin10qlk22rxjap2ny8qltc2tl996kenxr3hhwuu6hrzs6tdq08yaqgqq6t83r",
|
||||
"recipient_sig": "02868f2d2b983981f8f98043701687a8531ed2de564ea3df48e9e7e0229ccbe8359efe506896df2efbe3528e977252c50e4a41ca3cc9896e7c5a30bbb1d33604",
|
||||
"sender_address": "tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp",
|
||||
"sender_address_path": 0,
|
||||
"sender_sig": "c511764f3f61ed3d1cbca9514df8bc6811fad5662b1cb0e0587b9c9e49db9f33183cce71af6cb24b507fabf525a2bc405c6e84e63a60334edff0b451ae5e6102"
|
||||
}
|
||||
}
|
||||
@@ -2156,7 +2198,6 @@ pub trait OwnerRpc {
|
||||
# , 5, true, true, true, true);
|
||||
```
|
||||
*/
|
||||
|
||||
fn retrieve_payment_proof(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -2181,6 +2222,7 @@ pub trait OwnerRpc {
|
||||
"recipient_address": "tgrin10qlk22rxjap2ny8qltc2tl996kenxr3hhwuu6hrzs6tdq08yaqgqq6t83r",
|
||||
"recipient_sig": "02868f2d2b983981f8f98043701687a8531ed2de564ea3df48e9e7e0229ccbe8359efe506896df2efbe3528e977252c50e4a41ca3cc9896e7c5a30bbb1d33604",
|
||||
"sender_address": "tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp",
|
||||
"sender_address_path": 0,
|
||||
"sender_sig": "c511764f3f61ed3d1cbca9514df8bc6811fad5662b1cb0e0587b9c9e49db9f33183cce71af6cb24b507fabf525a2bc405c6e84e63a60334edff0b451ae5e6102"
|
||||
}
|
||||
},
|
||||
@@ -2203,7 +2245,6 @@ pub trait OwnerRpc {
|
||||
# , 5, true, true, true, true);
|
||||
```
|
||||
*/
|
||||
|
||||
fn verify_payment_proof(
|
||||
&self,
|
||||
token: Token,
|
||||
@@ -2288,7 +2329,11 @@ pub trait OwnerRpc {
|
||||
) -> Result<BuiltOutput, Error>;
|
||||
|
||||
/**
|
||||
Networked version of [Owner::build_output](struct.Owner.html#method.create_mwixnet_req).
|
||||
Networked version of [Owner::create_mwixnet_req](struct.Owner.html#method.create_mwixnet_req).
|
||||
|
||||
server_keys accepts public X25519 onion keys as hex, in route order, replacing secret keys
|
||||
fee_per_hop accepts a nanogrin string or null for the swap minimum
|
||||
|
||||
```
|
||||
# grin_wallet_api::doctest_helper_json_rpc_owner_assert_response!(
|
||||
# r#"
|
||||
@@ -2298,12 +2343,12 @@ pub trait OwnerRpc {
|
||||
"params": {
|
||||
"token": "d202964900000000d302964900000000d402964900000000d502964900000000",
|
||||
"commitment": "08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7",
|
||||
"fee_per_hop": "5000000",
|
||||
"fee_per_hop": null,
|
||||
"lock_output": true,
|
||||
"server_keys": [
|
||||
"97444ae673bb92c713c1a2f7b8882ffbfc1c67401a280a775dce1a8651584332",
|
||||
"0c9414341f2140ed34a5a12a6479bf5a6404820d001ab81d9d3e8cc38f049b4e",
|
||||
"b58ece97d60e71bb7e53218400b0d67bfe6a3cb7d3b4a67a44f8fb7c525cbca5"
|
||||
"24308f58032819d05146db48e78246139f8e30770b1fd1585392df8374d6226a",
|
||||
"3ab3b7d1fb643393897a0b942934d34be9cb823621cd49c09b12fdfa69598d71",
|
||||
"80f2ceadcc5a767961772f4ae04826c70b0ae497f4f50d782241ff056b71df45"
|
||||
]
|
||||
},
|
||||
"id": 1
|
||||
@@ -2325,24 +2370,24 @@ pub trait OwnerRpc {
|
||||
"62ea6b8369686a0415e1e752b9b4d6e66cf5b6066a2d3c60d8818890a55f3adff4601466f4c6e6b646568b99ae93549a3595b7a7b4be815ced87d9297cabbd69518d7b2ed6edd14007528fd346aaea765a1165fe886666627ebcab9588b8ee1c9e98395ae67913c48eb6e924581b40182fce807f97312fb07fd5e216d99941f2b488babce4078a50cd66b28b30a66c4f54fcc127437408a99b30ffd6c3d0d8c7d39e864fc04e321b8c10138c8852d4cad0a4f2780412b9dadcc6e0f2657b7803a81bccb809ca392464be2e01755be7377d0e815698ad6ea51d4617cc92c3ccf852f038e33cc9c90992438ba5c49cca7cc188b682da684e2f4c9733a84a7b64ac5c2216ebf5926f0ee67b664fb5bab799109cbee755ce1aebc8cd352fea51cd84c333cb958093c53544c3f3ab05dba64d8f041c3b179796b476ec04b11044e39db6994ab767315e52cc0ef023432ec88ade2911612db7e74e0923889f765b58b00e3869c5072a4e882c1b721913f63bda986b8c97b7ae575f0d4be596a1ac3cd0db96ce6074ee000b32018b3bda16d7dba34a13ba9c3ce983946414c16e278351a3411cb8ef2cb8ef5b6e1667c4c58bc797c0324ae4fec8960d684e561c0e833ee4c3331c6c439b59042a62993535e23cc8a8a4cf705c0f9b1d62db4e3d76c22c01138800414b143ddff471e4df4413e842a1b41f43cc9647e47145fd6c86d4d1a34fb2f62f5a55b31c9353ee34743c548eff955f2d2143c1a86cbcb452104f96d0142db31153021bbeed995c71a92de8fb1f97269533a508085c543fcb3ee57000bb265e74187b858403aa97b6c7b085e5d5b6025cbfe5f6926d33c835f90e60fc62013e80bbe0a855da5938b4b8f83ac29c5e8251827795356222079a6d1612e2fdf93bd7836d1613c7a353ada48ce256f880bbbb3108e037e3b5647101bd4d549101b0ee73d2248a932a802a3b1beb0b69d777c4285d57e91d83e96fe2f8a1a2f182fe2c6ca37b18460cf8d7f56c201147b9be19f1d01f8ad305c1e9c4dd79b5d8719d6550432352cf737082b1e9de7a083ffbe1"
|
||||
],
|
||||
"pubkey": "e7ee7d51b11d09f268ade98bc9d7ae9be3c4ac124ce1c3a40e50d34460fa5f08"
|
||||
}
|
||||
},
|
||||
"tx_id": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
# "#
|
||||
# , 5, true, true, false, false);
|
||||
# , 5, true, false, false, false);
|
||||
```
|
||||
*
|
||||
*/
|
||||
|
||||
fn create_mwixnet_req(
|
||||
&self,
|
||||
token: Token,
|
||||
commitment: String,
|
||||
fee_per_hop: String,
|
||||
fee_per_hop: Option<String>,
|
||||
lock_output: bool,
|
||||
server_keys: Vec<String>,
|
||||
) -> Result<SwapReq, Error>;
|
||||
) -> Result<MwixnetReqCreationResult, Error>;
|
||||
}
|
||||
|
||||
fn versioned_output(slate: Slate) -> Result<VersionedSlate, Error> {
|
||||
@@ -2357,15 +2402,23 @@ where
|
||||
K: Keychain + 'static,
|
||||
{
|
||||
fn accounts(&self, token: Token) -> Result<Vec<AcctPathMapping>, Error> {
|
||||
Owner::accounts(self, (&token.keychain_mask).as_ref())
|
||||
Owner::accounts(self, token.keychain_mask.as_ref())
|
||||
}
|
||||
|
||||
fn accounts_info(
|
||||
&self,
|
||||
token: Token,
|
||||
minimum_confirmations: u64,
|
||||
) -> Result<Vec<AcctPathMapping>, Error> {
|
||||
Owner::accounts_info(self, token.keychain_mask.as_ref(), minimum_confirmations)
|
||||
}
|
||||
|
||||
fn create_account_path(&self, token: Token, label: &String) -> Result<Identifier, Error> {
|
||||
Owner::create_account_path(self, (&token.keychain_mask).as_ref(), label)
|
||||
Owner::create_account_path(self, token.keychain_mask.as_ref(), label)
|
||||
}
|
||||
|
||||
fn set_active_account(&self, token: Token, label: &String) -> Result<(), Error> {
|
||||
Owner::set_active_account(self, (&token.keychain_mask).as_ref(), label)
|
||||
Owner::set_active_account(self, token.keychain_mask.as_ref(), label)
|
||||
}
|
||||
|
||||
fn retrieve_outputs(
|
||||
@@ -2377,7 +2430,7 @@ where
|
||||
) -> Result<(bool, Vec<OutputCommitMapping>), Error> {
|
||||
Owner::retrieve_outputs(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
include_spent,
|
||||
refresh_from_node,
|
||||
tx_id,
|
||||
@@ -2392,7 +2445,7 @@ where
|
||||
) -> Result<(bool, u64, u64, u32), Error> {
|
||||
Owner::estimate_max_sendable(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
refresh_from_node,
|
||||
minimum_confirmations,
|
||||
)
|
||||
@@ -2407,7 +2460,7 @@ where
|
||||
) -> Result<(bool, Vec<TxLogEntry>), Error> {
|
||||
Owner::retrieve_txs(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
refresh_from_node,
|
||||
tx_id,
|
||||
tx_slate_id,
|
||||
@@ -2423,7 +2476,7 @@ where
|
||||
) -> Result<(bool, Vec<TxLogEntry>), Error> {
|
||||
Owner::retrieve_txs(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
refresh_from_node,
|
||||
None,
|
||||
None,
|
||||
@@ -2439,14 +2492,14 @@ where
|
||||
) -> Result<(bool, WalletInfo), Error> {
|
||||
Owner::retrieve_summary_info(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
refresh_from_node,
|
||||
minimum_confirmations,
|
||||
)
|
||||
}
|
||||
|
||||
fn init_send_tx(&self, token: Token, args: InitTxArgs) -> Result<VersionedSlate, Error> {
|
||||
let slate = Owner::init_send_tx(self, (&token.keychain_mask).as_ref(), args)?;
|
||||
let slate = Owner::init_send_tx(self, token.keychain_mask.as_ref(), args)?;
|
||||
versioned_output(slate)
|
||||
}
|
||||
|
||||
@@ -2455,7 +2508,7 @@ where
|
||||
token: Token,
|
||||
args: ContractNewArgsAPI,
|
||||
) -> Result<VersionedSlate, Error> {
|
||||
let slate = Owner::contract_new(self, (&token.keychain_mask).as_ref(), &args)?;
|
||||
let slate = Owner::contract_new(self, token.keychain_mask.as_ref(), &args)?;
|
||||
versioned_output(slate)
|
||||
}
|
||||
|
||||
@@ -2467,7 +2520,7 @@ where
|
||||
) -> Result<VersionedSlate, Error> {
|
||||
let slate = Owner::contract_sign(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
&Slate::from(in_slate),
|
||||
&args,
|
||||
)?;
|
||||
@@ -2475,7 +2528,7 @@ where
|
||||
}
|
||||
|
||||
fn contract_view(&self, token: Token, slate: VersionedSlate) -> Result<ContractView, Error> {
|
||||
Owner::contract_view(self, (&token.keychain_mask).as_ref(), &Slate::from(slate))
|
||||
Owner::contract_view(self, token.keychain_mask.as_ref(), &Slate::from(slate))
|
||||
}
|
||||
|
||||
fn contract_revoke(
|
||||
@@ -2483,7 +2536,7 @@ where
|
||||
token: Token,
|
||||
args: ContractRevokeArgsAPI,
|
||||
) -> Result<Option<VersionedSlate>, Error> {
|
||||
let slate_opt = Owner::contract_revoke(self, (&token.keychain_mask).as_ref(), &args)?;
|
||||
let slate_opt = Owner::contract_revoke(self, token.keychain_mask.as_ref(), &args)?;
|
||||
// We return a slate only when we had to perform a self-spend safe cancel
|
||||
if let Some(slate) = slate_opt {
|
||||
return Ok(Some(versioned_output(slate)?));
|
||||
@@ -2496,7 +2549,7 @@ where
|
||||
token: Token,
|
||||
args: IssueInvoiceTxArgs,
|
||||
) -> Result<VersionedSlate, Error> {
|
||||
let slate = Owner::issue_invoice_tx(self, (&token.keychain_mask).as_ref(), args)?;
|
||||
let slate = Owner::issue_invoice_tx(self, token.keychain_mask.as_ref(), args)?;
|
||||
versioned_output(slate)
|
||||
}
|
||||
|
||||
@@ -2508,7 +2561,7 @@ where
|
||||
) -> Result<VersionedSlate, Error> {
|
||||
let out_slate = Owner::process_invoice_tx(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
&Slate::from(in_slate),
|
||||
args,
|
||||
)?;
|
||||
@@ -2516,26 +2569,19 @@ where
|
||||
}
|
||||
|
||||
fn tx_lock_outputs(&self, token: Token, in_slate: VersionedSlate) -> Result<(), Error> {
|
||||
Owner::tx_lock_outputs(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
&Slate::from(in_slate),
|
||||
)
|
||||
Owner::tx_lock_outputs(self, token.keychain_mask.as_ref(), &Slate::from(in_slate))
|
||||
}
|
||||
|
||||
fn finalize_tx(&self, token: Token, in_slate: VersionedSlate) -> Result<VersionedSlate, Error> {
|
||||
let out_slate = Owner::finalize_tx(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
&Slate::from(in_slate),
|
||||
)?;
|
||||
let out_slate =
|
||||
Owner::finalize_tx(self, token.keychain_mask.as_ref(), &Slate::from(in_slate))?;
|
||||
versioned_output(out_slate)
|
||||
}
|
||||
|
||||
fn post_tx(&self, token: Token, slate: VersionedSlate, fluff: bool) -> Result<(), Error> {
|
||||
Owner::post_tx(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
&Slate::from(slate),
|
||||
fluff,
|
||||
)
|
||||
@@ -2547,7 +2593,7 @@ where
|
||||
tx_id: Option<u32>,
|
||||
tx_slate_id: Option<Uuid>,
|
||||
) -> Result<(), Error> {
|
||||
Owner::cancel_tx(self, (&token.keychain_mask).as_ref(), tx_id, tx_slate_id)
|
||||
Owner::cancel_tx(self, token.keychain_mask.as_ref(), tx_id, tx_slate_id)
|
||||
}
|
||||
|
||||
fn get_stored_tx(
|
||||
@@ -2556,12 +2602,8 @@ where
|
||||
id: Option<u32>,
|
||||
slate_id: Option<Uuid>,
|
||||
) -> Result<Option<VersionedSlate>, Error> {
|
||||
let out_slate = Owner::get_stored_tx(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
id,
|
||||
(&slate_id).as_ref(),
|
||||
)?;
|
||||
let out_slate =
|
||||
Owner::get_stored_tx(self, token.keychain_mask.as_ref(), id, slate_id.as_ref())?;
|
||||
match out_slate {
|
||||
Some(s) => {
|
||||
let version = SlateVersion::V4;
|
||||
@@ -2572,7 +2614,7 @@ where
|
||||
}
|
||||
|
||||
fn get_rewind_hash(&self, token: Token) -> Result<String, Error> {
|
||||
Owner::get_rewind_hash(self, (&token.keychain_mask).as_ref())
|
||||
Owner::get_rewind_hash(self, token.keychain_mask.as_ref())
|
||||
}
|
||||
|
||||
fn scan_rewind_hash(
|
||||
@@ -2591,14 +2633,14 @@ where
|
||||
) -> Result<(), Error> {
|
||||
Owner::scan(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
start_height,
|
||||
delete_unconfirmed,
|
||||
)
|
||||
}
|
||||
|
||||
fn node_height(&self, token: Token) -> Result<NodeHeightResult, Error> {
|
||||
Owner::node_height(self, (&token.keychain_mask).as_ref())
|
||||
Owner::node_height(self, token.keychain_mask.as_ref())
|
||||
}
|
||||
|
||||
fn init_secure_api(&self, ecdh_pubkey: ECDHPubkey) -> Result<ECDHPubkey, Error> {
|
||||
@@ -2650,16 +2692,13 @@ where
|
||||
mnemonic_length: u32,
|
||||
password: String,
|
||||
) -> Result<(), Error> {
|
||||
let n = name.as_ref().map(|s| s.as_str());
|
||||
let m = match mnemonic {
|
||||
Some(s) => Some(ZeroingString::from(s)),
|
||||
None => None,
|
||||
};
|
||||
let n = name.as_deref();
|
||||
let m = mnemonic.map(ZeroingString::from);
|
||||
Owner::create_wallet(self, n, m, mnemonic_length, ZeroingString::from(password))
|
||||
}
|
||||
|
||||
fn open_wallet(&self, name: Option<String>, password: String) -> Result<Token, Error> {
|
||||
let n = name.as_ref().map(|s| s.as_str());
|
||||
let n = name.as_deref();
|
||||
let sec_key = Owner::open_wallet(self, n, ZeroingString::from(password), true)?;
|
||||
Ok(Token {
|
||||
keychain_mask: sec_key,
|
||||
@@ -2667,30 +2706,30 @@ where
|
||||
}
|
||||
|
||||
fn close_wallet(&self, name: Option<String>) -> Result<(), Error> {
|
||||
let n = name.as_ref().map(|s| s.as_str());
|
||||
let n = name.as_deref();
|
||||
Owner::close_wallet(self, n)
|
||||
}
|
||||
|
||||
fn get_mnemonic(&self, name: Option<String>, password: String) -> Result<String, Error> {
|
||||
let n = name.as_ref().map(|s| s.as_str());
|
||||
let n = name.as_deref();
|
||||
let res = Owner::get_mnemonic(self, n, ZeroingString::from(password))?;
|
||||
Ok((&*res).to_string())
|
||||
Ok((*res).to_string())
|
||||
}
|
||||
|
||||
fn change_password(&self, name: Option<String>, old: String, new: String) -> Result<(), Error> {
|
||||
let n = name.as_ref().map(|s| s.as_str());
|
||||
let n = name.as_deref();
|
||||
Owner::change_password(self, n, ZeroingString::from(old), ZeroingString::from(new))
|
||||
}
|
||||
|
||||
fn delete_wallet(&self, name: Option<String>) -> Result<(), Error> {
|
||||
let n = name.as_ref().map(|s| s.as_str());
|
||||
let n = name.as_deref();
|
||||
Owner::delete_wallet(self, n)
|
||||
}
|
||||
|
||||
fn start_updater(&self, token: Token, frequency: u32) -> Result<(), Error> {
|
||||
Owner::start_updater(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
Duration::from_millis(frequency as u64),
|
||||
)
|
||||
}
|
||||
@@ -2706,21 +2745,18 @@ where
|
||||
fn get_slatepack_address(
|
||||
&self,
|
||||
token: Token,
|
||||
derivation_index: u32,
|
||||
derivation_index: SlatepackAddressIndex,
|
||||
) -> Result<SlatepackAddress, Error> {
|
||||
Owner::get_slatepack_address(self, (&token.keychain_mask).as_ref(), derivation_index)
|
||||
Owner::get_slatepack_address(self, token.keychain_mask.as_ref(), derivation_index)
|
||||
}
|
||||
|
||||
fn get_slatepack_secret_key(
|
||||
&self,
|
||||
token: Token,
|
||||
derivation_index: u32,
|
||||
derivation_index: SlatepackAddressIndex,
|
||||
) -> Result<Ed25519SecretKey, Error> {
|
||||
let key = Owner::get_slatepack_secret_key(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
derivation_index,
|
||||
)?;
|
||||
let key =
|
||||
Owner::get_slatepack_secret_key(self, token.keychain_mask.as_ref(), derivation_index)?;
|
||||
Ok(Ed25519SecretKey { key })
|
||||
}
|
||||
|
||||
@@ -2728,12 +2764,12 @@ where
|
||||
&self,
|
||||
token: Token,
|
||||
slate: VersionedSlate,
|
||||
sender_index: Option<u32>,
|
||||
sender_index: Option<SlatepackAddressIndex>,
|
||||
recipients: Vec<SlatepackAddress>,
|
||||
) -> Result<String, Error> {
|
||||
let res = Owner::create_slatepack_message(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
&Slate::from(slate),
|
||||
sender_index,
|
||||
recipients,
|
||||
@@ -2745,11 +2781,11 @@ where
|
||||
&self,
|
||||
token: Token,
|
||||
message: String,
|
||||
secret_indices: Vec<u32>,
|
||||
secret_indices: Vec<SlatepackAddressIndex>,
|
||||
) -> Result<VersionedSlate, Error> {
|
||||
let slate = Owner::slate_from_slatepack_message(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
message,
|
||||
secret_indices,
|
||||
)?;
|
||||
@@ -2761,14 +2797,9 @@ where
|
||||
&self,
|
||||
token: Token,
|
||||
message: String,
|
||||
secret_indices: Vec<u32>,
|
||||
secret_indices: Vec<SlatepackAddressIndex>,
|
||||
) -> Result<Slatepack, Error> {
|
||||
Owner::decode_slatepack_message(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
message,
|
||||
secret_indices,
|
||||
)
|
||||
Owner::decode_slatepack_message(self, token.keychain_mask.as_ref(), message, secret_indices)
|
||||
}
|
||||
|
||||
fn retrieve_payment_proof(
|
||||
@@ -2780,7 +2811,7 @@ where
|
||||
) -> Result<PaymentProof, Error> {
|
||||
Owner::retrieve_payment_proof(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
refresh_from_node,
|
||||
tx_id,
|
||||
tx_slate_id,
|
||||
@@ -2792,7 +2823,7 @@ where
|
||||
token: Token,
|
||||
proof: PaymentProof,
|
||||
) -> Result<(bool, bool), Error> {
|
||||
Owner::verify_payment_proof(self, (&token.keychain_mask).as_ref(), &proof)
|
||||
Owner::verify_payment_proof(self, token.keychain_mask.as_ref(), &proof)
|
||||
}
|
||||
|
||||
fn set_tor_config(&self, tor_config: Option<TorConfig>) -> Result<(), Error> {
|
||||
@@ -2806,41 +2837,34 @@ where
|
||||
features: OutputFeatures,
|
||||
amount: Amount,
|
||||
) -> Result<BuiltOutput, Error> {
|
||||
Owner::build_output(self, (&token.keychain_mask).as_ref(), features, amount.0)
|
||||
Owner::build_output(self, token.keychain_mask.as_ref(), features, amount.0)
|
||||
}
|
||||
|
||||
fn create_mwixnet_req(
|
||||
&self,
|
||||
token: Token,
|
||||
commitment: String,
|
||||
fee_per_hop: String,
|
||||
fee_per_hop: Option<String>,
|
||||
lock_output: bool,
|
||||
server_keys: Vec<String>,
|
||||
) -> Result<SwapReq, Error> {
|
||||
let commit =
|
||||
Commitment::from_vec(from_hex(&commitment).map_err(|e| Error::CommitDeser(e))?);
|
||||
|
||||
let secp_inst = static_secp_instance();
|
||||
let secp = secp_inst.lock();
|
||||
) -> Result<MwixnetReqCreationResult, Error> {
|
||||
let commit = Commitment::from_vec(from_hex(&commitment).map_err(Error::CommitDeser)?);
|
||||
|
||||
let mut keys = vec![];
|
||||
for key in server_keys {
|
||||
keys.push(SecretKey::from_slice(
|
||||
&secp,
|
||||
&grin_util::from_hex(&key).map_err(|e| Error::ServerKeyDeser(e))?,
|
||||
)?)
|
||||
keys.push(MwixnetServerPublicKey::from_hex(&key).map_err(Error::ServerKeyDeser)?)
|
||||
}
|
||||
|
||||
let req_params = MixnetReqCreationParams {
|
||||
server_keys: keys,
|
||||
fee_per_hop: fee_per_hop
|
||||
.parse::<u64>()
|
||||
.map_err(|_| Error::U64Deser(fee_per_hop))?,
|
||||
.map(|fee| fee.parse::<u64>().map_err(|_| Error::U64Deser(fee)))
|
||||
.transpose()?,
|
||||
};
|
||||
|
||||
Owner::create_mwixnet_req(
|
||||
self,
|
||||
(&token.keychain_mask).as_ref(),
|
||||
token.keychain_mask.as_ref(),
|
||||
&req_params,
|
||||
&commit,
|
||||
lock_output,
|
||||
@@ -2875,6 +2899,7 @@ pub fn run_doctest_owner(
|
||||
|
||||
/// Set up an owner doctest and run several requests against the same wallet
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn run_doctest_owner_with<F>(
|
||||
test_dir: &str,
|
||||
blocks_to_mine: u64,
|
||||
@@ -3002,19 +3027,14 @@ where
|
||||
let _ = test_framework::award_blocks_to_wallet(
|
||||
&chain,
|
||||
wallet1.clone(),
|
||||
(&mask1).as_ref(),
|
||||
1 as usize,
|
||||
mask1.as_ref(),
|
||||
1_usize,
|
||||
false,
|
||||
);
|
||||
//update local outputs after each block, so transaction IDs stay consistent
|
||||
let (wallet_refreshed, _) = api_impl::owner::retrieve_summary_info(
|
||||
wallet1.clone(),
|
||||
(&mask1).as_ref(),
|
||||
&None,
|
||||
true,
|
||||
1,
|
||||
)
|
||||
.unwrap();
|
||||
let (wallet_refreshed, _) =
|
||||
api_impl::owner::retrieve_summary_info(wallet1.clone(), mask1.as_ref(), &None, true, 1)
|
||||
.unwrap();
|
||||
assert!(wallet_refreshed);
|
||||
}
|
||||
|
||||
@@ -3041,25 +3061,24 @@ where
|
||||
payment_proof_recipient_address: proof_address,
|
||||
..Default::default()
|
||||
};
|
||||
let mut slate = api_impl::owner::init_send_tx(w, (&mask1).as_ref(), args, true).unwrap();
|
||||
let mut slate = api_impl::owner::init_send_tx(w, mask1.as_ref(), args, true).unwrap();
|
||||
println!("INITIAL SLATE");
|
||||
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
|
||||
{
|
||||
let mut w_lock = wallet2.lock();
|
||||
let w2 = w_lock.lc_provider().unwrap().wallet_inst().unwrap();
|
||||
slate =
|
||||
api_impl::foreign::receive_tx(w2, (&mask2).as_ref(), &slate, None, true).unwrap();
|
||||
slate = api_impl::foreign::receive_tx(w2, mask2.as_ref(), &slate, None, true).unwrap();
|
||||
w2.close().unwrap();
|
||||
}
|
||||
// Spit out slate for input to finalize_tx
|
||||
if lock_tx {
|
||||
println!("LOCKING TX");
|
||||
api_impl::owner::tx_lock_outputs(w, (&mask1).as_ref(), &slate).unwrap();
|
||||
api_impl::owner::tx_lock_outputs(w, mask1.as_ref(), &slate).unwrap();
|
||||
}
|
||||
println!("RECEIPIENT SLATE");
|
||||
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
|
||||
if finalize_tx {
|
||||
slate = api_impl::owner::finalize_tx(w, (&mask1).as_ref(), &slate).unwrap();
|
||||
slate = api_impl::owner::finalize_tx(w, mask1.as_ref(), &slate).unwrap();
|
||||
error!("FINALIZED TX SLATE");
|
||||
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
|
||||
}
|
||||
@@ -3075,8 +3094,8 @@ where
|
||||
let _ = test_framework::award_blocks_to_wallet(
|
||||
&chain,
|
||||
wallet1.clone(),
|
||||
(&mask1).as_ref(),
|
||||
3 as usize,
|
||||
mask1.as_ref(),
|
||||
3_usize,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
+13
-11
@@ -18,7 +18,6 @@ use crate::util::secp::key::{PublicKey, SecretKey};
|
||||
use crate::util::{from_hex, ToHex};
|
||||
use ed25519_dalek::SigningKey as DalekSecretKey;
|
||||
|
||||
use base64;
|
||||
use rand::{thread_rng, Rng};
|
||||
use ring::aead;
|
||||
use serde_json::{self, Value};
|
||||
@@ -90,8 +89,10 @@ impl EncryptedBody {
|
||||
aad,
|
||||
&mut to_encrypt,
|
||||
);
|
||||
if let Err(_) = res {
|
||||
return Err(Error::APIEncryption("EncryptedBody: encryption failed".to_owned()).into());
|
||||
if res.is_err() {
|
||||
return Err(Error::APIEncryption(
|
||||
"EncryptedBody: encryption failed".to_owned(),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(EncryptedBody {
|
||||
@@ -129,8 +130,7 @@ impl EncryptedBody {
|
||||
if nonce.len() < 12 {
|
||||
return Err(Error::APIEncryption(
|
||||
"EncryptedBody Dec: Invalid Nonce length".to_string(),
|
||||
)
|
||||
.into());
|
||||
));
|
||||
}
|
||||
let mut n = [0u8; 12];
|
||||
n.copy_from_slice(&nonce[0..12]);
|
||||
@@ -139,8 +139,10 @@ impl EncryptedBody {
|
||||
let aad = aead::Aad::from(&[]);
|
||||
let res =
|
||||
opening_key.open_in_place(aead::Nonce::assume_unique_for_key(n), aad, &mut to_decrypt);
|
||||
if let Err(_) = res {
|
||||
return Err(Error::APIEncryption("EncryptedBody: decryption failed".to_owned()).into());
|
||||
if res.is_err() {
|
||||
return Err(Error::APIEncryption(
|
||||
"EncryptedBody: decryption failed".to_owned(),
|
||||
));
|
||||
}
|
||||
for _ in 0..aead::AES_256_GCM.tag_len() {
|
||||
to_decrypt.pop();
|
||||
@@ -148,8 +150,8 @@ impl EncryptedBody {
|
||||
|
||||
let decrypted = String::from_utf8(to_decrypt)
|
||||
.map_err(|_| Error::APIEncryption("EncryptedBody Dec: Invalid UTF-8".to_string()))?;
|
||||
Ok(serde_json::from_str(&decrypted)
|
||||
.map_err(|_| Error::APIEncryption("EncryptedBody Dec: Invalid JSON".to_string()))?)
|
||||
serde_json::from_str(&decrypted)
|
||||
.map_err(|_| Error::APIEncryption("EncryptedBody Dec: Invalid JSON".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,9 +277,9 @@ impl EncryptionErrorResponse {
|
||||
pub fn new(id: u64, code: i32, message: &str) -> Self {
|
||||
EncryptionErrorResponse {
|
||||
jsonrpc: "2.0".to_owned(),
|
||||
id: id,
|
||||
id,
|
||||
error: EncryptionError {
|
||||
code: code,
|
||||
code,
|
||||
message: message.to_owned(),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
//use grin_wallet_api::foreign_rpc_client;
|
||||
use grin_wallet_api::run_doctest_foreign;
|
||||
//use grin_wallet_libwallet::VersionedSlate;
|
||||
use serde_json;
|
||||
use serde_json::Value;
|
||||
use tempfile::tempdir;
|
||||
//use grin_wallet_libwallet::slate_versions::v1::SlateV1;
|
||||
|
||||
Reference in New Issue
Block a user