"<amount> is a real and is rounded to the nearest " + FormatMoney(nMinimumInputValue)
+ HelpRequiringPassphrase());
- CBitcoinAddress address(params[0].get_str());
- if (!address.IsValid())
+ // Parse address
+ CScript scriptPubKey;
+ string strAddress = params[0].get_str();
+
+ CBitcoinAddress address(strAddress);
+ if (address.IsValid())
+ {
+ if (!address.IsPair())
+ scriptPubKey.SetDestination(address.Get());
+ else
+ {
+ CMalleablePubKey mpk;
+ if (!mpk.setvch(address.GetData()))
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
+
+ CPubKey R, pubKeyVariant;
+ mpk.GetVariant(R, pubKeyVariant);
+ scriptPubKey.SetDestination(R, pubKeyVariant);
+ }
+ }
+ else
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
// Amount
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())
+
+ // Parse address
+ CScript scriptPubKey;
+ string strAddress = params[0].get_str();
+
+ CBitcoinAddress address(strAddress);
+ if (address.IsValid())
+ {
+ if (!address.IsPair())
+ scriptPubKey.SetDestination(address.Get());
+ else
+ {
+ CMalleablePubKey mpk;
+ if (!mpk.setvch(address.GetData()))
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
+
+ CPubKey R, pubKeyVariant;
+ mpk.GetVariant(R, pubKeyVariant);
+ scriptPubKey.SetDestination(R, pubKeyVariant);
+ }
+ }
+ else
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
+
+
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);
ret.push_back(Pair("isvalid", isValid));
if (isValid)
{
- CTxDestination dest = address.Get();
- string currentAddress = address.ToString();
- ret.push_back(Pair("address", currentAddress));
- isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : MINE_NO;
- ret.push_back(Pair("ismine", mine != MINE_NO));
- if (mine != MINE_NO) {
- ret.push_back(Pair("watchonly", mine == MINE_WATCH_ONLY));
- Object detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest);
- ret.insert(ret.end(), detail.begin(), detail.end());
+ if (address.IsPair())
+ {
+ CMalleablePubKey mpk;
+ mpk.setvch(address.GetData());
+ ret.push_back(Pair("ispair", true));
+
+ CMalleableKeyView view;
+ bool isMine = pwalletMain->GetMalleableView(mpk, view);
+ ret.push_back(Pair("ismine", isMine));
+
+ if (isMine)
+ ret.push_back(Pair("KeyView", view.ToString()));
+ }
+ else
+ {
+ CTxDestination dest = address.Get();
+ string currentAddress = address.ToString();
+ ret.push_back(Pair("address", currentAddress));
+ isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : MINE_NO;
+ ret.push_back(Pair("ismine", mine != MINE_NO));
+ if (mine != MINE_NO) {
+ ret.push_back(Pair("watchonly", mine == MINE_WATCH_ONLY));
+ Object detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest);
+ ret.insert(ret.end(), detail.begin(), detail.end());
+ }
+ if (pwalletMain->mapAddressBook.count(dest))
+ ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest]));
}
- if (pwalletMain->mapAddressBook.count(dest))
- ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest]));
}
return ret;
}
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
{
"newmalleablekey\n"
"Make a malleable public/private key pair.\n");
- if (!fTestNet)
+ if (!(fDebug || fTestNet) && GetTime() < SMALLDATA_SWITCH_TIME)
throw runtime_error("This feature has been disabled for mainNet clients");
CMalleableKeyView keyView = pwalletMain->GenerateNewMalleableKey();
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()));
-
- 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");
+ CMalleablePubKey mPubKey = mKey.GetMalleablePubKey();
Object result;
- result.push_back(Pair("PrivatePair", mKey.ToString()));
- result.push_back(Pair("PublicPair", mKey.GetMalleablePubKey().ToString()));
+ result.push_back(Pair("PublicPair", mPubKey.ToString()));
+ result.push_back(Pair("PublicBytes", HexStr(mPubKey.Raw())));
+ result.push_back(Pair("Address", CBitcoinAddress(mPubKey).ToString()));
+ result.push_back(Pair("KeyView", keyView.ToString()));
return result;
}
string pubKeyPair = params[0].get_str();
CMalleablePubKey malleablePubKey;
- if (pubKeyPair.size() == 138) {
- CDataStream ssPublicBytes(ParseHex(pubKeyPair), SER_NETWORK, PROTOCOL_VERSION);
- ssPublicBytes >> malleablePubKey;
+ if (pubKeyPair.size() == 136) {
+ malleablePubKey.setvch(ParseHex(pubKeyPair));
} else
malleablePubKey.SetString(pubKeyPair);