changeset 29650:aa4a517420b8

rpc: give back base58 encoded address format in utxos
author Braydon Fuller <courier@braydon.com>
date Tue, 05 Apr 2016 10:49:11 -0400
parents 139d221a297c
children 01d5c87c0dae
files src/rpcmisc.cpp
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/rpcmisc.cpp	Mon Apr 04 16:37:43 2016 -0400
+++ b/src/rpcmisc.cpp	Tue Apr 05 10:49:11 2016 -0400
@@ -523,8 +523,16 @@
 
     for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) {
         UniValue output(UniValue::VOBJ);
-        output.push_back(Pair("addressType", (int)it->first.type));
-        output.push_back(Pair("addressHash", it->first.hashBytes.GetHex()));
+        std::string address;
+        if (it->first.type == 2) {
+            address = CBitcoinAddress(CScriptID(it->first.hashBytes)).ToString();
+        } else if (it->first.type == 1) {
+            address = CBitcoinAddress(CKeyID(it->first.hashBytes)).ToString();
+        } else {
+            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type");
+        }
+
+        output.push_back(Pair("address", address));
         output.push_back(Pair("txid", it->first.txhash.GetHex()));
         output.push_back(Pair("outputIndex", it->first.index));
         output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end())));