| 72 | } |
| 73 | |
| 74 | void 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 | |
| 94 | bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType, SignatureData& sig_data) |
| 95 | { |
no test coverage detected