[rpc] Add dustlimit info to getnetworkinfo

This commit is contained in:
Patrick 2021-10-28 16:10:42 -04:00
parent b2a55984f8
commit c3cead8737
No known key found for this signature in database
GPG Key ID: 7C523F5FBABE80E7
2 changed files with 15 additions and 0 deletions

View File

@ -59,6 +59,12 @@ class DustLimitTest(BitcoinTestFramework):
def run_test(self):
# make sure the dust limits got configured
self.check_dust_config(self.nodes[0], Decimal("1.0"), Decimal("0.0"))
self.check_dust_config(self.nodes[1], Decimal("1.0"), Decimal("1.0"))
self.check_dust_config(self.nodes[2], Decimal("0.01"), Decimal("0.001"))
self.check_dust_config(self.nodes[3], Decimal("0.0"), Decimal("0.0"))
# set up 10 seeded addresses for node 0-2
addrs = []
for i in range(3):
@ -162,5 +168,10 @@ class DustLimitTest(BitcoinTestFramework):
rawtx = self.create_dusty_tx(n, dust, fee)
assert_raises_jsonrpc(-26, "dust", n.sendrawtransaction, rawtx['hex'])
def check_dust_config(self, n, soft, hard):
networkinfo = n.getnetworkinfo()
assert_equal(networkinfo["softdustlimit"], soft)
assert_equal(networkinfo["harddustlimit"], hard)
if __name__ == '__main__':
DustLimitTest().main()

View File

@ -422,6 +422,8 @@ UniValue getnetworkinfo(const JSONRPCRequest& request)
" ],\n"
" \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for non-free transactions in " + CURRENCY_UNIT + "/kB\n"
" \"incrementalfee\": x.xxxxxxxx, (numeric) minimum fee increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kB\n"
" \"softdustlimit\": x.xxxxxxxx, (numeric) minimum output value under which this value needs to be added to fee, in " + CURRENCY_UNIT + "\n"
" \"harddustlimit\": x.xxxxxxxx, (numeric) minimum output value under which the node will no longer relay, in " + CURRENCY_UNIT + "\n"
" \"localaddresses\": [ (array) list of local addresses\n"
" {\n"
" \"address\": \"xxxx\", (string) network address\n"
@ -453,6 +455,8 @@ UniValue getnetworkinfo(const JSONRPCRequest& request)
obj.pushKV("networks", GetNetworksInfo());
obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFeeRate.GetFeePerK()));
obj.pushKV("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()));
obj.pushKV("softdustlimit", ValueFromAmount(nDustLimit));
obj.pushKV("harddustlimit", ValueFromAmount(nHardDustLimit));
UniValue localAddresses(UniValue::VARR);
{
LOCK(cs_mapLocalHost);