mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
test: Return the largest utxo in MiniWallet.get_utxo
This commit is contained in:
parent
41a1b5f58c
commit
fa62207737
2 changed files with 3 additions and 5 deletions
|
@ -53,7 +53,7 @@ class MerkleBlockTest(BitcoinTestFramework):
|
|||
assert_equal(self.nodes[0].verifytxoutproof(self.nodes[0].gettxoutproof([txid1, txid2])), txlist)
|
||||
assert_equal(self.nodes[0].verifytxoutproof(self.nodes[0].gettxoutproof([txid1, txid2], blockhash)), txlist)
|
||||
|
||||
txin_spent = miniwallet.get_utxo() # Get the change from txid2
|
||||
txin_spent = miniwallet.get_utxo(txid=txid2) # Get the change from txid2
|
||||
tx3 = miniwallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=txin_spent)
|
||||
txid3 = tx3['txid']
|
||||
self.generate(self.nodes[0], 1)
|
||||
|
|
|
@ -133,10 +133,9 @@ class MiniWallet:
|
|||
|
||||
Args:
|
||||
txid: get the first utxo we find from a specific transaction
|
||||
|
||||
Note: Can be used to get the change output immediately after a send_self_transfer
|
||||
"""
|
||||
index = -1 # by default the last utxo
|
||||
self._utxos = sorted(self._utxos, key=lambda k: (k['value'], -k['height'])) # Put the largest utxo last
|
||||
if txid:
|
||||
utxo = next(filter(lambda utxo: txid == utxo['txid'], self._utxos))
|
||||
index = self._utxos.index(utxo)
|
||||
|
@ -172,8 +171,7 @@ class MiniWallet:
|
|||
|
||||
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None, mempool_valid=True, locktime=0, sequence=0):
|
||||
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
|
||||
self._utxos = sorted(self._utxos, key=lambda k: (k['value'], -k['height']))
|
||||
utxo_to_spend = utxo_to_spend or self._utxos.pop() # Pick the largest utxo (if none provided) and hope it covers the fee
|
||||
utxo_to_spend = utxo_to_spend or self.get_utxo()
|
||||
if self._priv_key is None:
|
||||
vsize = Decimal(104) # anyone-can-spend
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue