示例#1
0
void
fill_fee (Json::Value& jv,
    ReadView const& view)
{
    if (jv.isMember(jss::Fee))
        return;
    jv[jss::Fee] = std::to_string(
        view.fees().base);
}
示例#2
0
std::uint64_t Transactor::calculateBaseFee (
    ReadView const& view,
    STTx const& tx)
{
    // Returns the fee in fee units.

    // The computation has two parts:
    //  * The base fee, which is the same for most transactions.
    //  * The additional cost of each multisignature on the transaction.
    std::uint64_t baseFee = view.fees().units;

    // Each signer adds one more baseFee to the minimum required fee
    // for the transaction.
    std::uint32_t signerCount = 0;
    if (tx.isFieldPresent (sfSigners))
        signerCount = tx.getFieldArray (sfSigners).size();

    return baseFee + (signerCount * baseFee);
}
示例#3
0
void
fill_fee (Json::Value& jv,
    ReadView const& view)
{
    if (jv.isMember(jss::Fee))
        return;
    auto fee = view.fees().base;
    if (jv.isMember (jss::TransactionType) &&
        (jv[jss::TransactionType].asString () == "Payment" ||
         jv[jss::TransactionType].asString () == "ActiveAccount"))
    {
        if (jv.isMember (jss::Amount))
        {
            STAmount amount;
            amountFromJsonNoThrow (amount, jv[jss::Amount]);
            if (amount.native ())
                fee = std::max (multiply (amount, amountFromRate (Config ().FEE_DEFAULT_RATE_NATIVE),
                                          amount.issue ())
                                    .mantissa (),
                                Config ().FEE_DEFAULT_MIN_NATIVE);
        }
        if (jv.isMember (jv[jss::TransactionType].asString () == "ActiveAccount" ?
                             jss::Reference :
                             jss::Destination))
        {
            auto const account =
                parseBase58<AccountID> (
                    jv[jv[jss::TransactionType].asString () == "ActiveAccount" ?
                           jss::Reference :
                           jss::Destination]
                        .asString ());
            if (!account)
                throw parse_error (
                    "unexpected invalid Destination");
            if (!view.exists (keylet::account (*account)))
                fee += Config ().FEE_DEFAULT_CREATE;
        }
    }
    jv[jss::Fee] = std::to_string(
        fee);
}