Merge pull request #279 from svost/patch
authorCryptoManiac <CryptoManiac@users.noreply.github.com>
Sat, 20 Feb 2016 06:17:59 +0000 (09:17 +0300)
committerCryptoManiac <CryptoManiac@users.noreply.github.com>
Sat, 20 Feb 2016 06:17:59 +0000 (09:17 +0300)
Minor fix

doc/MalleableKeysRawTx.txt [new file with mode: 0644]
src/keystore.h
src/protocol.h
src/rpcrawtransaction.cpp
src/rpcwallet.cpp
src/script.cpp
src/script.h
src/util.cpp
src/wallet.cpp
src/wallet.h

diff --git a/doc/MalleableKeysRawTx.txt b/doc/MalleableKeysRawTx.txt
new file mode 100644 (file)
index 0000000..66e08af
--- /dev/null
@@ -0,0 +1,91 @@
+> createrawtransaction '[{"txid" : "fe19e91308bc7d5e564d51d3401c40b47e18fb4abb713be2c75e517f9607e8c0","vout" : 0}, {"txid" : "ffb6281239fa8b882188aa9b53ce9c753592ce5db9ed360b95cf96fca14ff7c3","vout" : 0}, {"txid" : "fe9373cce4729f1e75092f9b85843bb5cad96e7fec4af728fb36f4f7d068044a","vout" : 0}]' '{"5GRatXVWnTHNjBaeLCw6TEqdYhMqDuej5n2aQJxoJj65bMMQvxDnnhCg6PEhCassbnSBrNpzWZu4YaLy13y8jLsUJz6ta5ad1c6" : 50, "5GRatXVWnTHNjBaeLCw6TEqdYhMqDuej5n2aQJxoJj65bMMQvxDnnhCg6PEhCassbnSBrNpzWZu4YaLy13y8jLsUJz6ta5ad1c6" : 50, "5GRatXVWnTHNjBaeLCw6TEqdYhMqDuej5n2aQJxoJj65bMMQvxDnnhCg6PEhCassbnSBrNpzWZu4YaLy13y8jLsUJz6ta5ad1c6" : 50, "5GRatXVWnTHNjBaeLCw6TEqdYhMqDuej5n2aQJxoJj65bMMQvxDnnhCg6PEhCassbnSBrNpzWZu4YaLy13y8jLsUJz6ta5ad1c6" : 50}'
+01000000ec7ac75603c0e807967f515ec7e23b71bb4afb187eb4401c40d3514d565e7dbc0813e919fe0000000000ffffffffc3f74fa1fc96cf950b36edb95dce9235759cce539baa8821888bfa391228b6ff0000000000ffffffff4a0468d0f7f436fb28f74aec7f6ed9cab53b84859b2f09751e9f72e4cc7393fe0000000000ffffffff0480f0fa02000000004621023465cd42efb1e62f0d74d4c968fa421fa900d46a87f91374a4f2cec16c61df072102cac2526421051d91daefa199277d2119ca0e447cff3a4136cb1e5326ea31e99175ac80f0fa020000000046210286ba58eef592aa6e883676445cb2e0797ebf221731caf57d5382f6ba7d04862a2102f1c4a308096f0484db4a5ca2297929f4c8b32a9e91d15d09c0c366f314835b7b75ac80f0fa02000000004621039c4ca9434cbcd65b0646b86302eadf2c22ba5e726a8c62bb413420a891f76a902102b5c6ad4ab2a017912bbb5923d3f00d0e93f486d6879bf1b284faca7c1e2f9fdd75ac80f0fa020000000046210227f68a9f13dbba130c3930f0d2ce90138135d7bea038264500e2188803af376821023343909069b8520a3a362b2b6ce70d3cd651f2c2e0119eaf3c6b410d3bd7cec075ac00000000
+
+> signrawtransaction 01000000ec7ac75603c0e807967f515ec7e23b71bb4afb187eb4401c40d3514d565e7dbc0813e919fe0000000000ffffffffc3f74fa1fc96cf950b36edb95dce9235759cce539baa8821888bfa391228b6ff0000000000ffffffff4a0468d0f7f436fb28f74aec7f6ed9cab53b84859b2f09751e9f72e4cc7393fe0000000000ffffffff0480f0fa02000000004621023465cd42efb1e62f0d74d4c968fa421fa900d46a87f91374a4f2cec16c61df072102cac2526421051d91daefa199277d2119ca0e447cff3a4136cb1e5326ea31e99175ac80f0fa020000000046210286ba58eef592aa6e883676445cb2e0797ebf221731caf57d5382f6ba7d04862a2102f1c4a308096f0484db4a5ca2297929f4c8b32a9e91d15d09c0c366f314835b7b75ac80f0fa02000000004621039c4ca9434cbcd65b0646b86302eadf2c22ba5e726a8c62bb413420a891f76a902102b5c6ad4ab2a017912bbb5923d3f00d0e93f486d6879bf1b284faca7c1e2f9fdd75ac80f0fa020000000046210227f68a9f13dbba130c3930f0d2ce90138135d7bea038264500e2188803af376821023343909069b8520a3a362b2b6ce70d3cd651f2c2e0119eaf3c6b410d3bd7cec075ac00000000
+{
+"hex" : "01000000ec7ac75603c0e807967f515ec7e23b71bb4afb187eb4401c40d3514d565e7dbc0813e919fe000000006a47304402206ae066f932568244b300207516941ec1ed3c1d1d073a64e73b030d648a873ba0022066cd2972fc33ccd72fbf2851926671cef3162a31c1b8d3fa54d5c1f48e64ddaa012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffffc3f74fa1fc96cf950b36edb95dce9235759cce539baa8821888bfa391228b6ff000000006b483045022100ac66cd8c20df9cf83efe16f0d5e8e4c120289b48d4599f74f240e75e63fabbf202207a479da48b723ca44ec7da49564642c53a01316be5e8e1f6faf54747df6cd471012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffff4a0468d0f7f436fb28f74aec7f6ed9cab53b84859b2f09751e9f72e4cc7393fe000000006a47304402202ecf35bf1aaa054db9cecbdb078a42a596bb58cfafe73a51910851799f6596fe022040dbae44820144d6c099fcdd077a29beb56ccbfa0be6a1173810bf7566981a8a012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffff0480f0fa02000000004621023465cd42efb1e62f0d74d4c968fa421fa900d46a87f91374a4f2cec16c61df072102cac2526421051d91daefa199277d2119ca0e447cff3a4136cb1e5326ea31e99175ac80f0fa020000000046210286ba58eef592aa6e883676445cb2e0797ebf221731caf57d5382f6ba7d04862a2102f1c4a308096f0484db4a5ca2297929f4c8b32a9e91d15d09c0c366f314835b7b75ac80f0fa02000000004621039c4ca9434cbcd65b0646b86302eadf2c22ba5e726a8c62bb413420a891f76a902102b5c6ad4ab2a017912bbb5923d3f00d0e93f486d6879bf1b284faca7c1e2f9fdd75ac80f0fa020000000046210227f68a9f13dbba130c3930f0d2ce90138135d7bea038264500e2188803af376821023343909069b8520a3a362b2b6ce70d3cd651f2c2e0119eaf3c6b410d3bd7cec075ac00000000",
+"complete" : true
+}
+
+> sendrawtransaction 01000000ec7ac75603c0e807967f515ec7e23b71bb4afb187eb4401c40d3514d565e7dbc0813e919fe000000006a47304402206ae066f932568244b300207516941ec1ed3c1d1d073a64e73b030d648a873ba0022066cd2972fc33ccd72fbf2851926671cef3162a31c1b8d3fa54d5c1f48e64ddaa012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffffc3f74fa1fc96cf950b36edb95dce9235759cce539baa8821888bfa391228b6ff000000006b483045022100ac66cd8c20df9cf83efe16f0d5e8e4c120289b48d4599f74f240e75e63fabbf202207a479da48b723ca44ec7da49564642c53a01316be5e8e1f6faf54747df6cd471012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffff4a0468d0f7f436fb28f74aec7f6ed9cab53b84859b2f09751e9f72e4cc7393fe000000006a47304402202ecf35bf1aaa054db9cecbdb078a42a596bb58cfafe73a51910851799f6596fe022040dbae44820144d6c099fcdd077a29beb56ccbfa0be6a1173810bf7566981a8a012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffff0480f0fa02000000004621023465cd42efb1e62f0d74d4c968fa421fa900d46a87f91374a4f2cec16c61df072102cac2526421051d91daefa199277d2119ca0e447cff3a4136cb1e5326ea31e99175ac80f0fa020000000046210286ba58eef592aa6e883676445cb2e0797ebf221731caf57d5382f6ba7d04862a2102f1c4a308096f0484db4a5ca2297929f4c8b32a9e91d15d09c0c366f314835b7b75ac80f0fa02000000004621039c4ca9434cbcd65b0646b86302eadf2c22ba5e726a8c62bb413420a891f76a902102b5c6ad4ab2a017912bbb5923d3f00d0e93f486d6879bf1b284faca7c1e2f9fdd75ac80f0fa020000000046210227f68a9f13dbba130c3930f0d2ce90138135d7bea038264500e2188803af376821023343909069b8520a3a362b2b6ce70d3cd651f2c2e0119eaf3c6b410d3bd7cec075ac00000000
+3835044e34803034aba65613925d424996237e97bc18a7649f550a5038bc3ce1
+
+> getrawtransaction 3835044e34803034aba65613925d424996237e97bc18a7649f550a5038bc3ce1 1
+{
+"hex" : "01000000ec7ac75603c0e807967f515ec7e23b71bb4afb187eb4401c40d3514d565e7dbc0813e919fe000000006a47304402206ae066f932568244b300207516941ec1ed3c1d1d073a64e73b030d648a873ba0022066cd2972fc33ccd72fbf2851926671cef3162a31c1b8d3fa54d5c1f48e64ddaa012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffffc3f74fa1fc96cf950b36edb95dce9235759cce539baa8821888bfa391228b6ff000000006b483045022100ac66cd8c20df9cf83efe16f0d5e8e4c120289b48d4599f74f240e75e63fabbf202207a479da48b723ca44ec7da49564642c53a01316be5e8e1f6faf54747df6cd471012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffff4a0468d0f7f436fb28f74aec7f6ed9cab53b84859b2f09751e9f72e4cc7393fe000000006a47304402202ecf35bf1aaa054db9cecbdb078a42a596bb58cfafe73a51910851799f6596fe022040dbae44820144d6c099fcdd077a29beb56ccbfa0be6a1173810bf7566981a8a012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbeaffffffff0480f0fa02000000004621023465cd42efb1e62f0d74d4c968fa421fa900d46a87f91374a4f2cec16c61df072102cac2526421051d91daefa199277d2119ca0e447cff3a4136cb1e5326ea31e99175ac80f0fa020000000046210286ba58eef592aa6e883676445cb2e0797ebf221731caf57d5382f6ba7d04862a2102f1c4a308096f0484db4a5ca2297929f4c8b32a9e91d15d09c0c366f314835b7b75ac80f0fa02000000004621039c4ca9434cbcd65b0646b86302eadf2c22ba5e726a8c62bb413420a891f76a902102b5c6ad4ab2a017912bbb5923d3f00d0e93f486d6879bf1b284faca7c1e2f9fdd75ac80f0fa020000000046210227f68a9f13dbba130c3930f0d2ce90138135d7bea038264500e2188803af376821023343909069b8520a3a362b2b6ce70d3cd651f2c2e0119eaf3c6b410d3bd7cec075ac00000000",
+"txid" : "3835044e34803034aba65613925d424996237e97bc18a7649f550a5038bc3ce1",
+"version" : 1,
+"time" : 1455913708,
+"locktime" : 0,
+"vin" : [
+{
+"txid" : "fe19e91308bc7d5e564d51d3401c40b47e18fb4abb713be2c75e517f9607e8c0",
+"vout" : 0,
+"scriptSig" : {
+"asm" : "304402206ae066f932568244b300207516941ec1ed3c1d1d073a64e73b030d648a873ba0022066cd2972fc33ccd72fbf2851926671cef3162a31c1b8d3fa54d5c1f48e64ddaa01 02a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbea",
+"hex" : "47304402206ae066f932568244b300207516941ec1ed3c1d1d073a64e73b030d648a873ba0022066cd2972fc33ccd72fbf2851926671cef3162a31c1b8d3fa54d5c1f48e64ddaa012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbea"
+},
+"sequence" : 4294967295
+},
+{
+"txid" : "ffb6281239fa8b882188aa9b53ce9c753592ce5db9ed360b95cf96fca14ff7c3",
+"vout" : 0,
+"scriptSig" : {
+"asm" : "3045022100ac66cd8c20df9cf83efe16f0d5e8e4c120289b48d4599f74f240e75e63fabbf202207a479da48b723ca44ec7da49564642c53a01316be5e8e1f6faf54747df6cd47101 02a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbea",
+"hex" : "483045022100ac66cd8c20df9cf83efe16f0d5e8e4c120289b48d4599f74f240e75e63fabbf202207a479da48b723ca44ec7da49564642c53a01316be5e8e1f6faf54747df6cd471012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbea"
+},
+"sequence" : 4294967295
+},
+{
+"txid" : "fe9373cce4729f1e75092f9b85843bb5cad96e7fec4af728fb36f4f7d068044a",
+"vout" : 0,
+"scriptSig" : {
+"asm" : "304402202ecf35bf1aaa054db9cecbdb078a42a596bb58cfafe73a51910851799f6596fe022040dbae44820144d6c099fcdd077a29beb56ccbfa0be6a1173810bf7566981a8a01 02a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbea",
+"hex" : "47304402202ecf35bf1aaa054db9cecbdb078a42a596bb58cfafe73a51910851799f6596fe022040dbae44820144d6c099fcdd077a29beb56ccbfa0be6a1173810bf7566981a8a012102a277f7eece96158bb86879b887adb3d5ad1ae2caf333633f41931687a95cdbea"
+},
+"sequence" : 4294967295
+}
+],
+"vout" : [
+{
+"value" : 50.00000000,
+"n" : 0,
+"scriptPubKey" : {
+"asm" : "023465cd42efb1e62f0d74d4c968fa421fa900d46a87f91374a4f2cec16c61df07 02cac2526421051d91daefa199277d2119ca0e447cff3a4136cb1e5326ea31e991 OP_DROP OP_CHECKSIG",
+"hex" : "21023465cd42efb1e62f0d74d4c968fa421fa900d46a87f91374a4f2cec16c61df072102cac2526421051d91daefa199277d2119ca0e447cff3a4136cb1e5326ea31e99175ac",
+"type" : "pubkeydrop"
+}
+},
+{
+"value" : 50.00000000,
+"n" : 1,
+"scriptPubKey" : {
+"asm" : "0286ba58eef592aa6e883676445cb2e0797ebf221731caf57d5382f6ba7d04862a 02f1c4a308096f0484db4a5ca2297929f4c8b32a9e91d15d09c0c366f314835b7b OP_DROP OP_CHECKSIG",
+"hex" : "210286ba58eef592aa6e883676445cb2e0797ebf221731caf57d5382f6ba7d04862a2102f1c4a308096f0484db4a5ca2297929f4c8b32a9e91d15d09c0c366f314835b7b75ac",
+"type" : "pubkeydrop"
+}
+},
+{
+"value" : 50.00000000,
+"n" : 2,
+"scriptPubKey" : {
+"asm" : "039c4ca9434cbcd65b0646b86302eadf2c22ba5e726a8c62bb413420a891f76a90 02b5c6ad4ab2a017912bbb5923d3f00d0e93f486d6879bf1b284faca7c1e2f9fdd OP_DROP OP_CHECKSIG",
+"hex" : "21039c4ca9434cbcd65b0646b86302eadf2c22ba5e726a8c62bb413420a891f76a902102b5c6ad4ab2a017912bbb5923d3f00d0e93f486d6879bf1b284faca7c1e2f9fdd75ac",
+"type" : "pubkeydrop"
+}
+},
+{
+"value" : 50.00000000,
+"n" : 3,
+"scriptPubKey" : {
+"asm" : "0227f68a9f13dbba130c3930f0d2ce90138135d7bea038264500e2188803af3768 023343909069b8520a3a362b2b6ce70d3cd651f2c2e0119eaf3c6b410d3bd7cec0 OP_DROP OP_CHECKSIG",
+"hex" : "210227f68a9f13dbba130c3930f0d2ce90138135d7bea038264500e2188803af376821023343909069b8520a3a362b2b6ce70d3cd651f2c2e0119eaf3c6b410d3bd7cec075ac",
+"type" : "pubkeydrop"
+}
+}
+],
+"blockhash" : "00006b9e0ba9faadf6fdf86123789d58c828cbd61565edcf7a46b9eaf87086d2",
+"confirmations" : 16,
+"time" : 1455913743,
+"blocktime" : 1455913743
+}
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 b4ebac6..ece6184 100644 (file)
@@ -17,9 +17,9 @@
 #include "uint256.h"
 
 extern bool fTestNet;
