From 2210e706f985b69f4bd35e13fe9996711468db6f Mon Sep 17 00:00:00 2001 From: AntiochP <30642645+antiochp@users.noreply.github.com> Date: Sun, 1 Oct 2017 17:56:19 -0400 Subject: [PATCH] Add fee amount to wallet receive_transaction (mainly for testing purposes) (#150) --- wallet/src/receiver.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wallet/src/receiver.rs b/wallet/src/receiver.rs index 68c2fb2cd..17690ae09 100644 --- a/wallet/src/receiver.rs +++ b/wallet/src/receiver.rs @@ -215,10 +215,16 @@ fn receive_transaction( let next_child = wallet_data.next_child(&ext_key.fingerprint); let out_key = ext_key.derive(&secp, next_child).map_err(|e| Error::Key(e))?; + // TODO - replace with real fee calculation + // TODO - note we are not enforcing this in consensus anywhere yet + let fee_amount = 1; + let out_amount = amount - fee_amount; + let (tx_final, _) = build::transaction(vec![ build::initial_tx(partial), build::with_excess(blinding), - build::output(amount, out_key.key), + build::output(out_amount, out_key.key), + build::with_fee(fee_amount), ])?; // make sure the resulting transaction is valid (could have been lied to @@ -229,7 +235,7 @@ fn receive_transaction( wallet_data.append_output(OutputData { fingerprint: out_key.fingerprint, n_child: out_key.n_child, - value: amount, + value: out_amount, status: OutputStatus::Unconfirmed, height: 0, lock_height: 0,