aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-02-15 15:31:04 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-02-15 16:29:16 +0100
commit7a93af8340d95add7f0d9ddf051aa242302cfc10 (patch)
tree7e7e6fdd4e47baa194cd284e1b92e478f49c51bb
parent476cc47da084633ac17b9b3c9257fab425b3bbba (diff)
parent9acf25cc013c013ee5b07dba7b1319b7c5a7b6a4 (diff)
downloadbitcoin-7a93af8340d95add7f0d9ddf051aa242302cfc10.tar.xz
Merge #9756: Return error when importmulti called with invalid address.
9acf25c Return error when importmulti called with invalid address. (Russell Yanofsky)
-rwxr-xr-xqa/rpc-tests/importmulti.py10
-rw-r--r--src/wallet/rpcdump.cpp3
2 files changed, 13 insertions, 0 deletions
diff --git a/qa/rpc-tests/importmulti.py b/qa/rpc-tests/importmulti.py
index 02a932e737..1aa4ba2e18 100755
--- a/qa/rpc-tests/importmulti.py
+++ b/qa/rpc-tests/importmulti.py
@@ -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")
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index 0a3225937e..908655d411 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -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)) {