@@ -4381,9 +4381,13 @@ RPCHelpMan walletprocesspsbt()
4381
4381
{
4382
4382
RPCTypeCheck (request.params , {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4383
4383
4384
- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
4385
- if (!wallet) return NullUniValue;
4386
- const CWallet* const pwallet = wallet.get ();
4384
+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
4385
+ if (!pwallet) return NullUniValue;
4386
+
4387
+ const CWallet& wallet{*pwallet};
4388
+ // Make sure the results are valid at least up to the most recent block
4389
+ // the user could have gotten from another RPC command prior to now
4390
+ wallet.BlockUntilSyncedToCurrentChain ();
4387
4391
4388
4392
// Unserialize the transaction
4389
4393
PartiallySignedTransaction psbtx;
@@ -4403,7 +4407,7 @@ RPCHelpMan walletprocesspsbt()
4403
4407
bool sign = request.params [1 ].isNull () ? true : request.params [1 ].get_bool ();
4404
4408
bool bip32derivs = request.params [3 ].isNull () ? true : request.params [3 ].get_bool ();
4405
4409
bool complete = true ;
4406
- const TransactionError err = pwallet-> FillPSBT (psbtx, complete, nHashType, sign, bip32derivs);
4410
+ const TransactionError err{wallet. FillPSBT (psbtx, complete, nHashType, sign, bip32derivs)} ;
4407
4411
if (err != TransactionError::OK) {
4408
4412
throw JSONRPCTransactionError (err);
4409
4413
}
@@ -4500,9 +4504,13 @@ static RPCHelpMan walletcreatefundedpsbt()
4500
4504
}, true
4501
4505
);
4502
4506
4503
- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
4504
- if (!wallet) return NullUniValue;
4505
- CWallet* const pwallet = wallet.get ();
4507
+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
4508
+ if (!pwallet) return NullUniValue;
4509
+
4510
+ CWallet& wallet{*pwallet};
4511
+ // Make sure the results are valid at least up to the most recent block
4512
+ // the user could have gotten from another RPC command prior to now
4513
+ wallet.BlockUntilSyncedToCurrentChain ();
4506
4514
4507
4515
CAmount fee;
4508
4516
int change_position;
@@ -4511,15 +4519,15 @@ static RPCHelpMan walletcreatefundedpsbt()
4511
4519
// Automatically select coins, unless at least one is manually selected. Can
4512
4520
// be overridden by options.add_inputs.
4513
4521
coin_control.m_add_inputs = rawTx.vin .size () == 0 ;
4514
- FundTransaction (pwallet , rawTx, fee, change_position, request.params [3 ], coin_control);
4522
+ FundTransaction (&wallet , rawTx, fee, change_position, request.params [3 ], coin_control);
4515
4523
4516
4524
// Make a blank psbt
4517
4525
PartiallySignedTransaction psbtx{rawTx};
4518
4526
4519
4527
// Fill transaction with out data but don't sign
4520
4528
bool bip32derivs = request.params [4 ].isNull () ? true : request.params [4 ].get_bool ();
4521
4529
bool complete = true ;
4522
- const TransactionError err = pwallet-> FillPSBT (psbtx, complete, 1 , false , bip32derivs);
4530
+ const TransactionError err{wallet. FillPSBT (psbtx, complete, 1 , false , bip32derivs)} ;
4523
4531
if (err != TransactionError::OK) {
4524
4532
throw JSONRPCTransactionError (err);
4525
4533
}
0 commit comments