@@ -105,6 +105,47 @@ void CoinsResult::clear()
105
105
other.clear ();
106
106
}
107
107
108
+ void CoinsResult::Erase (std::set<COutPoint>& preset_coins)
109
+ {
110
+ for (auto & it : coins) {
111
+ auto & vec = it.second ;
112
+ auto i = std::find_if (vec.begin (), vec.end (), [&](const COutput &c) { return preset_coins.count (c.outpoint );});
113
+ if (i != vec.end ()) {
114
+ vec.erase (i);
115
+ break ;
116
+ }
117
+ }
118
+ }
119
+
120
+ void CoinsResult::Shuffle (FastRandomContext& rng_fast)
121
+ {
122
+ for (auto & it : coins) {
123
+ ::Shuffle (it.second.begin(), it.second.end(), rng_fast);
124
+ }
125
+ }
126
+
127
+ void CoinsResult::Add (OutputType type, const COutput& out)
128
+ {
129
+ coins[type].emplace_back (out);
130
+ }
131
+
132
+ static OutputType GetOutputType (TxoutType type, bool is_from_p2sh)
133
+ {
134
+ switch (type) {
135
+ case TxoutType::WITNESS_V1_TAPROOT:
136
+ return OutputType::BECH32M;
137
+ case TxoutType::WITNESS_V0_KEYHASH:
138
+ case TxoutType::WITNESS_V0_SCRIPTHASH:
139
+ if (is_from_p2sh) return OutputType::P2SH_SEGWIT;
140
+ else return OutputType::BECH32;
141
+ case TxoutType::SCRIPTHASH:
142
+ case TxoutType::PUBKEYHASH:
143
+ return OutputType::LEGACY;
144
+ default :
145
+ return OutputType::UNKNOWN;
146
+ }
147
+ }
148
+
108
149
CoinsResult AvailableCoins (const CWallet& wallet,
109
150
const CCoinControl* coinControl,
110
151
std::optional<CFeeRate> feerate,
0 commit comments