mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 11:13:23 -03:00
test: Return fee from MiniWallet
This commit is contained in:
parent
faec09f240
commit
fa448c27d2
1 changed files with 4 additions and 1 deletions
|
@ -298,6 +298,9 @@ class MiniWallet:
|
||||||
inputs_value_total = sum([int(COIN * utxo['value']) for utxo in utxos_to_spend])
|
inputs_value_total = sum([int(COIN * utxo['value']) for utxo in utxos_to_spend])
|
||||||
outputs_value_total = inputs_value_total - fee_per_output * num_outputs
|
outputs_value_total = inputs_value_total - fee_per_output * num_outputs
|
||||||
amount_per_output = amount_per_output or (outputs_value_total // num_outputs)
|
amount_per_output = amount_per_output or (outputs_value_total // num_outputs)
|
||||||
|
assert amount_per_output > 0
|
||||||
|
outputs_value_total = amount_per_output * num_outputs
|
||||||
|
fee = Decimal(inputs_value_total - outputs_value_total) / COIN
|
||||||
|
|
||||||
# create tx
|
# create tx
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
|
@ -320,6 +323,7 @@ class MiniWallet:
|
||||||
coinbase=False,
|
coinbase=False,
|
||||||
confirmations=0,
|
confirmations=0,
|
||||||
) for i in range(len(tx.vout))],
|
) for i in range(len(tx.vout))],
|
||||||
|
"fee": fee,
|
||||||
"txid": txid,
|
"txid": txid,
|
||||||
"wtxid": tx.getwtxid(),
|
"wtxid": tx.getwtxid(),
|
||||||
"hex": tx.serialize().hex(),
|
"hex": tx.serialize().hex(),
|
||||||
|
@ -339,7 +343,6 @@ class MiniWallet:
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
send_value = utxo_to_spend["value"] - (fee or (fee_rate * vsize / 1000))
|
send_value = utxo_to_spend["value"] - (fee or (fee_rate * vsize / 1000))
|
||||||
assert send_value > 0
|
|
||||||
|
|
||||||
# create tx
|
# create tx
|
||||||
tx = self.create_self_transfer_multi(utxos_to_spend=[utxo_to_spend], locktime=locktime, sequence=sequence, amount_per_output=int(COIN * send_value), target_weight=target_weight)
|
tx = self.create_self_transfer_multi(utxos_to_spend=[utxo_to_spend], locktime=locktime, sequence=sequence, amount_per_output=int(COIN * send_value), target_weight=target_weight)
|
||||||
|
|
Loading…
Add table
Reference in a new issue