X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Frpcwallet.cpp;h=ed024a562c75112874a27562e97fb970ba8a6196;hp=8558036db62cb2c0e0d760bebbdb28cc4bfb1bcf;hb=9167b228998e353585d2d5e45826d57dfddf534e;hpb=16646cd1afb50399fbe867f1e9590e58c6f1a792 diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 8558036..ed024a5 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -255,6 +255,53 @@ Value getaddressesbyaccount(const Array& params, bool fHelp) return ret; } +Value mergecoins(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 3) + throw runtime_error( + "mergecoins \n" + " is resulting inputs sum\n" + " is resulting value of inputs which will be created\n" + " is maximum value of inputs which are used in join process\n" + "All values are real and and rounded to the nearest " + FormatMoney(MIN_TXOUT_AMOUNT) + + HelpRequiringPassphrase()); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + + // Amount + int64 nAmount = AmountFromValue(params[0]); + + // Amount + int64 nOutputValue = AmountFromValue(params[1]); + + // Amount + int64 nMaxValue = AmountFromValue(params[2]); + + if (nAmount < MIN_TXOUT_AMOUNT) + throw JSONRPCError(-101, "Send amount too small"); + + if (nOutputValue < MIN_TXOUT_AMOUNT) + throw JSONRPCError(-101, "Output value too small"); + + if (nMaxValue < MIN_TXOUT_AMOUNT) + throw JSONRPCError(-101, "Max value too small"); + + if (nOutputValue < nMaxValue) + throw JSONRPCError(-101, "Output value is lower than max value"); + + + list listMerged; + if (!pwalletMain->MergeCoins(nAmount, nMaxValue, nOutputValue, listMerged)) + return Value::null; + + Array mergedHashes; + BOOST_FOREACH(const uint256 txHash, listMerged) + mergedHashes.push_back(txHash.GetHex()); + + return mergedHashes; +} + Value sendtoaddress(const Array& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 4)