-static inline unsigned short GetDefaultPort(const bool testnet = fTestNet)
+inline unsigned short GetDefaultPort()
 {
-    return static_cast<unsigned short>(testnet ? 17777 : 7777);
+    return static_cast<unsigned short>(fTestNet ? 17777 : 7777);
 }
 
 
index fd40d5f..855e9be 100644 (file)
@@ -40,10 +40,24 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
         out.push_back(Pair("reqSigs", nRequired));
         out.push_back(Pair("type", GetTxnOutputType(type)));
 
-        Array a;
-        BOOST_FOREACH(const CTxDestination& addr, addresses)
-            a.push_back(CBitcoinAddress(addr).ToString());
-        out.push_back(Pair("addresses", a));
+        if (type == TX_PUBKEY_DROP)
+        {
+            vector<valtype> vSolutions;
+            Solver(scriptPubKey, type, vSolutions);
+            out.push_back(Pair("keyVariant", HexStr(vSolutions[0])));
+            out.push_back(Pair("R", HexStr(vSolutions[1])));
+
+            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
     {
@@ -276,16 +290,27 @@ Value createrawtransaction(const Array& params, bool fHelp)
     set<CBitcoinAddress> setAddress;
     BOOST_FOREACH(const Pair& s, sendTo)
     {
+        // Create output destination script
+        CScript scriptPubKey;
         CBitcoinAddress address(s.name_);
         if (!address.IsValid())
-            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid NovaCoin address: ")+s.name_);
+        {
+            CMalleablePubKey mpk(s.name_);
+            if (!mpk.IsValid())
+                throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid output destination: ")+s.name_);
 
-        if (setAddress.count(address))
-            throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_);
-        setAddress.insert(address);
+            CPubKey keyVariant, R;
+            mpk.GetVariant(R, keyVariant);
+            scriptPubKey.SetDestination(R, keyVariant);
+        }
+        else
+        {
+            scriptPubKey.SetDestination(address.Get());
+            if (setAddress.count(address))
+                throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_);
+            setAddress.insert(address);
+        }
 
-        CScript scriptPubKey;
-        scriptPubKey.SetDestination(address.Get());
         int64_t nAmount = AmountFromValue(s.value_);
 
         CTxOut out(nAmount, scriptPubKey);
index 8b3780e..1353149 100644 (file)
@@ -323,9 +323,23 @@ Value sendtoaddress(const Array& params, bool fHelp)
             "<amount> is a real and is rounded to the nearest " + FormatMoney(nMinimumInputValue)
             + HelpRequiringPassphrase());
 
