mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
add optional subtract fee argument to sendtomainchain
This commit is contained in:
parent
146808c163
commit
0328059a69
2 changed files with 11 additions and 4 deletions
|
|
@ -137,6 +137,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||||
{ "getmempooldescendants", 1, "verbose" },
|
{ "getmempooldescendants", 1, "verbose" },
|
||||||
{ "bumpfee", 1, "options" },
|
{ "bumpfee", 1, "options" },
|
||||||
{ "testproposedblock", 1, "acceptnonstd" },
|
{ "testproposedblock", 1, "acceptnonstd" },
|
||||||
|
{ "sendtomainchain", 2, "subtractfeefromamount"},
|
||||||
// Echo with conversion (For testing only)
|
// Echo with conversion (For testing only)
|
||||||
{ "echojson", 0, "arg0" },
|
{ "echojson", 0, "arg0" },
|
||||||
{ "echojson", 1, "arg1" },
|
{ "echojson", 1, "arg1" },
|
||||||
|
|
|
||||||
|
|
@ -3446,14 +3446,15 @@ UniValue sendtomainchain(const JSONRPCRequest& request)
|
||||||
if (!EnsureWalletIsAvailable(request.fHelp))
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
|
||||||
if (request.fHelp || request.params.size() != 2)
|
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"sendtomainchain mainchainaddress amount\n"
|
"sendtomainchain mainchainaddress amount ( subtractfeefromamount )\n"
|
||||||
"\nSends sidechain funds to the given mainchain address, through the federated withdraw mechanism\n"
|
"\nSends sidechain funds to the given mainchain address, through the federated withdraw mechanism\n"
|
||||||
+ HelpRequiringPassphrase() +
|
+ HelpRequiringPassphrase() +
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"address\" (string, required) The destination address on Bitcoin mainchain\n"
|
"1. \"address\" (string, required) The destination address on Bitcoin mainchain\n"
|
||||||
"2. \"amount\" (numeric, required) The amount being sent to Bitcoin mainchain\n"
|
"2. \"amount\" (numeric, required) The amount being sent to Bitcoin mainchain\n"
|
||||||
|
"3. \"subtractfeefromamount\" (boolean, optional, default=false) The fee will be deducted from the amount being pegged-out.\n"
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
"\"txid\" (string) Transaction ID of the resulting sidechain transaction\n"
|
"\"txid\" (string) Transaction ID of the resulting sidechain transaction\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
|
|
@ -3473,6 +3474,11 @@ UniValue sendtomainchain(const JSONRPCRequest& request)
|
||||||
if (nAmount <= 0)
|
if (nAmount <= 0)
|
||||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
|
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
|
||||||
|
|
||||||
|
bool subtract_fee = false;
|
||||||
|
if (request.params.size() > 2) {
|
||||||
|
subtract_fee = request.params[2].get_bool();
|
||||||
|
}
|
||||||
|
|
||||||
// Parse Bitcoin address for destination, embed script
|
// Parse Bitcoin address for destination, embed script
|
||||||
CScript scriptPubKeyMainchain(GetScriptForDestination(address.Get()));
|
CScript scriptPubKeyMainchain(GetScriptForDestination(address.Get()));
|
||||||
|
|
||||||
|
|
@ -3487,7 +3493,7 @@ UniValue sendtomainchain(const JSONRPCRequest& request)
|
||||||
EnsureWalletIsUnlocked();
|
EnsureWalletIsUnlocked();
|
||||||
|
|
||||||
CWalletTx wtxNew;
|
CWalletTx wtxNew;
|
||||||
SendMoney(scriptPubKey, nAmount, Params().GetConsensus().pegged_asset, false, CPubKey(), wtxNew, true);
|
SendMoney(scriptPubKey, nAmount, Params().GetConsensus().pegged_asset, subtract_fee, CPubKey(), wtxNew, true);
|
||||||
|
|
||||||
std::string blinds;
|
std::string blinds;
|
||||||
for (unsigned int i=0; i<wtxNew.tx->vout.size(); i++) {
|
for (unsigned int i=0; i<wtxNew.tx->vout.size(); i++) {
|
||||||
|
|
@ -4118,7 +4124,7 @@ static const CRPCCommand commands[] =
|
||||||
{ "wallet", "setaccount", &setaccount, true, {"address","account"} },
|
{ "wallet", "setaccount", &setaccount, true, {"address","account"} },
|
||||||
{ "wallet", "reissueasset", &reissueasset, true, {"asset", "assetamount"} },
|
{ "wallet", "reissueasset", &reissueasset, true, {"asset", "assetamount"} },
|
||||||
{ "wallet", "signblock", &signblock, true, {} },
|
{ "wallet", "signblock", &signblock, true, {} },
|
||||||
{ "wallet", "sendtomainchain", &sendtomainchain, false, {} },
|
{ "wallet", "sendtomainchain", &sendtomainchain, false, {"address", "amount", "subtractfeefromamount"} },
|
||||||
{ "wallet", "destroyamount", &destroyamount, false, {"asset", "amount", "comment"} },
|
{ "wallet", "destroyamount", &destroyamount, false, {"asset", "amount", "comment"} },
|
||||||
{ "wallet", "settxfee", &settxfee, true, {"amount"} },
|
{ "wallet", "settxfee", &settxfee, true, {"amount"} },
|
||||||
{ "wallet", "signmessage", &signmessage, true, {"address","message"} },
|
{ "wallet", "signmessage", &signmessage, true, {"address","message"} },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue