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

Function make_chain

test/functional/test_framework/wallet.py:261–281  ·  view source on GitHub ↗

Build a transaction that spends parent_txid.vout[n] and produces one output with amount = parent_value with a fee deducted. Return tuple (CTransaction object, raw hex, nValue, scriptPubKey of the output created).

(node, address, privkeys, parent_txid, parent_value, n=0, parent_locking_script=None, fee=DEFAULT_FEE)

Source from the content-addressed store, hash-verified

259
260
261def make_chain(node, address, privkeys, parent_txid, parent_value, n=0, parent_locking_script=None, fee=DEFAULT_FEE):
262 """Build a transaction that spends parent_txid.vout[n] and produces one output with
263 amount = parent_value with a fee deducted.
264 Return tuple (CTransaction object, raw hex, nValue, scriptPubKey of the output created).
265 """
266 inputs = [{"txid": parent_txid, "vout": n}]
267 # ELEMENTS: add fee output
268 my_value = parent_value - fee
269 outputs = [{address : my_value}, {"fee": fee}]
270 rawtx = node.createrawtransaction(inputs, outputs)
271 tx = tx_from_hex(rawtx)
272 prevtxs = [{
273 "txid": parent_txid,
274 "vout": n,
275 "scriptPubKey": parent_locking_script,
276 "amount": parent_value,
277 }] if parent_locking_script else None
278 signedtx = node.signrawtransactionwithkey(hexstring=rawtx, privkeys=privkeys, prevtxs=prevtxs)
279 assert signedtx["complete"]
280 tx = tx_from_hex(signedtx["hex"])
281 return (tx, signedtx["hex"], my_value, tx.vout[0].scriptPubKey.hex())
282
283def create_child_with_parents(node, address, privkeys, parents_tx, values, locking_scripts, fee=DEFAULT_FEE):
284 """Creates a transaction that spends the first output of each parent in parents_tx."""

Callers 11

test_multiple_parentsMethod · 0.90
test_anc_count_limitsMethod · 0.90
test_anc_size_limitsMethod · 0.90
test_desc_size_limitsMethod · 0.90
create_raw_chainFunction · 0.85

Calls 2

tx_from_hexFunction · 0.90
hexMethod · 0.80

Tested by 10

test_multiple_parentsMethod · 0.72
test_anc_count_limitsMethod · 0.72
test_anc_size_limitsMethod · 0.72
test_desc_size_limitsMethod · 0.72