-    CBitcoinAddress address(params[0].get_str());
-    if (!address.IsValid())
-        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
+    // Parse address
+    CScript scriptPubKey;
+    string strAddress = params[0].get_str();
+
+    CBitcoinAddress address(strAddress);
+    if (address.IsValid())
+        scriptPubKey.SetDestination(address.Get());
+    else
+    {
+        CMalleablePubKey mpk(strAddress);
+        if (!mpk.IsValid())
+            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
+
+        CPubKey R, pubKeyVariant;
+        mpk.GetVariant(R, pubKeyVariant);
+        scriptPubKey.SetDestination(R, pubKeyVariant);
+    }
 
     // Amount
     int64_t nAmount = AmountFromValue(params[1]);
@@ -343,7 +357,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
     if (pwalletMain->IsLocked())
         throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
 
-    string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx);
+    string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx);
     if (strError != "")
         throw JSONRPCError(RPC_WALLET_ERROR, strError);
 
@@ -695,9 +709,25 @@ Value sendfrom(const Array& params, bool fHelp)
             + HelpRequiringPassphrase());
 
     string strAccount = AccountFromValue(params[0]);
-    CBitcoinAddress address(params[1].get_str());
-    if (!address.IsValid())
-        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
+
+    // Parse address
+    CScript scriptPubKey;
+    string strAddress = params[0].get_str();
+
+    CBitcoinAddress address(strAddress);
+    if (address.IsValid())
+        scriptPubKey.SetDestination(address.Get());
+    else
+    {
+        CMalleablePubKey mpk(strAddress);
+        if (!mpk.IsValid())
+            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
+
+        CPubKey R, pubKeyVariant;
+        mpk.GetVariant(R, pubKeyVariant);
+        scriptPubKey.SetDestination(R, pubKeyVariant);
+    }
+
     int64_t nAmount = AmountFromValue(params[2]);
 
     if (nAmount < nMinimumInputValue)
