Merge #9756: Return error when importmulti called with invalid address.
9acf25c
Return error when importmulti called with invalid address. (Russell Yanofsky)
This commit is contained in:
commit
7a93af8340
2 changed files with 13 additions and 0 deletions
|
@ -64,6 +64,16 @@ class ImportMultiTest (BitcoinTestFramework):
|
|||
watchonly_address = address['address']
|
||||
watchonly_timestamp = timestamp
|
||||
|
||||
print("Should not import an invalid address")
|
||||
result = self.nodes[1].importmulti([{
|
||||
"scriptPubKey": {
|
||||
"address": "not valid address",
|
||||
},
|
||||
"timestamp": "now",
|
||||
}])
|
||||
assert_equal(result[0]['success'], False)
|
||||
assert_equal(result[0]['error']['code'], -5)
|
||||
assert_equal(result[0]['error']['message'], 'Invalid address')
|
||||
|
||||
# ScriptPubKey + internal
|
||||
print("Should import a scriptPubKey with internal flag")
|
||||
|
|
|
@ -672,6 +672,9 @@ UniValue ProcessImport(const UniValue& data, const int64_t timestamp)
|
|||
|
||||
if (!isScript) {
|
||||
address = CBitcoinAddress(output);
|
||||
if (!address.IsValid()) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
||||
}
|
||||
script = GetScriptForDestination(address.Get());
|
||||
} else {
|
||||
if (!IsHex(output)) {
|
||||
|
|
Loading…
Reference in a new issue