@@ -4317,6 +4317,11 @@ static RPCHelpMan walletprocesspsbt()
4317
4317
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
4318
4318
if (!pwallet) return NullUniValue;
4319
4319
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
+
4320
4325
RPCTypeCheck (request.params , {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4321
4326
4322
4327
// Unserialize the transaction
@@ -4333,7 +4338,7 @@ static RPCHelpMan walletprocesspsbt()
4333
4338
bool sign = request.params [1 ].isNull () ? true : request.params [1 ].get_bool ();
4334
4339
bool bip32derivs = request.params [3 ].isNull () ? true : request.params [3 ].get_bool ();
4335
4340
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)} ;
4337
4342
if (err != TransactionError::OK) {
4338
4343
throw JSONRPCTransactionError (err);
4339
4344
}
@@ -4431,6 +4436,11 @@ static RPCHelpMan walletcreatefundedpsbt()
4431
4436
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
4432
4437
if (!pwallet) return NullUniValue;
4433
4438
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
+
4434
4444
RPCTypeCheck (request.params , {
4435
4445
UniValue::VARR,
4436
4446
UniValueType (), // ARR or OBJ, checked later
@@ -4442,7 +4452,7 @@ static RPCHelpMan walletcreatefundedpsbt()
4442
4452
4443
4453
CAmount fee;
4444
4454
int change_position;
4445
- bool rbf = pwallet-> m_signal_rbf ;
4455
+ bool rbf{wallet. m_signal_rbf } ;
4446
4456
const UniValue &replaceable_arg = request.params [3 ][" replaceable" ];
4447
4457
if (!replaceable_arg.isNull ()) {
4448
4458
RPCTypeCheckArgument (replaceable_arg, UniValue::VBOOL);
@@ -4453,15 +4463,15 @@ static RPCHelpMan walletcreatefundedpsbt()
4453
4463
// Automatically select coins, unless at least one is manually selected. Can
4454
4464
// be overridden by options.add_inputs.
4455
4465
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 );
4457
4467
4458
4468
// Make a blank psbt
4459
4469
PartiallySignedTransaction psbtx (rawTx);
4460
4470
4461
4471
// Fill transaction with out data but don't sign
4462
4472
bool bip32derivs = request.params [4 ].isNull () ? true : request.params [4 ].get_bool ();
4463
4473
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)} ;
4465
4475
if (err != TransactionError::OK) {
4466
4476
throw JSONRPCTransactionError (err);
4467
4477
}
0 commit comments