Skip to content

Commit 7a93af8

Browse files
committed
Merge #9756: Return error when importmulti called with invalid address.
9acf25c Return error when importmulti called with invalid address. (Russell Yanofsky)
2 parents 476cc47 + 9acf25c commit 7a93af8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

qa/rpc-tests/importmulti.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ def run_test (self):
6464
watchonly_address = address['address']
6565
watchonly_timestamp = timestamp
6666

67+
print("Should not import an invalid address")
68+
result = self.nodes[1].importmulti([{
69+
"scriptPubKey": {
70+
"address": "not valid address",
71+
},
72+
"timestamp": "now",
73+
}])
74+
assert_equal(result[0]['success'], False)
75+
assert_equal(result[0]['error']['code'], -5)
76+
assert_equal(result[0]['error']['message'], 'Invalid address')
6777

6878
# ScriptPubKey + internal
6979
print("Should import a scriptPubKey with internal flag")

src/wallet/rpcdump.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,9 @@ UniValue ProcessImport(const UniValue& data, const int64_t timestamp)
672672

673673
if (!isScript) {
674674
address = CBitcoinAddress(output);
675+
if (!address.IsValid()) {
676+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
677+
}
675678
script = GetScriptForDestination(address.Get());
676679
} else {
677680
if (!IsHex(output)) {

0 commit comments

Comments
 (0)