mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-02 03:43:55 +01:00
Implement fee inclusive transactions (#657)
* Add amount_includes_fee option in TX building * Add --amount_includes_fee CLI option * Implement send 'max' amount Co-authored-by: cliik <cliik@example.com>
This commit is contained in:
@@ -109,7 +109,7 @@ subcommands:
|
||||
about: Builds a transaction to send coins and sends to the recipient via the Slatepack workflow
|
||||
args:
|
||||
- amount:
|
||||
help: Number of coins to send with optional fraction, e.g. 12.423
|
||||
help: Number of coins to send with optional fraction, e.g. 12.423. Keyword 'max' will send maximum amount.
|
||||
index: 1
|
||||
- minimum_confirmations:
|
||||
help: Minimum number of confirmations required for an output to be spendable
|
||||
@@ -181,6 +181,9 @@ subcommands:
|
||||
help: Show slatepack data as QR code
|
||||
short: q
|
||||
long: slatepack_qr
|
||||
- amount_includes_fee:
|
||||
help: Transaction amount includes transaction fee. Recipient will receive (amount - fee).
|
||||
long: amount_includes_fee
|
||||
- unpack:
|
||||
about: Unpack and display an armored Slatepack Message, decrypting if possible
|
||||
args:
|
||||
|
||||
@@ -444,7 +444,11 @@ pub fn parse_account_args(account_args: &ArgMatches) -> Result<command::AccountA
|
||||
pub fn parse_send_args(args: &ArgMatches) -> Result<command::SendArgs, ParseError> {
|
||||
// amount
|
||||
let amount = parse_required(args, "amount")?;
|
||||
let amount = core::core::amount_from_hr_string(amount);
|
||||
let (amount, spend_max) = if amount.eq_ignore_ascii_case("max") {
|
||||
(Ok(0), true)
|
||||
} else {
|
||||
(core::core::amount_from_hr_string(amount), false)
|
||||
};
|
||||
let amount = match amount {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
@@ -455,6 +459,7 @@ pub fn parse_send_args(args: &ArgMatches) -> Result<command::SendArgs, ParseErro
|
||||
return Err(ParseError::ArgumentError(msg));
|
||||
}
|
||||
};
|
||||
let amount_includes_fee = args.is_present("amount_includes_fee") || spend_max;
|
||||
|
||||
// minimum_confirmations
|
||||
let min_c = parse_required(args, "minimum_confirmations")?;
|
||||
@@ -524,6 +529,8 @@ pub fn parse_send_args(args: &ArgMatches) -> Result<command::SendArgs, ParseErro
|
||||
|
||||
Ok(command::SendArgs {
|
||||
amount: amount,
|
||||
amount_includes_fee: amount_includes_fee,
|
||||
use_max_amount: spend_max,
|
||||
minimum_confirmations: min_c,
|
||||
selection_strategy: selection_strategy.to_owned(),
|
||||
estimate_selection_strategies,
|
||||
|
||||
Reference in New Issue
Block a user