Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TTL Option to command line #273

Merged
merged 12 commits into from
Dec 4, 2019
4 changes: 4 additions & 0 deletions controller/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pub struct SendArgs {
pub max_outputs: usize,
pub target_slate_version: Option<u16>,
pub payment_proof_address: Option<String>,
pub ttl_blocks: Option<u64>,
}

pub fn send<L, C, K>(
Expand Down Expand Up @@ -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()
};
Expand Down Expand Up @@ -529,6 +531,7 @@ pub struct ProcessInvoiceArgs {
pub max_outputs: usize,
pub input: String,
pub estimate_selection_strategies: bool,
pub ttl_blocks: Option<u64>,
}

/// Process invoice
Expand Down Expand Up @@ -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()
};
Expand Down
2 changes: 1 addition & 1 deletion libwallet/src/api_impl/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
10 changes: 10 additions & 0 deletions src/bin/grin-wallet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions src/cmd/wallet_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ pub fn parse_send_args(args: &ArgMatches) -> Result<command::SendArgs, ParseErro
// fluff
let fluff = args.is_present("fluff");

// ttl_blocks
let ttl_blocks = parse_u64_or_none(args.value_of("ttl_blocks"));

// max_outputs
let max_outputs = 500;

Expand Down Expand Up @@ -493,6 +496,7 @@ pub fn parse_send_args(args: &ArgMatches) -> Result<command::SendArgs, ParseErro
fluff: fluff,
max_outputs: max_outputs,
payment_proof_address,
ttl_blocks,
target_slate_version: target_slate_version,
})
}
Expand Down Expand Up @@ -636,6 +640,9 @@ pub fn parse_process_invoice_args(
return Err(ParseError::ArgumentError(msg));
}

// ttl_blocks
let ttl_blocks = parse_u64_or_none(args.value_of("ttl_blocks"));

// max_outputs
let max_outputs = 500;

Expand Down Expand Up @@ -663,6 +670,7 @@ pub fn parse_process_invoice_args(
dest: dest.to_owned(),
max_outputs: max_outputs,
input: tx_file.to_owned(),
ttl_blocks,
})
}

Expand Down