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:
cliik
2022-07-26 10:15:53 +01:00
committed by GitHub
co-authored by cliik
parent 7b1eab62b1
commit ef3fadbd24
10 changed files with 270 additions and 17 deletions
+4
View File
@@ -508,6 +508,7 @@ where
&mut *w,
keychain_mask,
args.amount,
args.amount_includes_fee.unwrap_or(false),
args.minimum_confirmations,
args.max_outputs as usize,
args.num_change_outputs as usize,
@@ -543,6 +544,7 @@ where
&parent_key_id,
true,
use_test_rng,
args.amount_includes_fee.unwrap_or(false),
)?
};
@@ -696,6 +698,7 @@ where
&parent_key_id,
false,
use_test_rng,
false,
)?;
let keychain = w.keychain(keychain_mask)?;
@@ -823,6 +826,7 @@ where
parent_key_id.clone(),
false,
true,
false,
)?;
// Add inputs and outputs to original context
+3
View File
@@ -40,6 +40,8 @@ pub struct InitTxArgs {
#[serde(with = "secp_ser::string_or_u64")]
/// The amount to send, in nanogrins. (`1 G = 1_000_000_000nG`)
pub amount: u64,
/// Does the amount include the fee, or will fees be spent in addition to the amount?
pub amount_includes_fee: Option<bool>,
#[serde(with = "secp_ser::string_or_u64")]
/// The minimum number of confirmations an output
/// should have in order to be included in the transaction.
@@ -105,6 +107,7 @@ impl Default for InitTxArgs {
InitTxArgs {
src_acct_name: None,
amount: 0,
amount_includes_fee: None,
minimum_confirmations: 10,
max_outputs: 500,
num_change_outputs: 1,