MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BulkTransaction

Function BulkTransaction

src/test/util/transaction_utils.cpp:74–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void BulkTransaction(CMutableTransaction& tx, int32_t target_weight)
75{
76 tx.vout.emplace_back(0, CScript() << OP_RETURN);
77 auto unpadded_weight{GetTransactionWeight(CTransaction(tx))};
78 assert(target_weight >= unpadded_weight);
79
80 // determine number of needed padding bytes by converting weight difference to vbytes
81 auto dummy_vbytes = (target_weight - unpadded_weight + (WITNESS_SCALE_FACTOR - 1)) / WITNESS_SCALE_FACTOR;
82 // compensate for the increase of the compact-size encoded script length
83 // (note that the length encoding of the unpadded output script needs one byte)
84 dummy_vbytes -= GetSizeOfCompactSize(dummy_vbytes) - 1;
85
86 // pad transaction by repeatedly appending a dummy opcode to the output script
87 tx.vout[0].scriptPubKey.insert(tx.vout[0].scriptPubKey.end(), dummy_vbytes, OP_1);
88
89 // actual weight should be at most 3 higher than target weight
90 assert(GetTransactionWeight(CTransaction(tx)) >= target_weight);
91 assert(GetTransactionWeight(CTransaction(tx)) <= target_weight + 3);
92}
93
94bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType, SignatureData& sig_data)
95{

Callers 4

BOOST_AUTO_TEST_CASEFunction · 0.85
TestPackageSelectionMethod · 0.85
MockMempoolMinFeeFunction · 0.85
MakeTransactionBulkedToFunction · 0.85

Calls 7

GetTransactionWeightFunction · 0.85
GetSizeOfCompactSizeFunction · 0.85
CScriptClass · 0.70
CTransactionClass · 0.50
emplace_backMethod · 0.45
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected