Skip to content

Commit 62f9394

Browse files
MarcoFalkeknst
authored andcommitted
Merge bitcoin#22308: wallet: Add missing BlockUntilSyncedToCurrentChain
fa27baa Revert "test: Add temporary logging to debug bitcoin#20975" (MarcoFalke) fadb550 wallet: Add missing BlockUntilSyncedToCurrentChain (MarcoFalke) Pull request description: Fixes bitcoin#20975 Also replace the wallet pointer by a reference ACKs for top commit: achow101: ACK fa27baa Tree-SHA512: 79047a30998104a12c2ff84a8e3cc5207151410bbe92b74cfedbe1c1aca3ffa5909391607fc597f3a3cf0725fa827528a4c57edaeacc8360536b1965e166be6a
1 parent 240d8ef commit 62f9394

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4381,9 +4381,13 @@ RPCHelpMan walletprocesspsbt()
43814381
{
43824382
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
43834383

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();
43874391

43884392
// Unserialize the transaction
43894393
PartiallySignedTransaction psbtx;
@@ -4403,7 +4407,7 @@ RPCHelpMan walletprocesspsbt()
44034407
bool sign = request.params[1].isNull() ? true : request.params[1].get_bool();
44044408
bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
44054409
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)};
44074411
if (err != TransactionError::OK) {
44084412
throw JSONRPCTransactionError(err);
44094413
}
@@ -4500,9 +4504,13 @@ static RPCHelpMan walletcreatefundedpsbt()
45004504
}, true
45014505
);
45024506

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();
45064514

45074515
CAmount fee;
45084516
int change_position;
@@ -4511,15 +4519,15 @@ static RPCHelpMan walletcreatefundedpsbt()
45114519
// Automatically select coins, unless at least one is manually selected. Can
45124520
// be overridden by options.add_inputs.
45134521
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);
45154523

45164524
// Make a blank psbt
45174525
PartiallySignedTransaction psbtx{rawTx};
45184526

45194527
// Fill transaction with out data but don't sign
45204528
bool bip32derivs = request.params[4].isNull() ? true : request.params[4].get_bool();
45214529
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)};
45234531
if (err != TransactionError::OK) {
45244532
throw JSONRPCTransactionError(err);
45254533
}

test/functional/test_framework/blocktools.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,6 @@ def create_raw_transaction(node, txid, to_address, *, amount):
223223
signed_psbt = wrpc.walletprocesspsbt(psbt)
224224
psbt = signed_psbt['psbt']
225225
final_psbt = node.finalizepsbt(psbt)
226-
if not final_psbt["complete"]:
227-
node.log.info(f'final_psbt={final_psbt}')
228-
for w in node.listwallets():
229-
wrpc = node.get_wallet_rpc(w)
230-
node.log.info(f'listunspent={wrpc.listunspent()}')
231226
assert_equal(final_psbt["complete"], True)
232227
return final_psbt['hex']
233228

0 commit comments

Comments
 (0)