mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
rpc, wallet: Document and test mempool scan after importaddress
co-authored-by: Fabian Jahr <fjahr@protonmail.com>
This commit is contained in:
parent
236239bd40
commit
3abdbbb90a
2 changed files with 19 additions and 1 deletions
|
@ -201,6 +201,8 @@ RPCHelpMan importaddress()
|
||||||
"\nAdds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n"
|
"\nAdds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n"
|
||||||
"\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n"
|
"\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n"
|
||||||
"may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
|
"may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
|
||||||
|
"The rescan parameter can be set to false if the key was never used to create transactions. If it is set to false,\n"
|
||||||
|
"but the key was used to create transactions, rescanwallet needs to be called with the appropriate block range.\n"
|
||||||
"If you have the full public key, you should call importpubkey instead of this.\n"
|
"If you have the full public key, you should call importpubkey instead of this.\n"
|
||||||
"Hint: use importmulti to import more than one address.\n"
|
"Hint: use importmulti to import more than one address.\n"
|
||||||
"\nNote: If you import a non-standard raw script in hex form, outputs sending to it will be treated\n"
|
"\nNote: If you import a non-standard raw script in hex form, outputs sending to it will be treated\n"
|
||||||
|
@ -209,7 +211,7 @@ RPCHelpMan importaddress()
|
||||||
{
|
{
|
||||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The Bitcoin address (or hex-encoded script)"},
|
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The Bitcoin address (or hex-encoded script)"},
|
||||||
{"label", RPCArg::Type::STR, RPCArg::Default{""}, "An optional label"},
|
{"label", RPCArg::Type::STR, RPCArg::Default{""}, "An optional label"},
|
||||||
{"rescan", RPCArg::Type::BOOL, RPCArg::Default{true}, "Rescan the wallet for transactions"},
|
{"rescan", RPCArg::Type::BOOL, RPCArg::Default{true}, "Scan the chain and mempool for wallet transactions."},
|
||||||
{"p2sh", RPCArg::Type::BOOL, RPCArg::Default{false}, "Add the P2SH version of the script as well"},
|
{"p2sh", RPCArg::Type::BOOL, RPCArg::Default{false}, "Add the P2SH version of the script as well"},
|
||||||
},
|
},
|
||||||
RPCResult{RPCResult::Type::NONE, "", ""},
|
RPCResult{RPCResult::Type::NONE, "", ""},
|
||||||
|
|
|
@ -273,6 +273,22 @@ class WalletTest(BitcoinTestFramework):
|
||||||
self.generatetoaddress(self.nodes[1], 1, ADDRESS_WATCHONLY)
|
self.generatetoaddress(self.nodes[1], 1, ADDRESS_WATCHONLY)
|
||||||
assert_equal(self.nodes[0].getbalance(minconf=0), total_amount + 1) # The reorg recovered our fee of 1 coin
|
assert_equal(self.nodes[0].getbalance(minconf=0), total_amount + 1) # The reorg recovered our fee of 1 coin
|
||||||
|
|
||||||
|
if not self.options.descriptors:
|
||||||
|
self.log.info('Check if mempool is taken into account after import*')
|
||||||
|
address = self.nodes[0].getnewaddress()
|
||||||
|
privkey = self.nodes[0].dumpprivkey(address)
|
||||||
|
self.nodes[0].sendtoaddress(address, 0.1)
|
||||||
|
self.nodes[0].unloadwallet('')
|
||||||
|
# check importaddress on fresh wallet
|
||||||
|
self.nodes[0].createwallet('w1', False, True)
|
||||||
|
self.nodes[0].importaddress(address)
|
||||||
|
assert_equal(self.nodes[0].getbalances()['mine']['untrusted_pending'], 0)
|
||||||
|
assert_equal(self.nodes[0].getbalances()['watchonly']['untrusted_pending'], Decimal('0.1'))
|
||||||
|
self.nodes[0].importprivkey(privkey)
|
||||||
|
assert_equal(self.nodes[0].getbalances()['mine']['untrusted_pending'], Decimal('0.1'))
|
||||||
|
assert_equal(self.nodes[0].getbalances()['watchonly']['untrusted_pending'], 0)
|
||||||
|
self.nodes[0].unloadwallet('w1')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
WalletTest().main()
|
WalletTest().main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue