From e2ad2b3880b614f5a4941aa45723d470da0ba614 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Wed, 4 Dec 2019 13:04:28 +0000 Subject: [PATCH] Add TTL Option to command line (#273) * re-insert v2 slate * reinstate version conversions * rustfmt * add and test versioning checks against 2.0.0 wallets * rustfmt * fix to invoice file output * doctest fix * remove target slate version from command line options * add ttl option to send_tx and pay commands * rustfmt --- controller/src/command.rs | 4 ++++ libwallet/src/api_impl/owner.rs | 2 +- src/bin/grin-wallet.yml | 10 ++++++++++ src/cmd/wallet_args.rs | 8 ++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/controller/src/command.rs b/controller/src/command.rs index d189b32ab..d09e4c8cd 100644 --- a/controller/src/command.rs +++ b/controller/src/command.rs @@ -253,6 +253,7 @@ pub struct SendArgs { pub max_outputs: usize, pub target_slate_version: Option, pub payment_proof_address: Option, + pub ttl_blocks: Option, } pub fn send( @@ -302,6 +303,7 @@ where message: args.message.clone(), target_slate_version: args.target_slate_version, payment_proof_recipient_address, + ttl_blocks: args.ttl_blocks, send_args: None, ..Default::default() }; @@ -529,6 +531,7 @@ pub struct ProcessInvoiceArgs { pub max_outputs: usize, pub input: String, pub estimate_selection_strategies: bool, + pub ttl_blocks: Option, } /// Process invoice @@ -574,6 +577,7 @@ where num_change_outputs: 1u32, selection_strategy_is_use_all: args.selection_strategy == "all", message: args.message.clone(), + ttl_blocks: args.ttl_blocks, send_args: None, ..Default::default() }; diff --git a/libwallet/src/api_impl/owner.rs b/libwallet/src/api_impl/owner.rs index d4d6139a6..988b3ebb3 100644 --- a/libwallet/src/api_impl/owner.rs +++ b/libwallet/src/api_impl/owner.rs @@ -751,7 +751,7 @@ where // Step 5: Cancel any transactions with an expired TTL for tx in txs { if let Some(e) = tx.ttl_cutoff_height { - if e >= tip.0 { + if tip.0 >= e { wallet_lock!(wallet_inst, w); let parent_key_id = w.parent_key_id(); tx::cancel_tx(&mut **w, keychain_mask, &parent_key_id, Some(tx.id), None)?; diff --git a/src/bin/grin-wallet.yml b/src/bin/grin-wallet.yml index be565ac6d..40c1b66df 100644 --- a/src/bin/grin-wallet.yml +++ b/src/bin/grin-wallet.yml @@ -155,6 +155,11 @@ subcommands: short: t long: stored_tx takes_value: true + - ttl_blocks: + help: If present, the number of blocks from the current after which wallets should refuse to process transactions further + short: b + long: ttl_blocks + takes_value: true - receive: about: Processes a transaction file to accept a transfer from a sender args: @@ -252,6 +257,11 @@ subcommands: short: i long: input takes_value: true + - ttl_blocks: + help: If present, the number of blocks from the current after which wallets should refuse to process transactions further + short: b + long: ttl_blocks + takes_value: true - outputs: about: Raw wallet output info (list of outputs) - txs: diff --git a/src/cmd/wallet_args.rs b/src/cmd/wallet_args.rs index 37f12a863..b7759d51e 100644 --- a/src/cmd/wallet_args.rs +++ b/src/cmd/wallet_args.rs @@ -453,6 +453,9 @@ pub fn parse_send_args(args: &ArgMatches) -> Result Result