Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get "paytxfee" and "relayfee" from "getinfo" #51

Open
dexX7 opened this issue Feb 9, 2015 · 2 comments
Open

Get "paytxfee" and "relayfee" from "getinfo" #51

dexX7 opened this issue Feb 9, 2015 · 2 comments

Comments

@dexX7
Copy link
Member

dexX7 commented Feb 9, 2015

I just noticed those values are part of the output of the RPC call "getinfo", so it's possible to get rid of the magic numbers. Won't start this today, but I assume it's basically switching from value = magicnum to value = getInfoRpcCallResult['key'].

@dexX7
Copy link
Member Author

dexX7 commented Apr 9, 2015

Coin amount = Coin.valueOf(dustAmountInSatoshis); // TODO: Make this dynamic

I'm not sure, how the encoder and transaction builder could be connected to client setup options, so let's go through it in theory:

In Omni Core we use the minimum amount that still gets relayed, based on the own client settings. The relevant value is relayfee, which can be retrieved via RPC call getinfo, and set via the config with minrelaytxfee. As per default, this value is 1000 satoshi (if I'm not mistaken now ... :).

There is a good chance, that BitcoinJ provides an alternative, and the Bitcoin Core master has a similar helper already, but we currently use GetDustLimit(const CScript& scriptPubKey):

//
// Determines minimum output amount to be spent by an output based on
// scriptPubKey size in relation to the minimum relay fee.
// 
// This method is very related with IsDust(nMinRelayTxFee) in core.h.
//
int64_t GetDustLimit(const CScript& scriptPubKey)
{
    // The total size is based on a typical scriptSig size of 148 byte,
    // 8 byte accounted for the size of output value and the serialized
    // size of scriptPubKey.
    size_t nSize = ::GetSerializeSize(scriptPubKey, SER_DISK, 0) + 156;

    // The minimum relay fee dictates a threshold value under which a
    // transaction won't be relayed.
    int64_t nRelayTxFee = (::minRelayTxFee).GetFee(nSize);

    // A transaction is considered as "dust", if less than 1/3 of the
    // minimum fee required to relay a transaction is spent by one of
    // it's outputs. The minimum relay fee is defined per 1000 byte.
    int64_t nDustLimit = nRelayTxFee * 3;

    return nDustLimit;
}

This is probably a bit cryptic, due to the getting of the relaytxfee and size, but the relevant numbers to use are: minrelaytxfee (which can be retrieved via getinfo) as well as the size in bytes of the transaction output. Some example values can be found here: mastercoin-MSC/mastercore@426592e

@dexX7
Copy link
Member Author

dexX7 commented Apr 13, 2015

@msgilligan: for some background about 8cc9800 see: OmniLayer/omnicore#13 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant