Permalink
Browse files

add rpc command burn

  • Loading branch information...
JohnDolittle committed Mar 14, 2017
1 parent 8e15d99 commit b0bf9eb77c777c42dcdb59f43609ad07117be8ad
Showing with 39 additions and 0 deletions.
  1. +1 −0 src/rpcclient.cpp
  2. +1 −0 src/rpcserver.cpp
  3. +1 −0 src/rpcserver.h
  4. +36 −0 src/rpcwallet.cpp
View
@@ -106,6 +106,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "stop", 0 },
{ "getaddednodeinfo", 0 },
{ "sendtoaddress", 1 },
{ "burn", 1 },
{ "settxfee", 0 },
{ "getreceivedbyaddress", 1 },
{ "getreceivedbyaccount", 1 },
View
@@ -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 },
View
@@ -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);
View
@@ -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)

1 comment on commit b0bf9eb

@joshuajbouw

This comment has been minimized.

Show comment
Hide comment
@joshuajbouw

joshuajbouw Mar 26, 2017

Haha good work =P.

Haha good work =P.

Please sign in to comment.