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)
| 259 | |
| 260 | |
| 261 | def 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 | |
| 283 | def 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.""" |