setaccount should return if an invalid address is provided.
authorMatt Corallo <matt@bluematt.me>
Sat, 5 Mar 2011 14:32:32 +0000 (15:32 +0100)
committerMatt Corallo <matt@bluematt.me>
Sat, 5 Mar 2011 14:32:32 +0000 (15:32 +0100)
This prevents setaccount from creating new accounts which do not have any addresses.

rpc.cpp

diff --git a/rpc.cpp b/rpc.cpp
index 1c6f228..e01ea0e 100644 (file)
--- a/rpc.cpp
+++ b/rpc.cpp
@@ -381,6 +381,12 @@ Value setaccount(const Array& params, bool fHelp)
             "Sets the account associated with the given address.");
 
     string strAddress = params[0].get_str();
+    uint160 hash160;
+    bool isValid = AddressToHash160(strAddress, hash160);
+    if (!isValid)
+        throw runtime_error("provided address is not valid");
+
+
     string strAccount;
     if (params.size() > 1)
         strAccount = AccountFromValue(params[1]);