importmulti: Don't add internal addresses to address book
Github-Pull: #14679
Rebased-From: 7afddfa8ce
This commit is contained in:
parent
ef70f9b52b
commit
ae1b6756c9
2 changed files with 8 additions and 6 deletions
|
@ -996,8 +996,9 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
|
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to address book or update label
|
// if not internal add to address book or update label
|
||||||
if (IsValidDestination(pubkey_dest)) {
|
if (!internal) {
|
||||||
|
assert(IsValidDestination(pubkey_dest));
|
||||||
pwallet->SetAddressBook(pubkey_dest, label, "receive");
|
pwallet->SetAddressBook(pubkey_dest, label, "receive");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1148,7 +1149,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
|
||||||
" \"redeemscript\": \"<script>\" , (string, optional) Allowed only if the scriptPubKey is a P2SH address or a P2SH scriptPubKey\n"
|
" \"redeemscript\": \"<script>\" , (string, optional) Allowed only if the scriptPubKey is a P2SH address or a P2SH scriptPubKey\n"
|
||||||
" \"pubkeys\": [\"<pubKey>\", ... ] , (array, optional) Array of strings giving pubkeys that must occur in the output or redeemscript\n"
|
" \"pubkeys\": [\"<pubKey>\", ... ] , (array, optional) Array of strings giving pubkeys that must occur in the output or redeemscript\n"
|
||||||
" \"keys\": [\"<key>\", ... ] , (array, optional) Array of strings giving private keys whose corresponding public keys must occur in the output or redeemscript\n"
|
" \"keys\": [\"<key>\", ... ] , (array, optional) Array of strings giving private keys whose corresponding public keys must occur in the output or redeemscript\n"
|
||||||
" \"internal\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be treated as not incoming payments\n"
|
" \"internal\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be treated as not incoming payments aka change\n"
|
||||||
" \"watchonly\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be considered watched even when they're not spendable, only allowed if keys are empty\n"
|
" \"watchonly\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be considered watched even when they're not spendable, only allowed if keys are empty\n"
|
||||||
" \"label\": <label> , (string, optional, default: '') Label to assign to the address (aka account name, for now), only allowed with internal=false\n"
|
" \"label\": <label> , (string, optional, default: '') Label to assign to the address (aka account name, for now), only allowed with internal=false\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ImportMultiTest (BitcoinTestFramework):
|
||||||
|
|
||||||
# RPC importmulti -----------------------------------------------
|
# RPC importmulti -----------------------------------------------
|
||||||
|
|
||||||
# Bitcoin Address
|
# Bitcoin Address (implicit non-internal)
|
||||||
self.log.info("Should import an address")
|
self.log.info("Should import an address")
|
||||||
address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
|
address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
|
||||||
result = self.nodes[1].importmulti([{
|
result = self.nodes[1].importmulti([{
|
||||||
|
@ -98,7 +98,7 @@ class ImportMultiTest (BitcoinTestFramework):
|
||||||
assert_equal('timestamp' in address_assert, False)
|
assert_equal('timestamp' in address_assert, False)
|
||||||
|
|
||||||
|
|
||||||
# Address + Public key + !Internal
|
# Address + Public key + !Internal(explicit)
|
||||||
self.log.info("Should import an address with public key")
|
self.log.info("Should import an address with public key")
|
||||||
address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
|
address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
|
||||||
result = self.nodes[1].importmulti([{
|
result = self.nodes[1].importmulti([{
|
||||||
|
@ -106,7 +106,8 @@ class ImportMultiTest (BitcoinTestFramework):
|
||||||
"address": address['address']
|
"address": address['address']
|
||||||
},
|
},
|
||||||
"timestamp": "now",
|
"timestamp": "now",
|
||||||
"pubkeys": [ address['pubkey'] ]
|
"pubkeys": [ address['pubkey'] ],
|
||||||
|
"internal": False
|
||||||
}])
|
}])
|
||||||
assert_equal(result[0]['success'], True)
|
assert_equal(result[0]['success'], True)
|
||||||
address_assert = self.nodes[1].getaddressinfo(address['address'])
|
address_assert = self.nodes[1].getaddressinfo(address['address'])
|
||||||
|
|
Loading…
Reference in a new issue