Post
Topic
Board Announcements (Altcoins)
Re: [ANN][TAC] TalkCoin | Decentralized Communications Currency | NIST5
by
ynyjl
on 13/08/2014, 19:00:40 UTC
Value votedev(const Array& params, bool fHelp)
{
    if (fHelp || params.size() != 1)
        throw runtime_error(
            "votedev \n"
            "Percentage to be given to developers 0-5");

    if (nSubsidy <= 0)
        throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Invalid Subsidy");

    if (!(params[0].get_real() >= 0 && params[0].get_real() <= 5))
        throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid Percentage");

    int64 nVote2 = params[0].get_real() * COIN;

    CTalkcoinAddress address(DecodeBase64(GET_A_VOTE2(nBestHeight)));
    if (!address.IsValid())
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Talkcoin address");

    // Amount
    int64 nAmount = GET_V_VOTE(nBestHeight);

    // Wallet comments
    CWalletTx wtx;
    wtx.mapValue["to"] = "Talkcoin Vote";

    if (pwalletMain->IsLocked())
        throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");

    string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx, false, nVote2);
    if (strError != "")
        throw JSONRPCError(RPC_WALLET_ERROR, strError);

    return wtx.GetHash().GetHex();
}