ScriptPubKeyToJSON: include matched key view.
authorCryptoManiac <balthazar@yandex.ru>
Fri, 19 Feb 2016 21:40:43 +0000 (00:40 +0300)
committerCryptoManiac <balthazar@yandex.ru>
Fri, 19 Feb 2016 21:40:43 +0000 (00:40 +0300)
src/keystore.h
src/rpcrawtransaction.cpp

index f03ffb3..eb38ddd 100644 (file)
@@ -70,6 +70,7 @@ public:
     }
 
     virtual bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const =0;
+    virtual bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const =0;
     virtual bool CreatePrivKey(const CPubKey &pubKeyVariant, const CPubKey &R, CKey &privKey) const =0;
     virtual void ListMalleableViews(std::list<CMalleableKeyView> &malleableViewList) const =0;
 };
@@ -160,6 +161,22 @@ public:
         return false;
     }
 
+    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const
+    {
+        {
+            LOCK(cs_KeyStore);
+            for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
+            {
+                if (mi->first.CheckKeyVariant(R, pubKeyVariant))
+                {
+                    view = mi->first;
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     bool CreatePrivKey(const CPubKey &pubKeyVariant, const CPubKey &R, CKey &privKey) const
     {
         {
index 346dcfc..855e9be 100644 (file)
@@ -46,12 +46,18 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
             Solver(scriptPubKey, type, vSolutions);
             out.push_back(Pair("keyVariant", HexStr(vSolutions[0])));
             out.push_back(Pair("R", HexStr(vSolutions[1])));
-        }
 
-        Array a;
-        BOOST_FOREACH(const CTxDestination& addr, addresses)
-            a.push_back(CBitcoinAddress(addr).ToString());
-        out.push_back(Pair("addresses", a));
+            CMalleableKeyView view;
+            if (pwalletMain->CheckOwnership(CPubKey(vSolutions[0]), CPubKey(vSolutions[1]), view))
+                out.push_back(Pair("keyView", view.ToString()));
+        }
+        else
+        {
+            Array a;
+            BOOST_FOREACH(const CTxDestination& addr, addresses)
+                a.push_back(CBitcoinAddress(addr).ToString());
+            out.push_back(Pair("addresses", a));
+        }
     }
     else
     {