|
20 | 20 | namespace wallet {
|
21 | 21 | //! Check whether transaction has descendant in wallet or mempool, or has been
|
22 | 22 | //! mined, or conflicts with a mined transaction. Return a feebumper::Result.
|
23 |
| -static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, std::vector<bilingual_str>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) |
| 23 | +static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, bool require_mine, std::vector<bilingual_str>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) |
24 | 24 | {
|
25 | 25 | if (wallet.HasWalletSpend(wtx.tx)) {
|
26 | 26 | errors.push_back(Untranslated("Transaction has descendants in the wallet"));
|
@@ -49,15 +49,16 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet
|
49 | 49 | return feebumper::Result::WALLET_ERROR;
|
50 | 50 | }
|
51 | 51 |
|
52 |
| - // check that original tx consists entirely of our inputs |
53 |
| - // if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee) |
54 |
| - isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE; |
55 |
| - if (!AllInputsMine(wallet, *wtx.tx, filter)) { |
56 |
| - errors.push_back(Untranslated("Transaction contains inputs that don't belong to this wallet")); |
57 |
| - return feebumper::Result::WALLET_ERROR; |
| 52 | + if (require_mine) { |
| 53 | + // check that original tx consists entirely of our inputs |
| 54 | + // if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee) |
| 55 | + isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE; |
| 56 | + if (!AllInputsMine(wallet, *wtx.tx, filter)) { |
| 57 | + errors.push_back(Untranslated("Transaction contains inputs that don't belong to this wallet")); |
| 58 | + return feebumper::Result::WALLET_ERROR; |
| 59 | + } |
58 | 60 | }
|
59 | 61 |
|
60 |
| - |
61 | 62 | return feebumper::Result::OK;
|
62 | 63 | }
|
63 | 64 |
|
@@ -149,12 +150,12 @@ bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid)
|
149 | 150 | if (wtx == nullptr) return false;
|
150 | 151 |
|
151 | 152 | std::vector<bilingual_str> errors_dummy;
|
152 |
| - feebumper::Result res = PreconditionChecks(wallet, *wtx, errors_dummy); |
| 153 | + feebumper::Result res = PreconditionChecks(wallet, *wtx, /* require_mine=*/ true, errors_dummy); |
153 | 154 | return res == feebumper::Result::OK;
|
154 | 155 | }
|
155 | 156 |
|
156 | 157 | Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCoinControl& coin_control, std::vector<bilingual_str>& errors,
|
157 |
| - CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx) |
| 158 | + CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx, bool require_mine) |
158 | 159 | {
|
159 | 160 | // We are going to modify coin control later, copy to re-use
|
160 | 161 | CCoinControl new_coin_control(coin_control);
|
@@ -216,7 +217,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
216 | 217 | }
|
217 | 218 | }
|
218 | 219 |
|
219 |
| - Result result = PreconditionChecks(wallet, wtx, errors); |
| 220 | + Result result = PreconditionChecks(wallet, wtx, require_mine, errors); |
220 | 221 | if (result != Result::OK) {
|
221 | 222 | return result;
|
222 | 223 | }
|
@@ -309,7 +310,7 @@ Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransacti
|
309 | 310 | const CWalletTx& oldWtx = it->second;
|
310 | 311 |
|
311 | 312 | // make sure the transaction still has no descendants and hasn't been mined in the meantime
|
312 |
| - Result result = PreconditionChecks(wallet, oldWtx, errors); |
| 313 | + Result result = PreconditionChecks(wallet, oldWtx, /* require_mine=*/ false, errors); |
313 | 314 | if (result != Result::OK) {
|
314 | 315 | return result;
|
315 | 316 | }
|
|
0 commit comments