Skip to content

Commit fadb550

Browse files
author
MarcoFalke
committed
wallet: Add missing BlockUntilSyncedToCurrentChain
1 parent 672870a commit fadb550

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4317,6 +4317,11 @@ static RPCHelpMan walletprocesspsbt()
43174317
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
43184318
if (!pwallet) return NullUniValue;
43194319

4320+
const CWallet& wallet{*pwallet};
4321+
// Make sure the results are valid at least up to the most recent block
4322+
// the user could have gotten from another RPC command prior to now
4323+
wallet.BlockUntilSyncedToCurrentChain();
4324+
43204325
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
43214326

43224327
// Unserialize the transaction
@@ -4333,7 +4338,7 @@ static RPCHelpMan walletprocesspsbt()
43334338
bool sign = request.params[1].isNull() ? true : request.params[1].get_bool();
43344339
bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
43354340
bool complete = true;
4336-
const TransactionError err = pwallet->FillPSBT(psbtx, complete, nHashType, sign, bip32derivs);
4341+
const TransactionError err{wallet.FillPSBT(psbtx, complete, nHashType, sign, bip32derivs)};
43374342
if (err != TransactionError::OK) {
43384343
throw JSONRPCTransactionError(err);
43394344
}
@@ -4431,6 +4436,11 @@ static RPCHelpMan walletcreatefundedpsbt()
44314436
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
44324437
if (!pwallet) return NullUniValue;
44334438

4439+
CWallet& wallet{*pwallet};
4440+
// Make sure the results are valid at least up to the most recent block
4441+
// the user could have gotten from another RPC command prior to now
4442+
wallet.BlockUntilSyncedToCurrentChain();
4443+
44344444
RPCTypeCheck(request.params, {
44354445
UniValue::VARR,
44364446
UniValueType(), // ARR or OBJ, checked later
@@ -4442,7 +4452,7 @@ static RPCHelpMan walletcreatefundedpsbt()
44424452

44434453
CAmount fee;
44444454
int change_position;
4445-
bool rbf = pwallet->m_signal_rbf;
4455+
bool rbf{wallet.m_signal_rbf};
44464456
const UniValue &replaceable_arg = request.params[3]["replaceable"];
44474457
if (!replaceable_arg.isNull()) {
44484458
RPCTypeCheckArgument(replaceable_arg, UniValue::VBOOL);
@@ -4453,15 +4463,15 @@ static RPCHelpMan walletcreatefundedpsbt()
44534463
// Automatically select coins, unless at least one is manually selected. Can
44544464
// be overridden by options.add_inputs.
44554465
coin_control.m_add_inputs = rawTx.vin.size() == 0;
4456-
FundTransaction(*pwallet, rawTx, fee, change_position, request.params[3], coin_control, /* override_min_fee */ true);
4466+
FundTransaction(wallet, rawTx, fee, change_position, request.params[3], coin_control, /* override_min_fee */ true);
44574467

44584468
// Make a blank psbt
44594469
PartiallySignedTransaction psbtx(rawTx);
44604470

44614471
// Fill transaction with out data but don't sign
44624472
bool bip32derivs = request.params[4].isNull() ? true : request.params[4].get_bool();
44634473
bool complete = true;
4464-
const TransactionError err = pwallet->FillPSBT(psbtx, complete, 1, false, bip32derivs);
4474+
const TransactionError err{wallet.FillPSBT(psbtx, complete, 1, false, bip32derivs)};
44654475
if (err != TransactionError::OK) {
44664476
throw JSONRPCTransactionError(err);
44674477
}

0 commit comments

Comments
 (0)