X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Frpcwallet.cpp;h=0c27a90eb6e70875585a835ad800c5cbcf8435a4;hb=8df93a092b9d9610e52c8405fe0b43374e9fba6f;hp=ca64fff8c543926967a1472cba586262e981bc5c;hpb=a494e1c51c7f54ba353b02a7e470b0df0c0e7bbe;p=novacoin.git diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index ca64fff..0c27a90 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -323,9 +323,23 @@ Value sendtoaddress(const Array& params, bool fHelp) " 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,10 +357,6 @@ 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."); - // Parse Bitcoin address - CScript scriptPubKey; - scriptPubKey.SetDestination(address.Get()); - string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx); if (strError != "") throw JSONRPCError(RPC_WALLET_ERROR, strError); @@ -699,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) @@ -725,10 +751,6 @@ Value sendfrom(const Array& params, bool fHelp) if (nAmount > nBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); - // Parse Bitcoin address - CScript scriptPubKey; - scriptPubKey.SetDestination(address.Get()); - // Send string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx); if (strError != "") @@ -1763,7 +1785,7 @@ Value reservebalance(const Array& params, bool fHelp) nAmount = (nAmount / CENT) * CENT; // round to cent if (nAmount < 0) throw runtime_error("amount cannot be negative.\n"); - mapArgs["-reservebalance"] = FormatMoney(nAmount).c_str(); + mapArgs["-reservebalance"] = FormatMoney(nAmount); } else { @@ -1874,7 +1896,7 @@ Value newmalleablekey(const Array& params, bool fHelp) "newmalleablekey\n" "Make a malleable public/private key pair.\n"); - if (!fTestNet) + if (!fTestNet && GetTime() < SMALLDATA_SWITCH_TIME) throw runtime_error("This feature has been disabled for mainNet clients"); CMalleableKeyView keyView = pwalletMain->GenerateNewMalleableKey();