Added sendtoaddressix for api IX support

This commit is contained in:
Evan Duffield 2015-07-30 11:33:37 -07:00
parent ebc2591e4b
commit 5024b7d3f6
6 changed files with 53 additions and 3 deletions

View File

@ -75,7 +75,7 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s
}
//if we're syncing we won't have instantX information, so accept 1 confirmation
if(conf >= BUDGET_FEE_CONFIRMATIONS || (!masternodeSync.IsSynced() && conf >= 1)){
if(conf >= BUDGET_FEE_CONFIRMATIONS){
return true;
} else {
strError = strprintf("Collateral requires at least %d confirmations - %d confirmations", BUDGET_FEE_CONFIRMATIONS, conf);

View File

@ -33,6 +33,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "getnetworkhashps", 0 },
{ "getnetworkhashps", 1 },
{ "sendtoaddress", 1 },
{ "sendtoaddressix", 1 },
{ "settxfee", 0 },
{ "getreceivedbyaddress", 1 },
{ "getreceivedbyaccount", 1 },

View File

@ -176,6 +176,10 @@ Value mnbudget(const Array& params, bool fHelp)
return "Proposal FeeTX is not valid - " + hash.ToString() + " - " + strError;
}
if(!masternodeSync.IsSynced()){
return "Must wait for client to sync with masternode network. Try again in a minute or so.";
}
if(!budgetProposalBroadcast.IsValid(strError)){
return "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + strError;
}

View File

@ -352,6 +352,7 @@ static const CRPCCommand vRPCCommands[] =
{ "wallet", "sendfrom", &sendfrom, false, false, true },
{ "wallet", "sendmany", &sendmany, false, false, true },
{ "wallet", "sendtoaddress", &sendtoaddress, false, false, true },
{ "wallet", "sendtoaddressix", &sendtoaddressix, false, false, true },
{ "wallet", "setaccount", &setaccount, true, false, true },
{ "wallet", "settxfee", &settxfee, true, false, true },
{ "wallet", "signmessage", &signmessage, true, false, true },

View File

@ -169,6 +169,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 sendtoaddressix(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 File

@ -312,7 +312,7 @@ Value getaddressesbyaccount(const Array& params, bool fHelp)
return ret;
}
void SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew)
void SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew, bool fUseIX=false)
{
// Check amount
if (nValue <= 0)
@ -335,7 +335,7 @@ void SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew)
// Create and send the transaction
CReserveKey reservekey(pwalletMain);
CAmount nFeeRequired;
if (!pwalletMain->CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError))
if (!pwalletMain->CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError, NULL, ALL_COINS, fUseIX, (CAmount)0))
{
if (nValue + nFeeRequired > pwalletMain->GetBalance())
strError = strprintf("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!", FormatMoney(nFeeRequired));
@ -390,6 +390,49 @@ Value sendtoaddress(const Array& params, bool fHelp)
return wtx.GetHash().GetHex();
}
Value sendtoaddressix(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 4)
throw runtime_error(
"sendtoaddressix \"dashaddress\" amount ( \"comment\" \"comment-to\" )\n"
"\nSend an amount to a given address. The amount is a real and is rounded to the nearest 0.00000001\n"
+ HelpRequiringPassphrase() +
"\nArguments:\n"
"1. \"dashaddress\" (string, required) The dash address to send to.\n"
"2. \"amount\" (numeric, required) The amount in btc to send. eg 0.1\n"
"3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n"
" This is not part of the transaction, just kept in your wallet.\n"
"4. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n"
" to which you're sending the transaction. This is not part of the \n"
" transaction, just kept in your wallet.\n"
"\nResult:\n"
"\"transactionid\" (string) The transaction id.\n"
"\nExamples:\n"
+ HelpExampleCli("sendtoaddressix", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\" 0.1")
+ HelpExampleCli("sendtoaddressix", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\" 0.1 \"donation\" \"seans outpost\"")
+ HelpExampleRpc("sendtoaddressix", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\", 0.1, \"donation\", \"seans outpost\"")
);
CBitcoinAddress address(params[0].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Dash address");
// Amount
CAmount nAmount = AmountFromValue(params[1]);
// Wallet comments
CWalletTx wtx;
if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty())
wtx.mapValue["comment"] = params[2].get_str();
if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
wtx.mapValue["to"] = params[3].get_str();
EnsureWalletIsUnlocked();
SendMoney(address.Get(), nAmount, wtx, true);
return wtx.GetHash().GetHex();
}
Value listaddressgroupings(const Array& params, bool fHelp)
{
if (fHelp)