"<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]);
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);
+ 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)
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);
"newmalleablekey\n"
"Make a malleable public/private key pair.\n");
- CMalleableKey malleableKey;
- malleableKey.MakeNewKeys();
- CMalleablePubKey malleablePubKey = malleableKey.GetMalleablePubKey();
+ if (!fTestNet)
+ throw runtime_error("This feature has been disabled for mainNet clients");
+
+ CMalleableKeyView keyView = pwalletMain->GenerateNewMalleableKey();
+
+ CMalleableKey mKey;
+ if (!pwalletMain->GetMalleableKey(keyView, mKey))
+ throw runtime_error("Unable to generate new malleable key");
+
+ Object result;
+ result.push_back(Pair("PublicPair", mKey.GetMalleablePubKey().ToString()));
+ result.push_back(Pair("KeyView", keyView.ToString()));
- CDataStream ssPublicBytes(SER_NETWORK, PROTOCOL_VERSION);
- ssPublicBytes << malleablePubKey;
+ return result;
+}
+
+Value dumpmalleablekey(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 1)
+ throw runtime_error (
+ "dumpmalleablekey <Key view>\n"
+ "Dump the private and public key pairs, which correspond to provided key view.\n");
+
+ CMalleableKey mKey;
+ CMalleableKeyView keyView;
+ keyView.SetString(params[0].get_str());
+
+ if (!pwalletMain->GetMalleableKey(keyView, mKey))
+ throw runtime_error("There is no such item in the wallet");
Object result;
- result.push_back(Pair("PrivatePair", malleableKey.ToString()));
- result.push_back(Pair("PublicPair", malleablePubKey.ToString()));
- result.push_back(Pair("PublicBytes", HexStr(ssPublicBytes.begin(), ssPublicBytes.end())));
+ result.push_back(Pair("PrivatePair", mKey.ToString()));
+ result.push_back(Pair("PublicPair", mKey.GetMalleablePubKey().ToString()));
return result;
}
result.push_back(Pair("PubkeyVariant", HexStr(vchPubKeyVariant.Raw())));
result.push_back(Pair("KeyVariantID", CBitcoinAddress(vchPubKeyVariant.GetID()).ToString()));
-
return result;
}
-Value listmalleablepubkeys(const Array& params, bool fHelp)
+Value listmalleableviews(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "listmalleablepubkeys\n"
- "Get list of malleable public keys.\n");
+ "listmalleableviews\n"
+ "Get list of views for generated malleable keys.\n");
- std::list<CMalleablePubKey> keyList;
- pwalletMain->ListMalleablePubKeys(keyList);
+ std::list<CMalleableKeyView> keyViewList;
+ pwalletMain->ListMalleableViews(keyViewList);
Array result;
- BOOST_FOREACH(const CMalleablePubKey &key, keyList)
+ BOOST_FOREACH(const CMalleableKeyView &keyView, keyViewList)
{
- result.push_back(key.ToString());
+ result.push_back(keyView.ToString());
}
return result;
}
+