MCPcopy Create free account
hub / github.com/ElementsProject/elements / send_to

Method send_to

test/functional/test_framework/wallet.py:163–181  ·  view source on GitHub ↗

Create and send a tx with an output to a given scriptPubKey/amount, plus a change output to our internal address. To keep things simple, a fixed fee given in Satoshi is used. Note that this method fails if there is no single internal utxo available that can

(self, *, from_node, scriptPubKey, amount, fee=1000)

Source from the content-addressed store, hash-verified

161 return tx
162
163 def send_to(self, *, from_node, scriptPubKey, amount, fee=1000):
164 """
165 Create and send a tx with an output to a given scriptPubKey/amount,
166 plus a change output to our internal address. To keep things simple, a
167 fixed fee given in Satoshi is used.
168
169 Note that this method fails if there is no single internal utxo
170 available that can cover the cost for the amount and the fixed fee
171 (the utxo with the largest value is taken).
172
173 Returns a tuple (txid, n) referring to the created external utxo outpoint.
174 """
175 tx = self.create_self_transfer(from_node=from_node, fee_rate=0, mempool_valid=False)['tx']
176 assert_greater_than_or_equal(tx.vout[0].nValue.getAmount(), amount + fee)
177 tx.vout[0].nValue.setToAmount(tx.vout[0].nValue.getAmount() - (amount + fee)) # change output -> MiniWallet
178 tx.vout[1].nValue.setToAmount(fee) # ELEMENTS explicitly set fee output value
179 tx.vout.append(CTxOut(amount, scriptPubKey)) # arbitrary output -> to be returned
180 txid = self.sendrawtransaction(from_node=from_node, tx_hex=tx.serialize().hex())
181 return txid, 1
182
183 def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utxo_to_spend=None, mempool_valid=True, locktime=0, sequence=0):
184 """Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""

Callers 6

run_testMethod · 0.80
test_msg_mempoolMethod · 0.80
test_frelay_falseMethod · 0.80
test_filterMethod · 0.80
sendtodestinationMethod · 0.80
make_utxoMethod · 0.80

Calls 8

create_self_transferMethod · 0.95
sendrawtransactionMethod · 0.95
CTxOutClass · 0.90
getAmountMethod · 0.80
setToAmountMethod · 0.80
hexMethod · 0.80
serializeMethod · 0.45

Tested by 3

test_msg_mempoolMethod · 0.64
test_frelay_falseMethod · 0.64
test_filterMethod · 0.64