@@ -73,6 +73,12 @@ def get_utxo(self, *, txid=''):
73
73
74
74
def send_self_transfer (self , * , fee_rate = Decimal ("0.003" ), from_node , utxo_to_spend = None ):
75
75
"""Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
76
+ tx = self .create_self_transfer (fee_rate = fee_rate , from_node = from_node , utxo_to_spend = utxo_to_spend )
77
+ self .sendrawtransaction (from_node = from_node , tx_hex = tx ['hex' ])
78
+ return tx
79
+
80
+ def create_self_transfer (self , * , fee_rate = Decimal ("0.003" ), from_node , utxo_to_spend = None , mempool_valid = True ):
81
+ """Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
76
82
self ._utxos = sorted (self ._utxos , key = lambda k : k ['value' ])
77
83
utxo_to_spend = utxo_to_spend or self ._utxos .pop () # Pick the largest utxo (if none provided) and hope it covers the fee
78
84
vsize = Decimal (96 )
@@ -88,9 +94,10 @@ def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_sp
88
94
tx_hex = tx .serialize ().hex ()
89
95
90
96
tx_info = from_node .testmempoolaccept ([tx_hex ])[0 ]
91
- self .sendrawtransaction (from_node = from_node , tx_hex = tx_hex )
92
- assert_equal (tx_info ['vsize' ], vsize )
93
- assert_equal (tx_info ['fees' ]['base' ], fee )
97
+ assert_equal (mempool_valid , tx_info ['allowed' ])
98
+ if mempool_valid :
99
+ assert_equal (tx_info ['vsize' ], vsize )
100
+ assert_equal (tx_info ['fees' ]['base' ], fee )
94
101
return {'txid' : tx_info ['txid' ], 'wtxid' : tx_info ['wtxid' ], 'hex' : tx_hex }
95
102
96
103
def sendrawtransaction (self , * , from_node , tx_hex ):
0 commit comments