Commit b0bf9eb7 authored by Pavel Vasin's avatar Pavel Vasin

add rpc command burn

parent 8e15d999
......@@ -106,6 +106,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "stop", 0 },
{ "getaddednodeinfo", 0 },
{ "sendtoaddress", 1 },
{ "burn", 1 },
{ "settxfee", 0 },
{ "getreceivedbyaddress", 1 },
{ "getreceivedbyaccount", 1 },
......
......@@ -256,6 +256,7 @@ static const CRPCCommand vRPCCommands[] =
{ "getaccount", &getaccount, false, false, true },
{ "getaddressesbyaccount", &getaddressesbyaccount, true, false, true },
{ "sendtoaddress", &sendtoaddress, false, false, true },
{ "burn", &burn, false, false, true },
{ "getreceivedbyaddress", &getreceivedbyaddress, false, false, true },
{ "getreceivedbyaccount", &getreceivedbyaccount, false, false, true },
{ "listreceivedbyaddress", &listreceivedbyaddress, false, false, true },
......
......@@ -126,6 +126,7 @@ extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHel
extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value sendtoaddress(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value burn(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value signmessage(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value verifymessage(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getreceivedbyaddress(const json_spirit::Array& params, bool fHelp);
......
......@@ -291,6 +291,42 @@ Value sendtoaddress(const Array& params, bool fHelp)
return wtx.GetHash().GetHex();
}
Value burn(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"burn <amount> [hex string]\n"
"<amount> is a real and is rounded to the nearest 0.00000001"
+ HelpRequiringPassphrase());
CScript scriptPubKey;
if (params.size() > 1) {
vector<unsigned char> data;
if (params[1].get_str().size() > 0){
data = ParseHexV(params[1], "data");
} else {
// Empty data is valid
}
scriptPubKey = CScript() << OP_RETURN << data;
} else {
scriptPubKey = CScript() << OP_RETURN;
}
// Amount
int64_t nAmount = AmountFromValue(params[0]);
if (pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
CWalletTx wtx;
string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx);
if (strError != "")
throw JSONRPCError(RPC_WALLET_ERROR, strError);
return wtx.GetHash().GetHex();
}
Value listaddressgroupings(const Array& params, bool fHelp)
{
if (fHelp)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment