mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Merge 95fe477fd1 into merged_master (Bitcoin PR bitcoin/bitcoin#23693)
This commit is contained in:
commit
360bf6eb36
1 changed files with 8 additions and 10 deletions
|
|
@ -53,7 +53,7 @@ static std::vector<CTransactionRef> CreateOrderedCoins(FastRandomContext& det_ra
|
|||
size_t n_ancestors = det_rand.randrange(10)+1;
|
||||
for (size_t ancestor = 0; ancestor < n_ancestors && !available_coins.empty(); ++ancestor){
|
||||
size_t idx = det_rand.randrange(available_coins.size());
|
||||
Available& coin = available_coins[idx];
|
||||
Available coin = available_coins[idx];
|
||||
uint256 hash = coin.ref->GetHash();
|
||||
// biased towards taking min_ancestors parents, but maybe more
|
||||
size_t n_to_take = det_rand.randrange(2) == 0 ?
|
||||
|
|
@ -66,17 +66,15 @@ static std::vector<CTransactionRef> CreateOrderedCoins(FastRandomContext& det_ra
|
|||
tx.witness.vtxinwit.emplace_back();
|
||||
tx.witness.vtxinwit.back().scriptWitness.stack.push_back(CScriptNum(coin.tx_count).getvch());
|
||||
}
|
||||
if (coin.vin_left == coin.ref->vout.size()) {
|
||||
if(available_coins.size()-1!=idx){ // if idx is not the last index swap it with the end index
|
||||
std::swap(available_coins[idx], available_coins.back());
|
||||
}
|
||||
if (coin.vin_left == coin.ref->vin.size()) {
|
||||
coin = available_coins.back();
|
||||
available_coins.pop_back();
|
||||
}
|
||||
}
|
||||
tx.vout.resize(det_rand.randrange(10)+2);
|
||||
for (auto& out : tx.vout) {
|
||||
out.scriptPubKey = CScript() << CScriptNum(tx_counter) << OP_EQUAL;
|
||||
out.nValue = 10 * COIN;
|
||||
tx.vout.resize(det_rand.randrange(10)+2);
|
||||
for (auto& out : tx.vout) {
|
||||
out.scriptPubKey = CScript() << CScriptNum(tx_counter) << OP_EQUAL;
|
||||
out.nValue = 10 * COIN;
|
||||
}
|
||||
}
|
||||
ordered_coins.emplace_back(MakeTransactionRef(tx));
|
||||
available_coins.emplace_back(ordered_coins.back(), tx_counter++);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue