Skip to content

Commit 6d3db52

Browse files
promagfjahr
andcommitted
rpc, wallet: Document and test mempool scan after importprivkey
co-authored-by: Fabian Jahr <[email protected]>
1 parent 3abdbbb commit 6d3db52

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/wallet/rpc/backup.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@ RPCHelpMan importprivkey()
100100
"Hint: use importmulti to import more than one private key.\n"
101101
"\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n"
102102
"may report that the imported key exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
103+
"The rescan parameter can be set to false if the key was never used to create transactions. If it is set to false,\n"
104+
"but the key was used to create transactions, rescanwallet needs to be called with the appropriate block range.\n"
103105
"Note: Use \"getwalletinfo\" to query the scanning progress.\n",
104106
{
105107
{"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The private key (see dumpprivkey)"},
106108
{"label", RPCArg::Type::STR, RPCArg::DefaultHint{"current label if address exists, otherwise \"\""}, "An optional label"},
107-
{"rescan", RPCArg::Type::BOOL, RPCArg::Default{true}, "Rescan the wallet for transactions"},
109+
{"rescan", RPCArg::Type::BOOL, RPCArg::Default{true}, "Scan the chain and mempool for wallet transactions."},
108110
},
109111
RPCResult{RPCResult::Type::NONE, "", ""},
110112
RPCExamples{

test/functional/wallet_balance.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ def test_balances(*, fee_node_1=0):
288288
assert_equal(self.nodes[0].getbalances()['mine']['untrusted_pending'], Decimal('0.1'))
289289
assert_equal(self.nodes[0].getbalances()['watchonly']['untrusted_pending'], 0)
290290
self.nodes[0].unloadwallet('w1')
291+
# check importprivkey on fresh wallet
292+
self.nodes[0].createwallet('w2', False, True)
293+
self.nodes[0].importprivkey(privkey)
294+
assert_equal(self.nodes[0].getbalances()['mine']['untrusted_pending'], Decimal('0.1'))
291295

292296

293297
if __name__ == '__main__':

0 commit comments

Comments
 (0)