aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-12-07 09:24:27 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-12-07 09:24:34 +0100
commit89ea2b3809352120343aabb4da8cb7b1fcdde485 (patch)
tree6095416e8072ff2f58a7cdefb5c100e45a17af81 /src/wallet
parentb7e63306e812c5b7f97b5e65c72f4283fddf4510 (diff)
parentfa5362a9a0c5665c1a4de51c3ce4758c93a9449e (diff)
Merge bitcoin/bitcoin#20583: rpc: Add missing BlockUntilSyncedToCurrentChain to wallet RPCs
fa5362a9a0c5665c1a4de51c3ce4758c93a9449e rpc: Add missing BlockUntilSyncedToCurrentChain to wallet RPCs (MarcoFalke) Pull request description: Wallet RPCs that allow a rescan based on block-timestamp or block-height need to sync with the active chain first, because the user might assume the wallet is up-to-date with the latest block they got reported via a blockchain RPC. ACKs for top commit: meshcollider: utACK fa5362a9a0c5665c1a4de51c3ce4758c93a9449e Tree-SHA512: d4831f1f08f854f9a49fc969de86c438f856e41c2163c801a6ff36dc2f6299cb342b44663279c524a8b7ca9a50895db1243cd7d49bed79277ada857213f20a26
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/rpc/backup.cpp10
-rw-r--r--src/wallet/rpcwallet.cpp5
2 files changed, 15 insertions, 0 deletions
diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
index a61ebb26b3..7e06ff0e4f 100644
--- a/src/wallet/rpc/backup.cpp
+++ b/src/wallet/rpc/backup.cpp
@@ -1346,6 +1346,11 @@ RPCHelpMan importmulti()
{
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(mainRequest);
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(mainRequest.params, {UniValue::VARR, UniValue::VOBJ});
@@ -1649,6 +1654,11 @@ RPCHelpMan importdescriptors()
{
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(main_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();
// Make sure wallet is a descriptor wallet
if (!pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index faf0154d0f..73949f26cb 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -3304,6 +3304,11 @@ static RPCHelpMan rescanblockchain()
{
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();
WalletRescanReserver reserver(*pwallet);
if (!reserver.reserve()) {