MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / split_inputs

Function split_inputs

test/functional/feature_fee_estimation.py:74–100  ·  view source on GitHub ↗

Generate a lot of inputs so we can generate a ton of transactions. This function takes an input from txins, and creates and sends a transaction which splits the value into 2 outputs which are appended to txouts. Previously this was designed to be small inputs so they wouldn't have a

(from_node, txins, txouts, initial_split=False)

Source from the content-addressed store, hash-verified

72 return (ToHex(tx), fee)
73
74def split_inputs(from_node, txins, txouts, initial_split=False):
75 """Generate a lot of inputs so we can generate a ton of transactions.
76
77 This function takes an input from txins, and creates and sends a transaction
78 which splits the value into 2 outputs which are appended to txouts.
79 Previously this was designed to be small inputs so they wouldn't have
80 a high coin age when the notion of priority still existed."""
81
82 prevtxout = txins.pop()
83 tx = CTransaction()
84 tx.vin.append(CTxIn(COutPoint(int(prevtxout["txid"], 16), prevtxout["vout"]), b""))
85
86 half_change = satoshi_round(prevtxout["amount"] / 2)
87 rem_change = prevtxout["amount"] - half_change - Decimal("0.00001000")
88 tx.vout.append(CTxOut(int(half_change * COIN), P2SH_1))
89 tx.vout.append(CTxOut(int(rem_change * COIN), P2SH_2))
90
91 # If this is the initial split we actually need to sign the transaction
92 # Otherwise we just need to insert the proper ScriptSig
93 if (initial_split):
94 completetx = from_node.signrawtransactionwithwallet(ToHex(tx))["hex"]
95 else:
96 tx.vin[0].scriptSig = SCRIPT_SIG[prevtxout["vout"]]
97 completetx = ToHex(tx)
98 txid = from_node.sendrawtransaction(completetx, True)
99 txouts.append({"txid": txid, "vout": 0, "amount": half_change})
100 txouts.append({"txid": txid, "vout": 1, "amount": rem_change})
101
102def check_estimates(node, fees_seen):
103 """Call estimatesmartfee and verify that the estimates meet certain invariants."""

Callers 1

run_testMethod · 0.85

Calls 6

CTransactionClass · 0.90
CTxInClass · 0.90
COutPointClass · 0.90
satoshi_roundFunction · 0.90
CTxOutClass · 0.90
ToHexFunction · 0.90

Tested by

no test coverage detected