@@ -722,7 +752,7 @@ Value sendfrom(const Array& params, bool fHelp)
         throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
 
     // Send
-    string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx);
+    string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx);
     if (strError != "")
         throw JSONRPCError(RPC_WALLET_ERROR, strError);
 
index 26b7c94..c7c2b29 100644 (file)
@@ -1195,7 +1195,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
         // Standard tx, sender provides pubkey, receiver adds signature
         mTemplates.insert(make_pair(TX_PUBKEY, CScript() << OP_PUBKEY << OP_CHECKSIG));
 
-        if (GetTime() > SMALLDATA_SWITCH_TIME)
+        if (fTestNet || GetTime() > SMALLDATA_SWITCH_TIME)
         {
             // Malleable pubkey tx hack, sender provides generated pubkey combined with R parameter. The R parameter is dropped before checking a signature.
             mTemplates.insert(make_pair(TX_PUBKEY_DROP, CScript() << OP_PUBKEY << OP_PUBKEY << OP_DROP << OP_CHECKSIG));
@@ -1507,14 +1507,9 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
     case TX_PUBKEY_DROP:
         {
             CPubKey key = CPubKey(vSolutions[0]);
-            if (keystore.HaveKey(key.GetID()))
+            CPubKey R = CPubKey(vSolutions[1]);
+            if (keystore.CheckOwnership(key, R))
                 return MINE_SPENDABLE;
-            else
-            {
-                CPubKey R = CPubKey(vSolutions[1]);
-                if (keystore.CheckOwnership(key, R))
-                    return MINE_SPENDABLE;
-            }
         }
         break;
     case TX_PUBKEYHASH:
@@ -1559,7 +1554,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
     if (!Solver(scriptPubKey, whichType, vSolutions))
         return false;
 
-    if (whichType == TX_PUBKEY || whichType == TX_PUBKEY_DROP)
+    if (whichType == TX_PUBKEY)
     {
         addressRet = CPubKey(vSolutions[0]).GetID();
         return true;
@@ -1624,7 +1619,10 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
     if (!Solver(scriptPubKey, typeRet, vSolutions))
         return false;
     if (typeRet == TX_NULL_DATA)
+    {
+        nRequiredRet = 0;
         return true;
+    }
 
     if (typeRet == TX_MULTISIG)
     {
@@ -1638,6 +1636,8 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
     else
     {
         nRequiredRet = 1;
+        if (typeRet == TX_PUBKEY_DROP)
+            return true;
         CTxDestination address;
         if (!ExtractDestination(scriptPubKey, address))
            return false;
@@ -1972,6 +1972,13 @@ void CScript::SetDestination(const CTxDestination& dest)
     boost::apply_visitor(CScriptVisitor(this), dest);
 }
 
+void CScript::SetDestination(const CPubKey& R, CPubKey& pubKeyVariant)
+{
+    this->clear();
+    *this << pubKeyVariant << R << OP_DROP << OP_CHECKSIG;
+}
+
+
 void CScript::SetMultisig(int nRequired, const std::vector<CKey>& keys)
 {
     this->clear();
index 4896630..ef13bf4 100644 (file)
@@ -557,6 +557,7 @@ public:
     bool HasCanonicalPushes() const;
 
     void SetDestination(const CTxDestination& address);
+    void SetDestination(const CPubKey& R, CPubKey& pubKeyVariant);
     void SetMultisig(int nRequired, const std::vector<CKey>& keys);
 
 
index 7fb43bc..73621d8 100644 (file)
@@ -1180,13 +1180,11 @@ void createConf()
     pConf << "rpcuser=user\nrpcpassword="
             + randomStrGen(15)
             + "\nrpcport=8344"
-            + "\nport=7777"
             + "\n#(0=off, 1=on) daemon - run in the background as a daemon and accept commands"
             + "\ndaemon=0"
             + "\n#(0=off, 1=on) server - accept command line and JSON-RPC commands"
             + "\nserver=0"
-            + "\nrpcallowip=127.0.0.1"
-            + "\ntestnet=0";
+            + "\nrpcallowip=127.0.0.1";
     pConf.close();
 }
 
index 5c46a1b..5eed75c 100644 (file)
@@ -2101,6 +2101,12 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
 
 string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee)
 {
+    // Check amount
+    if (nValue <= 0)
+        return _("Invalid amount");
+    if (nValue + nTransactionFee > GetBalance())
+        return _("Insufficient funds");
+
     CReserveKey reservekey(this);
     int64_t nFeeRequired;
 
@@ -2136,26 +2142,6 @@ string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNe
     return "";
 }
 
-
-
-string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee)
-{
-    // Check amount
-    if (nValue <= 0)
-        return _("Invalid amount");
-    if (nValue + nTransactionFee > GetBalance())
-        return _("Insufficient funds");
-
-    // Parse Bitcoin address
-    CScript scriptPubKey;
-    scriptPubKey.SetDestination(address);
-
-    return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee);
-}
-
-
-
-
 DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
 {
     if (!fFileBacked)
index 20abe44..bc8afa8 100644 (file)
@@ -229,7 +229,6 @@ public:
     bool MergeCoins(const int64_t& nAmount, const int64_t& nMinValue, const int64_t& nMaxValue, std::list<uint256>& listMerged);
 
     std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);
-    std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);
 
     bool NewKeyPool(unsigned int nSize = 0);
     bool TopUpKeyPool(unsigned int nSize = 0);