Skip to content

Commit

Permalink
refactor: drop CompareInputCoinBIP69
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Jan 2, 2025
1 parent 7f0dd73 commit d77cc28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
8 changes: 3 additions & 5 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3801,19 +3801,17 @@ bool CWallet::CreateTransactionInternal(
}
}

// Shuffle selected coins and fill in final vin
// Fill in final vin and shuffle/sort it
txNew.vin.clear();
std::vector<CInputCoin> selected_coins(setCoins.begin(), setCoins.end());
if (sort_bip69) { std::sort(selected_coins.begin(), selected_coins.end(), CompareInputCoinBIP69()); }
else { Shuffle(selected_coins.begin(), selected_coins.end(), FastRandomContext()); }

// Note how the sequence number is set to non-maxint so that
// the nLockTime set above actually works.
const uint32_t nSequence = CTxIn::SEQUENCE_FINAL - 1;
for (const auto& coin : selected_coins) {
for (const auto& coin : setCoins) {
txNew.vin.push_back(CTxIn(coin.outpoint, CScript(), nSequence));
}
if (sort_bip69) { std::sort(txNew.vin.begin(), txNew.vin.end(), CompareInputBIP69()); }
else { Shuffle(txNew.vin.begin(), txNew.vin.end(), FastRandomContext()); }

if (sign && !SignTransaction(txNew)) {
error = _("Signing transaction failed");
Expand Down
10 changes: 0 additions & 10 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,16 +618,6 @@ struct WalletTxHasher
}
};

struct CompareInputCoinBIP69
{
inline bool operator()(const CInputCoin& a, const CInputCoin& b) const
{
// Note: CInputCoin-s are essentially inputs, their txouts are used for informational purposes only
// that's why we use CompareInputBIP69 to sort them in a BIP69 compliant way.
return CompareInputBIP69()(CTxIn(a.outpoint), CTxIn(b.outpoint));
}
};

class COutput
{
public:
Expand Down

0 comments on commit d77cc28

Please sign in to comment.