Skip to content

Commit 75a5e47

Browse files
committed
Change bumpfee to use watch-only funds for legacy watchonly wallets
1 parent 1705f19 commit 75a5e47

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/wallet/feebumper.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet
4747

4848
// check that original tx consists entirely of our inputs
4949
// 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)
50-
if (!wallet.IsAllFromMe(*wtx.tx, ISMINE_SPENDABLE)) {
50+
isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
51+
if (!wallet.IsAllFromMe(*wtx.tx, filter)) {
5152
errors.push_back("Transaction contains inputs that don't belong to this wallet");
5253
return feebumper::Result::WALLET_ERROR;
5354
}
@@ -78,7 +79,8 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
7879
CFeeRate incrementalRelayFee = std::max(wallet.chain().relayIncrementalFee(), CFeeRate(WALLET_INCREMENTAL_RELAY_FEE));
7980

8081
// Given old total fee and transaction size, calculate the old feeRate
81-
CAmount old_fee = wtx.GetDebit(ISMINE_SPENDABLE) - wtx.tx->GetValueOut();
82+
isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
83+
CAmount old_fee = wtx.GetDebit(filter) - wtx.tx->GetValueOut();
8284
const int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
8385
CFeeRate nOldFeeRate(old_fee, txSize);
8486
// Min total fee is old fee + relay fee
@@ -195,7 +197,8 @@ Result CreateTotalBumpTransaction(const CWallet* wallet, const uint256& txid, co
195197
}
196198

197199
// calculate the old fee and fee-rate
198-
old_fee = wtx.GetDebit(ISMINE_SPENDABLE) - wtx.tx->GetValueOut();
200+
isminefilter filter = wallet->GetLegacyScriptPubKeyMan() && wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
201+
old_fee = wtx.GetDebit(filter) - wtx.tx->GetValueOut();
199202
CFeeRate nOldFeeRate(old_fee, txSize);
200203
// The wallet uses a conservative WALLET_INCREMENTAL_RELAY_FEE value to
201204
// future proof against changes to network wide policy for incremental relay
@@ -308,7 +311,8 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
308311
}
309312
}
310313

311-
old_fee = wtx.GetDebit(ISMINE_SPENDABLE) - wtx.tx->GetValueOut();
314+
isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
315+
old_fee = wtx.GetDebit(filter) - wtx.tx->GetValueOut();
312316

313317
if (coin_control.m_feerate) {
314318
// The user provided a feeRate argument.

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3380,10 +3380,12 @@ static UniValue bumpfee(const JSONRPCRequest& request)
33803380
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ});
33813381
uint256 hash(ParseHashV(request.params[0], "txid"));
33823382

3383+
CCoinControl coin_control;
3384+
coin_control.fAllowWatchOnly = pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
33833385
// optional parameters
33843386
CAmount totalFee = 0;
3385-
CCoinControl coin_control;
33863387
coin_control.m_signal_bip125_rbf = true;
3388+
33873389
if (!request.params[1].isNull()) {
33883390
UniValue options = request.params[1];
33893391
RPCTypeCheckObj(options,

0 commit comments

Comments
 (0)