Skip to content

Commit c93e123

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22308: wallet: Add missing BlockUntilSyncedToCurrentChain
fa27baa Revert "test: Add temporary logging to debug #20975" (MarcoFalke) fadb550 wallet: Add missing BlockUntilSyncedToCurrentChain (MarcoFalke) Pull request description: Fixes #20975 Also replace the wallet pointer by a reference ACKs for top commit: achow101: ACK fa27baa Tree-SHA512: 79047a30998104a12c2ff84a8e3cc5207151410bbe92b74cfedbe1c1aca3ffa5909391607fc597f3a3cf0725fa827528a4c57edaeacc8360536b1965e166be6a
2 parents 327e269 + fa27baa commit c93e123

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
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
}

test/functional/test_framework/blocktools.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,6 @@ def create_raw_transaction(node, txid, to_address, *, amount):
181181
signed_psbt = wrpc.walletprocesspsbt(psbt)
182182
psbt = signed_psbt['psbt']
183183
final_psbt = node.finalizepsbt(psbt)
184-
if not final_psbt["complete"]:
185-
node.log.info(f'final_psbt={final_psbt}')
186-
for w in node.listwallets():
187-
wrpc = node.get_wallet_rpc(w)
188-
node.log.info(f'listunspent={wrpc.listunspent()}')
189184
assert_equal(final_psbt["complete"], True)
190185
return final_psbt['hex']
191186

0 commit comments

Comments
 (0)