Wallet Interactive-mode, Part 1 (#295)

* cli addition to yml

* first experiments with CLI mode

* rustfmt

* modify owner_single_use to take optional instantiated API

* refactor command functions to take owner api instance

* modify commands to use single owner api instance

* add ability to pass customised message handler to API

* prevent update wallet attempt if wallet hasn't been opened

* fix output when internal updater is running

* add termion, use cli for status updates, remove logging output from CLI

* some attempts to clean up the command prompt and accomodate scanning intervals

* rework listener slightly to allow for cli mode, add close command

* remove termion dependency
This commit is contained in:
Yeastplume
2020-02-06 09:08:24 +00:00
committed by GitHub
parent 0ae921461c
commit 2d264db91a
28 changed files with 929 additions and 314 deletions
+104 -59
View File
@@ -15,6 +15,7 @@
//! Grin wallet command-line function implementations
use crate::api::TLSConfig;
use crate::apiwallet::Owner;
use crate::config::{TorConfig, WalletConfig, WALLET_CONFIG_FILE_NAME};
use crate::core::{core, global};
use crate::error::{Error, ErrorKind};
@@ -22,7 +23,7 @@ use crate::impls::{create_sender, KeybaseAllChannels, SlateGetter as _, SlateRec
use crate::impls::{PathToSlate, SlatePutter};
use crate::keychain;
use crate::libwallet::{
self, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, WalletInst, WalletLCProvider,
self, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, WalletLCProvider,
};
use crate::util::secp::key::SecretKey;
use crate::util::{Mutex, ZeroingString};
@@ -31,6 +32,7 @@ use grin_wallet_util::OnionV3Address;
use serde_json as json;
use std::fs::File;
use std::io::{Read, Write};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::thread;
use std::time::Duration;
@@ -67,7 +69,7 @@ pub struct InitArgs {
}
pub fn init<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
g_args: &GlobalArgs,
args: InitArgs,
) -> Result<(), Error>
@@ -76,7 +78,7 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
let mut w_lock = wallet.lock();
let mut w_lock = owner_api.wallet_inst.lock();
let p = w_lock.lc_provider()?;
p.create_config(
&g_args.chain_type,
@@ -103,16 +105,13 @@ pub struct RecoverArgs {
pub passphrase: ZeroingString,
}
pub fn recover<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
args: RecoverArgs,
) -> Result<(), Error>
pub fn recover<L, C, K>(owner_api: &mut Owner<L, C, K>, args: RecoverArgs) -> Result<(), Error>
where
L: WalletLCProvider<'static, C, K> + 'static,
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
let mut w_lock = wallet.lock();
let mut w_lock = owner_api.wallet_inst.lock();
let p = w_lock.lc_provider()?;
let m = p.get_mnemonic(None, args.passphrase)?;
show_recovery_phrase(m);
@@ -125,12 +124,13 @@ pub struct ListenArgs {
}
pub fn listen<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Arc<Mutex<Option<SecretKey>>>,
config: &WalletConfig,
tor_config: &TorConfig,
args: &ListenArgs,
g_args: &GlobalArgs,
cli_mode: bool,
) -> Result<(), Error>
where
L: WalletLCProvider<'static, C, K> + 'static,
@@ -138,13 +138,36 @@ where
K: keychain::Keychain + 'static,
{
let res = match args.method.as_str() {
"http" => controller::foreign_listener(
wallet.clone(),
keychain_mask,
&config.api_listen_addr(),
g_args.tls_conf.clone(),
tor_config.use_tor_listener,
),
"http" => {
let wallet_inst = owner_api.wallet_inst.clone();
let config = config.clone();
let tor_config = tor_config.clone();
let g_args = g_args.clone();
let api_thread = thread::Builder::new()
.name("wallet-http-listener".to_string())
.spawn(move || {
let res = controller::foreign_listener(
wallet_inst,
keychain_mask,
&config.api_listen_addr(),
g_args.tls_conf.clone(),
tor_config.use_tor_listener,
);
if let Err(e) = res {
error!("Error starting listener: {}", e);
}
});
if let Ok(t) = api_thread {
if !cli_mode {
let r = t.join();
if let Err(_) = r {
error!("Error starting listener");
return Err(ErrorKind::ListenerError.into());
}
}
}
Ok(())
}
"keybase" => KeybaseAllChannels::new()?.listen(
config.clone(),
g_args.password.clone().unwrap(),
@@ -167,7 +190,7 @@ where
}
pub fn owner_api<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<SecretKey>,
config: &WalletConfig,
tor_config: &TorConfig,
@@ -182,7 +205,7 @@ where
// also being run at the same time
let km = Arc::new(Mutex::new(keychain_mask));
let res = controller::owner_listener(
wallet,
owner_api.wallet_inst.clone(),
km,
config.owner_api_listen_addr().as_str(),
g_args.api_secret.clone(),
@@ -202,7 +225,7 @@ pub struct AccountArgs {
}
pub fn account<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: AccountArgs,
) -> Result<(), Error>
@@ -212,7 +235,7 @@ where
K: keychain::Keychain + 'static,
{
if args.create.is_none() {
let res = controller::owner_single_use(wallet, keychain_mask, |api, m| {
let res = controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let acct_mappings = api.accounts(m)?;
// give logging thread a moment to catch up
thread::sleep(Duration::from_millis(200));
@@ -225,7 +248,7 @@ where
}
} else {
let label = args.create.unwrap();
let res = controller::owner_single_use(wallet, keychain_mask, |api, m| {
let res = controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
api.create_account_path(m, &label)?;
thread::sleep(Duration::from_millis(200));
info!("Account: '{}' Created!", label);
@@ -258,7 +281,7 @@ pub struct SendArgs {
}
pub fn send<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
tor_config: Option<TorConfig>,
args: SendArgs,
@@ -269,7 +292,8 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
let wallet_inst = owner_api.wallet_inst.clone();
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
if args.estimate_selection_strategies {
let strategies = vec!["smallest", "all"]
.into_iter()
@@ -333,7 +357,7 @@ where
None => None,
Some(&m) => Some(m.to_owned()),
};
controller::foreign_single_use(wallet, km, |api| {
controller::foreign_single_use(wallet_inst, km, |api| {
slate = api.receive_tx(&slate, Some(&args.dest), None)?;
Ok(())
})?;
@@ -374,7 +398,7 @@ pub struct ReceiveArgs {
}
pub fn receive<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
g_args: &GlobalArgs,
args: ReceiveArgs,
@@ -389,7 +413,7 @@ where
None => None,
Some(&m) => Some(m.to_owned()),
};
controller::foreign_single_use(wallet, km, |api| {
controller::foreign_single_use(owner_api.wallet_inst.clone(), km, |api| {
if let Err(e) = api.verify_slate_messages(&slate) {
error!("Error validating participant messages: {}", e);
return Err(e);
@@ -414,7 +438,7 @@ pub struct FinalizeArgs {
}
pub fn finalize<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: FinalizeArgs,
) -> Result<(), Error>
@@ -448,7 +472,7 @@ where
None => None,
Some(&m) => Some(m.to_owned()),
};
controller::foreign_single_use(wallet.clone(), km, |api| {
controller::foreign_single_use(owner_api.wallet_inst.clone(), km, |api| {
if let Err(e) = api.verify_slate_messages(&slate) {
error!("Error validating participant messages: {}", e);
return Err(e);
@@ -457,7 +481,7 @@ where
Ok(())
})?;
} else {
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
if let Err(e) = api.verify_slate_messages(m, &slate) {
error!("Error validating participant messages: {}", e);
return Err(e);
@@ -468,7 +492,7 @@ where
}
if !args.nopost {
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let result = api.post_tx(m, &slate.tx, args.fluff);
match result {
Ok(_) => {
@@ -501,7 +525,7 @@ pub struct IssueInvoiceArgs {
}
pub fn issue_invoice_tx<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: IssueInvoiceArgs,
) -> Result<(), Error>
@@ -510,7 +534,7 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let slate = api.issue_invoice_tx(m, args.issue_args)?;
PathToSlate((&args.dest).into()).put_tx(&slate)?;
Ok(())
@@ -533,7 +557,7 @@ pub struct ProcessInvoiceArgs {
/// Process invoice
pub fn process_invoice<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
tor_config: Option<TorConfig>,
args: ProcessInvoiceArgs,
@@ -545,7 +569,8 @@ where
K: keychain::Keychain + 'static,
{
let slate = PathToSlate((&args.input).into()).get_tx()?;
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
let wallet_inst = owner_api.wallet_inst.clone();
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
if args.estimate_selection_strategies {
let strategies = vec!["smallest", "all"]
.into_iter()
@@ -611,7 +636,7 @@ where
None => None,
Some(&m) => Some(m.to_owned()),
};
controller::foreign_single_use(wallet, km, |api| {
controller::foreign_single_use(wallet_inst, km, |api| {
slate = api.finalize_invoice_tx(&slate)?;
Ok(())
})?;
@@ -633,7 +658,7 @@ pub struct InfoArgs {
}
pub fn info<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
g_args: &GlobalArgs,
args: InfoArgs,
@@ -644,17 +669,23 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
let updater_running = owner_api.updater_running.load(Ordering::Relaxed);
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let (validated, wallet_info) =
api.retrieve_summary_info(m, true, args.minimum_confirmations)?;
display::info(&g_args.account, &wallet_info, validated, dark_scheme);
display::info(
&g_args.account,
&wallet_info,
validated || updater_running,
dark_scheme,
);
Ok(())
})?;
Ok(())
}
pub fn outputs<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
g_args: &GlobalArgs,
dark_scheme: bool,
@@ -664,10 +695,17 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
let updater_running = owner_api.updater_running.load(Ordering::Relaxed);
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let res = api.node_height(m)?;
let (validated, outputs) = api.retrieve_outputs(m, g_args.show_spent, true, None)?;
display::outputs(&g_args.account, res.height, validated, outputs, dark_scheme)?;
display::outputs(
&g_args.account,
res.height,
validated || updater_running,
outputs,
dark_scheme,
)?;
Ok(())
})?;
Ok(())
@@ -680,7 +718,7 @@ pub struct TxsArgs {
}
pub fn txs<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
g_args: &GlobalArgs,
args: TxsArgs,
@@ -691,14 +729,15 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
let updater_running = owner_api.updater_running.load(Ordering::Relaxed);
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let res = api.node_height(m)?;
let (validated, txs) = api.retrieve_txs(m, true, args.id, args.tx_slate_id)?;
let include_status = !args.id.is_some() && !args.tx_slate_id.is_some();
display::txs(
&g_args.account,
res.height,
validated,
validated || updater_running,
&txs,
include_status,
dark_scheme,
@@ -721,7 +760,13 @@ where
if id.is_some() {
let (_, outputs) = api.retrieve_outputs(m, true, false, id)?;
display::outputs(&g_args.account, res.height, validated, outputs, dark_scheme)?;
display::outputs(
&g_args.account,
res.height,
validated || updater_running,
outputs,
dark_scheme,
)?;
// should only be one here, but just in case
for tx in txs {
display::tx_messages(&tx, dark_scheme)?;
@@ -741,7 +786,7 @@ pub struct PostArgs {
}
pub fn post<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: PostArgs,
) -> Result<(), Error>
@@ -752,7 +797,7 @@ where
{
let slate = PathToSlate((&args.input).into()).get_tx()?;
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
api.post_tx(m, &slate.tx, args.fluff)?;
info!("Posted transaction");
return Ok(());
@@ -768,7 +813,7 @@ pub struct RepostArgs {
}
pub fn repost<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: RepostArgs,
) -> Result<(), Error>
@@ -777,7 +822,7 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let (_, txs) = api.retrieve_txs(m, true, Some(args.id), None)?;
let stored_tx = api.get_stored_tx(m, &txs[0])?;
if stored_tx.is_none() {
@@ -820,7 +865,7 @@ pub struct CancelArgs {
}
pub fn cancel<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: CancelArgs,
) -> Result<(), Error>
@@ -829,7 +874,7 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let result = api.cancel_tx(m, args.tx_id, args.tx_slate_id);
match result {
Ok(_) => {
@@ -852,7 +897,7 @@ pub struct CheckArgs {
}
pub fn scan<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: CheckArgs,
) -> Result<(), Error>
@@ -861,7 +906,7 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
warn!("Starting output scan ...",);
let result = api.scan(m, args.start_height, args.delete_unconfirmed);
match result {
@@ -881,7 +926,7 @@ where
/// Payment Proof Address
pub fn address<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
g_args: &GlobalArgs,
keychain_mask: Option<&SecretKey>,
) -> Result<(), Error>
@@ -890,7 +935,7 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
// Just address at derivation index 0 for now
let pub_key = api.get_public_proof_address(m, 0)?;
let addr = OnionV3Address::from_bytes(pub_key.to_bytes());
@@ -912,7 +957,7 @@ pub struct ProofExportArgs {
}
pub fn proof_export<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: ProofExportArgs,
) -> Result<(), Error>
@@ -921,7 +966,7 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let result = api.retrieve_payment_proof(m, true, args.id, args.tx_slate_id);
match result {
Ok(p) => {
@@ -947,7 +992,7 @@ pub struct ProofVerifyArgs {
}
pub fn proof_verify<L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
owner_api: &mut Owner<L, C, K>,
keychain_mask: Option<&SecretKey>,
args: ProofVerifyArgs,
) -> Result<(), Error>
@@ -956,7 +1001,7 @@ where
C: NodeClient + 'static,
K: keychain::Keychain + 'static,
{
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
let mut proof_f = match File::open(&args.input_file) {
Ok(p) => p,
Err(e) => {
+25 -4
View File
@@ -121,8 +121,9 @@ where
/// Instantiate wallet Owner API for a single-use (command line) call
/// Return a function containing a loaded API context to call
pub fn owner_single_use<L, F, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
wallet: Option<Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>>,
keychain_mask: Option<&SecretKey>,
api_context: Option<&mut Owner<L, C, K>>,
f: F,
) -> Result<(), Error>
where
@@ -131,7 +132,21 @@ where
C: NodeClient + 'static,
K: Keychain + 'static,
{
f(&mut Owner::new(wallet), keychain_mask)?;
match api_context {
Some(c) => f(c, keychain_mask)?,
None => {
let wallet = match wallet {
Some(w) => w,
None => {
return Err(ErrorKind::GenericError(format!(
"Instantiated wallet or Owner API context must be provided"
))
.into())
}
};
f(&mut Owner::new(wallet, None), keychain_mask)?
}
}
Ok(())
}
@@ -243,6 +258,12 @@ where
C: NodeClient + 'static,
K: Keychain + 'static,
{
// Check if wallet has been opened first
{
let mut w_lock = wallet.lock();
let lc = w_lock.lc_provider()?;
let _ = lc.wallet_inst()?;
}
// need to keep in scope while the main listener is running
let _tor_process = match use_tor {
true => match init_tor_listener(wallet.clone(), keychain_mask.clone(), addr) {
@@ -325,7 +346,7 @@ where
}
fn handle_post_request(&self, req: Request<Body>) -> WalletResponseFuture {
let api = Owner::new(self.wallet.clone());
let api = Owner::new(self.wallet.clone(), None);
Box::new(
self.call_api(req, api)
.and_then(|resp| ok(json_response_pretty(&resp))),
@@ -600,7 +621,7 @@ where
tor_config: Option<TorConfig>,
running_foreign: bool,
) -> OwnerAPIHandlerV3<L, C, K> {
let owner_api = Owner::new(wallet.clone());
let owner_api = Owner::new(wallet.clone(), None);
owner_api.set_tor_config(tor_config);
let owner_api = Arc::new(owner_api);
OwnerAPIHandlerV3 {
+4
View File
@@ -104,6 +104,10 @@ pub enum ErrorKind {
#[fail(display = "{}", _0)]
ArgumentError(String),
/// Other
#[fail(display = "Listener Startup Error")]
ListenerError,
/// Other
#[fail(display = "Generic error: {}", _0)]
GenericError(String),
+11 -11
View File
@@ -76,7 +76,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let cm = global::coinbase_maturity(); // assume all testing precedes soft fork height
// test default accounts exist
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let accounts = api.accounts(m)?;
assert_eq!(accounts[0].label, "default");
assert_eq!(accounts[0].path, ExtKeychain::derive_key_id(2, 0, 0, 0, 0));
@@ -84,7 +84,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// add some accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let new_path = api.create_account_path(m, "account1").unwrap();
assert_eq!(new_path, ExtKeychain::derive_key_id(2, 1, 0, 0, 0));
let new_path = api.create_account_path(m, "account2").unwrap();
@@ -98,7 +98,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// add account to wallet 2
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let new_path = api.create_account_path(m, "listener_account").unwrap();
assert_eq!(new_path, ExtKeychain::derive_key_id(2, 1, 0, 0, 0));
Ok(())
@@ -126,7 +126,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 5, false);
// Should have 5 in account1 (5 spendable), 5 in account (2 spendable)
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, 12);
@@ -147,7 +147,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
w.set_parent_key_id_by_name("account1")?;
}
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
// check last confirmed height on this account is different from above (should be 0)
let (_, wallet1_info) = api.retrieve_summary_info(m, false, 1)?;
assert_eq!(wallet1_info.last_confirmed_height, 0);
@@ -167,7 +167,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("default")?;
}
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, wallet1_info) = api.retrieve_summary_info(m, false, 1)?;
assert_eq!(wallet1_info.last_confirmed_height, 0);
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
@@ -186,7 +186,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("account1")?;
}
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let args = InitTxArgs {
src_acct_name: None,
amount: reward,
@@ -204,7 +204,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
Ok(())
})?;
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, 13);
@@ -218,7 +218,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("account2")?;
}
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, wallet1_info) = api.retrieve_summary_info(m, false, 1)?;
assert_eq!(wallet1_info.last_confirmed_height, 12);
let (_, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
@@ -230,7 +230,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// wallet 2 should only have this tx on the listener account
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (wallet2_refreshed, wallet2_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet2_refreshed);
assert_eq!(wallet2_info.last_confirmed_height, 13);
@@ -243,7 +243,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
wallet_inst!(wallet2, w);
w.set_parent_key_id_by_name("default")?;
}
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (_, wallet2_info) = api.retrieve_summary_info(m, false, 1)?;
assert_eq!(wallet2_info.last_confirmed_height, 0);
let (wallet2_refreshed, wallet2_info) = api.retrieve_summary_info(m, true, 1)?;
+28 -28
View File
@@ -89,7 +89,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let cm = global::coinbase_maturity() as u64; // assume all testing precedes soft fork height
// add some accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.create_account_path(m, "named_account_1")?;
api.create_account_path(m, "account_2")?;
api.create_account_path(m, "account_3")?;
@@ -98,7 +98,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// add account to wallet 2
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
api.create_account_path(m, "account_1")?;
api.set_active_account(m, "account_1")?;
Ok(())
@@ -110,7 +110,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, bh as usize, false);
// Sanity check contents
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -126,7 +126,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// Accidentally delete some outputs
let mut w1_outputs_commits = vec![];
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
w1_outputs_commits = api.retrieve_outputs(m, false, true, None)?.1;
Ok(())
})?;
@@ -146,7 +146,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
}
// check we have a problem now
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
let (_, txs) = api.retrieve_txs(m, true, None, None)?;
let (c, _) = libwallet::TxLogEntry::sum_confirmed(&txs);
@@ -155,13 +155,13 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// this should restore our missing outputs
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.scan(m, None, true)?;
Ok(())
})?;
// check our outputs match again
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.total, bh * reward);
@@ -174,7 +174,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// perform a transaction, but don't let it finish
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
// send to send
let args = InitTxArgs {
src_acct_name: None,
@@ -194,7 +194,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// check we're all locked
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert!(wallet1_info.amount_currently_spendable == 0);
@@ -202,13 +202,13 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// unlock/restore
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.scan(m, None, true)?;
Ok(())
})?;
// check spendable amount again
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert_eq!(wallet1_info.amount_currently_spendable, (bh - cm) * reward);
Ok(())
@@ -408,7 +408,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
bh += 3;
// 0) Check repair when all is okay should leave wallet contents alone
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.scan(m, None, true)?;
let info = wallet_info!(wallet1.clone(), m)?;
assert_eq!(info.amount_currently_spendable, base_amount * 6);
@@ -458,12 +458,12 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
// seed + BIP32 path.
// 1) a full restore should recover all of them:
wallet::controller::owner_single_use(wallet3.clone(), mask3, |api, m| {
wallet::controller::owner_single_use(Some(wallet3.clone()), mask3, None, |api, m| {
api.scan(m, None, false)?;
Ok(())
})?;
wallet::controller::owner_single_use(wallet3.clone(), mask3, |api, m| {
wallet::controller::owner_single_use(Some(wallet3.clone()), mask3, None, |api, m| {
let info = wallet_info!(wallet3.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
assert_eq!(outputs.len(), 6);
@@ -473,12 +473,12 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
})?;
// 2) scan should recover them into a single wallet
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.scan(m, None, true)?;
Ok(())
})?;
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let info = wallet_info!(wallet1.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
assert_eq!(outputs.len(), 6);
@@ -516,7 +516,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), miner_mask, cm, false);
bh += cm as u64;
wallet::controller::owner_single_use(wallet4.clone(), mask4, |api, m| {
wallet::controller::owner_single_use(Some(wallet4.clone()), mask4, None, |api, m| {
let info = wallet_info!(wallet4.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
assert_eq!(outputs.len(), 9);
@@ -524,12 +524,12 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
Ok(())
})?;
wallet::controller::owner_single_use(wallet5.clone(), mask5, |api, m| {
wallet::controller::owner_single_use(Some(wallet5.clone()), mask5, None, |api, m| {
api.scan(m, None, false)?;
Ok(())
})?;
wallet::controller::owner_single_use(wallet5.clone(), mask5, |api, m| {
wallet::controller::owner_single_use(Some(wallet5.clone()), mask5, None, |api, m| {
let info = wallet_info!(wallet5.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
assert_eq!(outputs.len(), 9);
@@ -571,7 +571,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
);
bh += cm as u64;
wallet::controller::owner_single_use(wallet6.clone(), mask6, |api, m| {
wallet::controller::owner_single_use(Some(wallet6.clone()), mask6, None, |api, m| {
let info = wallet_info!(wallet6.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
assert_eq!(outputs.len(), 12);
@@ -579,12 +579,12 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
Ok(())
})?;
wallet::controller::owner_single_use(wallet6.clone(), mask6, |api, m| {
wallet::controller::owner_single_use(Some(wallet6.clone()), mask6, None, |api, m| {
api.scan(m, None, true)?;
Ok(())
})?;
wallet::controller::owner_single_use(wallet6.clone(), mask6, |api, m| {
wallet::controller::owner_single_use(Some(wallet6.clone()), mask6, None, |api, m| {
let info = wallet_info!(wallet6.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
assert_eq!(outputs.len(), 12);
@@ -619,7 +619,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
bh += 3;
// mix it up a bit
wallet::controller::owner_single_use(wallet7.clone(), mask7, |api, m| {
wallet::controller::owner_single_use(Some(wallet7.clone()), mask7, None, |api, m| {
api.create_account_path(m, "account_1")?;
api.set_active_account(m, "account_1")?;
Ok(())
@@ -652,7 +652,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), miner_mask, cm, false);
bh += cm as u64;
wallet::controller::owner_single_use(wallet7.clone(), mask7, |api, m| {
wallet::controller::owner_single_use(Some(wallet7.clone()), mask7, None, |api, m| {
let info = wallet_info!(wallet7.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
assert_eq!(outputs.len(), 3);
@@ -665,7 +665,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
Ok(())
})?;
wallet::controller::owner_single_use(wallet8.clone(), mask8, |api, m| {
wallet::controller::owner_single_use(Some(wallet8.clone()), mask8, None, |api, m| {
api.scan(m, None, false)?;
let info = wallet_info!(wallet8.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
@@ -683,7 +683,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
// ids on account 2 as well, scan should get all outputs created
// to now into 2 accounts
wallet::controller::owner_single_use(wallet9.clone(), mask9, |api, m| {
wallet::controller::owner_single_use(Some(wallet9.clone()), mask9, None, |api, m| {
api.create_account_path(m, "account_1")?;
api.set_active_account(m, "account_1")?;
Ok(())
@@ -713,7 +713,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
bh += 3;
let _bh = bh;
wallet::controller::owner_single_use(wallet9.clone(), mask9, |api, m| {
wallet::controller::owner_single_use(Some(wallet9.clone()), mask9, None, |api, m| {
let info = wallet_info!(wallet9.clone(), m)?;
let outputs = api.retrieve_outputs(m, true, false, None)?.1;
assert_eq!(outputs.len(), 6);
@@ -735,7 +735,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), miner_mask, cm, false);
// 7) Ensure scan creates missing accounts
wallet::controller::owner_single_use(wallet10.clone(), mask10, |api, m| {
wallet::controller::owner_single_use(Some(wallet10.clone()), mask10, None, |api, m| {
api.scan(m, None, true)?;
api.set_active_account(m, "account_1")?;
let info = wallet_info!(wallet10.clone(), m)?;
+9 -9
View File
@@ -75,14 +75,14 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
let reward = core::consensus::REWARD;
// add some accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.create_account_path(m, "mining")?;
api.create_account_path(m, "listener")?;
Ok(())
})?;
// add some accounts
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
api.create_account_path(m, "account1")?;
api.create_account_path(m, "account2")?;
Ok(())
@@ -104,7 +104,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
let message = "sender test message, sender test message";
// Should have 5 in account1 (5 spendable), 5 in account (2 spendable)
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -138,7 +138,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
naughty_slate.participant_data[0].message = Some("I changed the message".to_owned());
// verify messages on slate match
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.verify_slate_messages(m, &slate)?;
assert!(api.verify_slate_messages(m, &naughty_slate).is_err());
Ok(())
@@ -154,7 +154,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
})?;
// wallet 1 finalises and posts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let mut slate = PathToSlate(receive_file.into()).get_tx()?;
api.verify_slate_messages(m, &slate)?;
slate = api.finalize_tx(m, &slate)?;
@@ -167,7 +167,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
bh += 3;
// Check total in mining account
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -176,7 +176,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
})?;
// Check total in 'wallet 2' account
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (wallet2_refreshed, wallet2_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet2_refreshed);
assert_eq!(wallet2_info.last_confirmed_height, bh);
@@ -185,7 +185,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
})?;
// Check messages, all participants should have both
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, tx) = api.retrieve_txs(m, true, None, Some(slate.id))?;
assert_eq!(
tx[0].clone().messages.unwrap().messages[0].message,
@@ -201,7 +201,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
Ok(())
})?;
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (_, tx) = api.retrieve_txs(m, true, None, Some(slate.id))?;
assert_eq!(
tx[0].clone().messages.unwrap().messages[0].message,
+8 -8
View File
@@ -69,7 +69,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let reward = core::consensus::REWARD;
// add some accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.create_account_path(m, "mining")?;
api.create_account_path(m, "listener")?;
Ok(())
@@ -85,7 +85,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, bh as usize, false);
// Sanity check wallet 1 contents
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -95,7 +95,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let mut slate = Slate::blank(2);
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
// Wallet 2 inititates an invoice transaction, requesting payment
let args = IssueInvoiceTxArgs {
amount: reward * 2,
@@ -105,7 +105,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
Ok(())
})?;
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
// Wallet 1 receives the invoice transaction
let args = InitTxArgs {
src_acct_name: None,
@@ -129,7 +129,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// wallet 1 posts so wallet 2 doesn't get the mined amount
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.post_tx(m, &slate.tx, false)?;
Ok(())
})?;
@@ -139,7 +139,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
bh += 3;
// Check transaction log for wallet 2
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (_, wallet2_info) = api.retrieve_summary_info(m, true, 1)?;
let (refreshed, txs) = api.retrieve_txs(m, true, None, None)?;
assert!(refreshed);
@@ -155,7 +155,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// Check transaction log for wallet 1, ensure only 1 entry
// exists
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
let (refreshed, txs) = api.retrieve_txs(m, true, None, None)?;
assert!(refreshed);
@@ -168,7 +168,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// Test self-sending
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
// Wallet 1 inititates an invoice transaction, requesting payment
let args = IssueInvoiceTxArgs {
amount: reward * 2,
+6 -6
View File
@@ -75,7 +75,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// send a single block's worth of transactions with minimal strategy
let mut slate = Slate::blank(2);
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let args = InitTxArgs {
src_acct_name: None,
amount: reward - fee,
@@ -94,7 +94,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// Refresh and check transaction log for wallet 1
wallet::controller::owner_single_use(wallet1.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask2, None, |api, m| {
let (refreshed, txs) = api.retrieve_txs(m, true, None, Some(slate.id))?;
assert!(refreshed);
let tx = txs[0].clone();
@@ -104,7 +104,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// ensure invoice TX works as well with no change
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
// Wallet 2 inititates an invoice transaction, requesting payment
let args = IssueInvoiceTxArgs {
amount: reward - fee,
@@ -114,7 +114,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
Ok(())
})?;
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
// Wallet 1 receives the invoice transaction
let args = InitTxArgs {
src_acct_name: None,
@@ -136,13 +136,13 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
slate = api.finalize_invoice_tx(&slate)?;
Ok(())
})?;
wallet::controller::owner_single_use(wallet2.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask1, None, |api, m| {
api.post_tx(m, &slate.tx, false)?;
Ok(())
})?;
// Refresh and check transaction log for wallet 1
wallet::controller::owner_single_use(wallet1.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask2, None, |api, m| {
let (refreshed, txs) = api.retrieve_txs(m, true, None, Some(slate.id))?;
assert!(refreshed);
for tx in txs {
+3 -3
View File
@@ -77,7 +77,7 @@ fn payment_proofs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, bh as usize, false);
let mut address = None;
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
address = Some(api.get_public_proof_address(m, 0)?);
Ok(())
})?;
@@ -86,7 +86,7 @@ fn payment_proofs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
println!("Public address is: {:?}", address);
let amount = 60_000_000_000;
let mut slate = Slate::blank(1);
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
// note this will increment the block count as part of the transaction "Posting"
let args = InitTxArgs {
src_acct_name: None,
@@ -139,7 +139,7 @@ fn payment_proofs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 2, false);
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
// Check payment proof here
let mut pp = sender_api.retrieve_payment_proof(m, true, None, Some(slate.id))?;
+11 -11
View File
@@ -72,14 +72,14 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
let reward = core::consensus::REWARD;
// add some accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.create_account_path(m, "mining")?;
api.create_account_path(m, "listener")?;
Ok(())
})?;
// add some accounts
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
api.create_account_path(m, "account1")?;
api.create_account_path(m, "account2")?;
Ok(())
@@ -100,7 +100,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
let mut slate = Slate::blank(2);
// Should have 5 in account1 (5 spendable), 5 in account (2 spendable)
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -144,14 +144,14 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
}
// wallet 1 finalize
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
slate = PathToSlate((&receive_file).into()).get_tx()?;
slate = api.finalize_tx(m, &slate)?;
Ok(())
})?;
// Now repost from cached
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, txs) = api.retrieve_txs(m, true, None, Some(slate.id))?;
let stored_tx = api.get_stored_tx(m, &txs[0])?;
api.post_tx(m, &stored_tx.unwrap(), false)?;
@@ -163,7 +163,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
bh += 3;
// update/test contents of both accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -176,7 +176,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
w.set_parent_key_id_by_name("listener")?;
}
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet2_refreshed, wallet2_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet2_refreshed);
assert_eq!(wallet2_info.last_confirmed_height, bh);
@@ -197,7 +197,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
let mut slate = Slate::blank(2);
let amount = 60_000_000_000;
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
// note this will increment the block count as part of the transaction "Posting"
let args = InitTxArgs {
src_acct_name: None,
@@ -219,7 +219,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
bh += 3;
// Now repost from cached
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, txs) = api.retrieve_txs(m, true, None, Some(slate.id))?;
let stored_tx = api.get_stored_tx(m, &txs[0])?;
api.post_tx(m, &stored_tx.unwrap(), false)?;
@@ -231,7 +231,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
bh += 3;
//
// update/test contents of both accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -239,7 +239,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
Ok(())
})?;
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (wallet2_refreshed, wallet2_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet2_refreshed);
assert_eq!(wallet2_info.last_confirmed_height, bh);
+4 -4
View File
@@ -60,7 +60,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let reward = core::consensus::REWARD;
// add some accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.create_account_path(m, "mining")?;
api.create_account_path(m, "listener")?;
Ok(())
@@ -76,7 +76,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, bh as usize, false);
// Should have 5 in account1 (5 spendable), 5 in account (2 spendable)
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -108,7 +108,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
bh += 3;
// Check total in mining account
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -121,7 +121,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("listener")?;
}
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet1_refreshed);
assert_eq!(wallet1_info.last_confirmed_height, bh);
+17 -17
View File
@@ -77,7 +77,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 10, false);
// Check wallet 1 contents are as expected
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
debug!(
"Wallet 1 Info Pre-Transaction, after {} blocks: {:?}",
@@ -96,7 +96,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
// and a single use api for a send command
let amount = 60_000_000_000;
let mut slate = Slate::blank(1);
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
// note this will increment the block count as part of the transaction "Posting"
let args = InitTxArgs {
src_acct_name: None,
@@ -128,7 +128,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
})?;
// Check transaction log for wallet 1
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (_, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
let (refreshed, txs) = api.retrieve_txs(m, true, None, None)?;
assert!(refreshed);
@@ -151,7 +151,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
})?;
// Check transaction log for wallet 2
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (refreshed, txs) = api.retrieve_txs(m, true, None, None)?;
assert!(refreshed);
// we should have a transaction entry for this slate
@@ -167,13 +167,13 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
})?;
// post transaction
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.post_tx(m, &slate.tx, false)?;
Ok(())
})?;
// Check wallet 1 contents are as expected
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
debug!(
"Wallet 1 Info Post Transaction, after {} blocks: {:?}",
@@ -213,7 +213,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 3, false);
// refresh wallets and retrieve info/tests for each wallet after maturity
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
debug!("Wallet 1 Info: {:?}", wallet1_info);
assert!(wallet1_refreshed);
@@ -228,7 +228,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
Ok(())
})?;
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (wallet2_refreshed, wallet2_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet2_refreshed);
assert_eq!(wallet2_info.amount_currently_spendable, amount);
@@ -245,7 +245,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
})?;
// Estimate fee and locked amount for a transaction
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
let init_args = InitTxArgs {
src_acct_name: None,
amount: amount * 2,
@@ -279,7 +279,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
// Send another transaction, but don't post to chain immediately and use
// the stored transaction instead
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
// note this will increment the block count as part of the transaction "Posting"
let args = InitTxArgs {
src_acct_name: None,
@@ -297,7 +297,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
Ok(())
})?;
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
let (refreshed, _wallet1_info) = sender_api.retrieve_summary_info(m, true, 1)?;
assert!(refreshed);
let (_, txs) = sender_api.retrieve_txs(m, true, None, None)?;
@@ -321,7 +321,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 3, false);
// check wallet2 has stored transaction
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (wallet2_refreshed, wallet2_info) = api.retrieve_summary_info(m, true, 1)?;
assert!(wallet2_refreshed);
assert_eq!(wallet2_info.amount_currently_spendable, amount * 3);
@@ -387,7 +387,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
let amount = 30_000_000_000;
let mut slate = Slate::blank(1);
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
// note this will increment the block count as part of the transaction "Posting"
let args = InitTxArgs {
src_acct_name: None,
@@ -407,7 +407,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// Check transaction log for wallet 1
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
println!(
"last confirmed height: {}",
@@ -438,7 +438,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// Check transaction log for wallet 2
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (refreshed, txs) = api.retrieve_txs(m, true, None, None)?;
assert!(refreshed);
let mut unconfirmed_count = 0;
@@ -465,7 +465,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 5, false);
// Wallet 1 decides to roll back instead
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
// can't roll back coinbase
let res = api.cancel_tx(m, Some(1), None);
assert!(res.is_err());
@@ -495,7 +495,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;
// Wallet 2 rolls back
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
let (_, txs) = api.retrieve_txs(m, true, None, None)?;
let tx = txs
.iter()
+6 -6
View File
@@ -76,7 +76,7 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
let amount = 60_000_000_000;
let mut slate = Slate::blank(1);
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
// note this will increment the block count as part of the transaction "Posting"
let args = InitTxArgs {
src_acct_name: None,
@@ -103,7 +103,7 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
// Now mine past the block, and check again. Transaction should be gone.
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 2, false);
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
let (_, txs) = sender_api.retrieve_txs(m, true, None, Some(slate.id))?;
let tx = txs[0].clone();
@@ -113,7 +113,7 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
})?;
// Should also be gone in wallet 2, and output gone
wallet::controller::owner_single_use(wallet2.clone(), mask2, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |sender_api, m| {
let (_, txs) = sender_api.retrieve_txs(m, true, None, Some(slate.id))?;
let tx = txs[0].clone();
let outputs = sender_api.retrieve_outputs(m, false, true, None)?.1;
@@ -126,7 +126,7 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
// try again, except try and send off the transaction for completion beyond the expiry
let mut slate = Slate::blank(1);
wallet::controller::owner_single_use(wallet1.clone(), mask1, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
// note this will increment the block count as part of the transaction "Posting"
let args = InitTxArgs {
src_acct_name: None,
@@ -153,13 +153,13 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 2, false);
// Wallet 2 will need to have updated past the TTL
wallet::controller::owner_single_use(wallet2.clone(), mask2, |sender_api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |sender_api, m| {
let (_, _) = sender_api.retrieve_txs(m, true, None, Some(slate.id))?;
Ok(())
})?;
// And when wallet 1 sends, should be rejected
wallet::controller::owner_single_use(wallet1.clone(), mask1, |_sender_api, _m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |_sender_api, _m| {
let res = client1.send_tx_slate_direct("wallet2", &slate);
println!("Send after TTL result is: {:?}", res);
assert!(res.is_err());
+3 -3
View File
@@ -69,14 +69,14 @@ fn updater_thread_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
});
// add some accounts
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
api.create_account_path(m, "mining")?;
api.create_account_path(m, "listener")?;
Ok(())
})?;
// add some accounts
wallet::controller::owner_single_use(wallet2.clone(), mask2, |api, m| {
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
api.create_account_path(m, "account1")?;
api.create_account_path(m, "account2")?;
Ok(())
@@ -91,7 +91,7 @@ fn updater_thread_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
let _ =
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, bh as usize, false);
let owner_api = api::Owner::new(wallet1);
let owner_api = api::Owner::new(wallet1, None);
owner_api.start_updater(mask1, Duration::from_secs(5))?;
// let updater thread run a bit