Creates a transaction with num_inputs inputs and 1 output, padded to target_weight. Use this function to maximize m_outpoint_to_orphan_it operations. If num_inputs is 0, we maximize the number of inputs.
| 28 | // Creates a transaction with num_inputs inputs and 1 output, padded to target_weight. Use this function to maximize m_outpoint_to_orphan_it operations. |
| 29 | // If num_inputs is 0, we maximize the number of inputs. |
| 30 | static CTransactionRef MakeTransactionBulkedTo(unsigned int num_inputs, int64_t target_weight, FastRandomContext& det_rand) |
| 31 | { |
| 32 | CMutableTransaction tx; |
| 33 | assert(target_weight >= 40 + APPROX_WEIGHT_PER_INPUT); |
| 34 | if (!num_inputs) num_inputs = (target_weight - 40) / APPROX_WEIGHT_PER_INPUT; |
| 35 | for (unsigned int i = 0; i < num_inputs; ++i) { |
| 36 | tx.vin.emplace_back(Txid::FromUint256(det_rand.rand256()), 0); |
| 37 | } |
| 38 | assert(GetTransactionWeight(*MakeTransactionRef(tx)) <= target_weight); |
| 39 | |
| 40 | tx.vout.resize(1); |
| 41 | |
| 42 | // If necessary, pad the transaction to the target weight. |
| 43 | if (GetTransactionWeight(*MakeTransactionRef(tx)) < target_weight - 4) { |
| 44 | BulkTransaction(tx, target_weight); |
| 45 | } |
| 46 | return MakeTransactionRef(tx); |
| 47 | } |
| 48 | |
| 49 | // Constructs a transaction using a subset of inputs[start_input : start_input + num_inputs] up to the weight_limit. |
| 50 | static CTransactionRef MakeTransactionSpendingUpTo(const std::vector<CTxIn>& inputs, unsigned int start_input, unsigned int num_inputs, int64_t weight_limit) |
no test coverage detected