mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-14 12:10:42 +02:00
test: Add txin.sequence option to MiniWallet
This commit is contained in:
parent
e87fbee402
commit
faff3f35b7
@ -124,13 +124,13 @@ class MiniWallet:
|
|||||||
else:
|
else:
|
||||||
return self._utxos[index]
|
return self._utxos[index]
|
||||||
|
|
||||||
def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None, locktime=0):
|
def send_self_transfer(self, **kwargs):
|
||||||
"""Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
|
"""Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
|
||||||
tx = self.create_self_transfer(fee_rate=fee_rate, from_node=from_node, utxo_to_spend=utxo_to_spend)
|
tx = self.create_self_transfer(**kwargs)
|
||||||
self.sendrawtransaction(from_node=from_node, tx_hex=tx['hex'])
|
self.sendrawtransaction(from_node=kwargs['from_node'], tx_hex=tx['hex'])
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None, mempool_valid=True, locktime=0):
|
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."""
|
"""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'])
|
self._utxos = sorted(self._utxos, key=lambda k: k['value'])
|
||||||
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._utxos.pop() # Pick the largest utxo (if none provided) and hope it covers the fee
|
||||||
@ -140,7 +140,7 @@ class MiniWallet:
|
|||||||
assert send_value > 0
|
assert send_value > 0
|
||||||
|
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']))]
|
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']), nSequence=sequence)]
|
||||||
tx.vout = [CTxOut(int(send_value * COIN), self._scriptPubKey)]
|
tx.vout = [CTxOut(int(send_value * COIN), self._scriptPubKey)]
|
||||||
tx.nLockTime = locktime
|
tx.nLockTime = locktime
|
||||||
if not self._address:
|
if not self._address:
|
||||||
|
Loading…
Reference in New Issue
Block a user