test/functional/test_framework/wallet.py
def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None):
        """Create and send 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'])
        utxo_to_spend = utxo_to_spend or self._utxos.pop()  # Pick the largest utxo (if none provided) and hope it covers the fee
        vsize = Decimal(96)
        send_value = satoshi_round(utxo_to_spend['value'] - fee_rate * (vsize / 1000))
        fee = utxo_to_spend['value'] - send_value
        assert send_value > 0

        tx = CTransaction()
        tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']))]
        tx.vout = [CTxOut(int(send_value * COIN), self._scriptPubKey)]
        tx.wit.vtxinwit = [CTxInWitness()]
        tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
        tx_hex = tx.serialize().hex()

        tx_info = from_node.testmempoolaccept([tx_hex])[0]
        self._utxos.append({'txid': tx_info['txid'], 'vout': 0, 'value': send_value})
        from_node.sendrawtransaction(tx_hex)
        assert_equal(tx_info['vsize'], vsize)
        assert_equal(tx_info['fees']['base'], fee)
        return {'txid': tx_info['txid'], 'wtxid': tx_info['wtxid'], 'hex': tx_hex}
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.
Create and send a tx with the specified fee_rate . Fee may be exact or at most one satoshi higher than needed .
def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None):
        self._utxos = sorted(self._utxos, key=lambda k: k['value'])
        utxo_to_spend = utxo_to_spend or self._utxos.pop()  
        vsize = Decimal(96)
        send_value = satoshi_round(utxo_to_spend['value'] - fee_rate * (vsize / 1000))
        fee = utxo_to_spend['value'] - send_value
        assert send_value > 0
        tx = CTransaction()
        tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']))]
        tx.vout = [CTxOut(int(send_value * COIN), self._scriptPubKey)]
        tx.wit.vtxinwit = [CTxInWitness()]
        tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
        tx_hex = tx.serialize().hex()
        tx_info = from_node.testmempoolaccept([tx_hex])[0]
        self._utxos.append({'txid': tx_info['txid'], 'vout': 0, 'value': send_value})
        from_node.sendrawtransaction(tx_hex)
        assert_equal(tx_info['vsize'], vsize)
        assert_equal(tx_info['fees']['base'], fee)
        return {'txid': tx_info['txid'], 'wtxid': tx_info['wtxid'], 'hex': tx_hex}
def send_self_transfer ( self , * , fee_rate = Decimal ( "0.003" ) , from_node , utxo_to_spend = None ) : self . _utxos = sorted ( self . _utxos , key = lambda k : k [ 'value' ] ) utxo_to_spend = utxo_to_spend or self . _utxos . pop ( ) vsize = Decimal ( 96 ) send_value = satoshi_round ( utxo_to_spend [ 'value' ] - fee_rate * ( vsize / 1000 ) ) fee = utxo_to_spend [ 'value' ] - send_value assert send_value > 0 tx = CTransaction ( ) tx . vin = [ CTxIn ( COutPoint ( int ( utxo_to_spend [ 'txid' ] , 16 ) , utxo_to_spend [ 'vout' ] ) ) ] tx . vout = [ CTxOut ( int ( send_value * COIN ) , self . _scriptPubKey ) ] tx . wit . vtxinwit = [ CTxInWitness ( ) ] tx . wit . vtxinwit [ 0 ] . scriptWitness . stack = [ CScript ( [ OP_TRUE ] ) ] tx_hex = tx . serialize ( ) . hex ( ) tx_info = from_node . testmempoolaccept ( [ tx_hex ] ) [ 0 ] self . _utxos . append ( { 'txid' : tx_info [ 'txid' ] , 'vout' : 0 , 'value' : send_value } ) from_node . sendrawtransaction ( tx_hex ) assert_equal ( tx_info [ 'vsize' ] , vsize ) assert_equal ( tx_info [ 'fees' ] [ 'base' ] , fee ) return { 'txid' : tx_info [ 'txid' ] , 'wtxid' : tx_info [ 'wtxid' ] , 'hex' : tx_hex }
Create and send a tx with the specified fee_rate.
Create and send a tx with the specified fee_rate .
"""Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.""" # Pick the largest utxo (if none provided) and hope it covers the fee
self
fee_rate
from_node
utxo_to_spend