diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-06-22 23:08:16 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-06-22 23:08:23 +0200 |
commit | c93e123dc72bfc1bd2c637fdcd032e570d53a7bd (patch) | |
tree | 123b8bcdd4c50ef5cb27a0dd91729dfc0a1278bb /src | |
parent | 327e2691f6e0498aa868af965bb4a951c5be17c5 (diff) | |
parent | fa27baa9c8a13239625e5a7b6c472d236fe5b9fa (diff) | |
download | bitcoin-c93e123dc72bfc1bd2c637fdcd032e570d53a7bd.tar.xz |
Merge bitcoin/bitcoin#22308: wallet: Add missing BlockUntilSyncedToCurrentChain
fa27baa9c8a13239625e5a7b6c472d236fe5b9fa Revert "test: Add temporary logging to debug #20975" (MarcoFalke)
fadb55085a02c9e355617bcb5f84b6335e4f8c9d wallet: Add missing BlockUntilSyncedToCurrentChain (MarcoFalke)
Pull request description:
Fixes #20975
Also replace the wallet pointer by a reference
ACKs for top commit:
achow101:
ACK fa27baa9c8a13239625e5a7b6c472d236fe5b9fa
Tree-SHA512: 79047a30998104a12c2ff84a8e3cc5207151410bbe92b74cfedbe1c1aca3ffa5909391607fc597f3a3cf0725fa827528a4c57edaeacc8360536b1965e166be6a
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/rpcwallet.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ab34af2329..8b1b6c6d95 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4317,6 +4317,11 @@ static RPCHelpMan walletprocesspsbt() std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; + const CWallet& wallet{*pwallet}; + // Make sure the results are valid at least up to the most recent block + // the user could have gotten from another RPC command prior to now + wallet.BlockUntilSyncedToCurrentChain(); + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR}); // Unserialize the transaction @@ -4333,7 +4338,7 @@ static RPCHelpMan walletprocesspsbt() bool sign = request.params[1].isNull() ? true : request.params[1].get_bool(); bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool(); bool complete = true; - const TransactionError err = pwallet->FillPSBT(psbtx, complete, nHashType, sign, bip32derivs); + const TransactionError err{wallet.FillPSBT(psbtx, complete, nHashType, sign, bip32derivs)}; if (err != TransactionError::OK) { throw JSONRPCTransactionError(err); } @@ -4431,6 +4436,11 @@ static RPCHelpMan walletcreatefundedpsbt() std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; + CWallet& wallet{*pwallet}; + // Make sure the results are valid at least up to the most recent block + // the user could have gotten from another RPC command prior to now + wallet.BlockUntilSyncedToCurrentChain(); + RPCTypeCheck(request.params, { UniValue::VARR, UniValueType(), // ARR or OBJ, checked later @@ -4442,7 +4452,7 @@ static RPCHelpMan walletcreatefundedpsbt() CAmount fee; int change_position; - bool rbf = pwallet->m_signal_rbf; + bool rbf{wallet.m_signal_rbf}; const UniValue &replaceable_arg = request.params[3]["replaceable"]; if (!replaceable_arg.isNull()) { RPCTypeCheckArgument(replaceable_arg, UniValue::VBOOL); @@ -4453,7 +4463,7 @@ static RPCHelpMan walletcreatefundedpsbt() // Automatically select coins, unless at least one is manually selected. Can // be overridden by options.add_inputs. coin_control.m_add_inputs = rawTx.vin.size() == 0; - FundTransaction(*pwallet, rawTx, fee, change_position, request.params[3], coin_control, /* override_min_fee */ true); + FundTransaction(wallet, rawTx, fee, change_position, request.params[3], coin_control, /* override_min_fee */ true); // Make a blank psbt PartiallySignedTransaction psbtx(rawTx); @@ -4461,7 +4471,7 @@ static RPCHelpMan walletcreatefundedpsbt() // Fill transaction with out data but don't sign bool bip32derivs = request.params[4].isNull() ? true : request.params[4].get_bool(); bool complete = true; - const TransactionError err = pwallet->FillPSBT(psbtx, complete, 1, false, bip32derivs); + const TransactionError err{wallet.FillPSBT(psbtx, complete, 1, false, bip32derivs)}; if (err != TransactionError::OK) { throw JSONRPCTransactionError(err); } |