diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -3,3 +3,4 @@ This release includes the following features and fixes: +- New `fees` field introduced in `getrawmempool`, `getmempoolancestors`, `getmempooldescendants` and `getmempoolentry` when verbosity is set to `true` with sub-fields `ancestor`, `base`, `modified` and `descendent` denominated in BCH. This new field deprecates previous fee fields, such as `fee`, `modifiedfee`, `ancestorfee` and `descendentfee`. diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -406,10 +406,10 @@ static std::string EntryDescriptionString() { return " \"size\" : n, (numeric) transaction size.\n" " \"fee\" : n, (numeric) transaction fee in " + - CURRENCY_UNIT + + CURRENCY_UNIT + "(DEPRECATED)" + "\n" " \"modifiedfee\" : n, (numeric) transaction fee with fee " - "deltas used for mining priority\n" + "deltas used for mining priority (DEPRECATED)\n" " \"time\" : n, (numeric) local time transaction " "entered pool in seconds since 1 Jan 1970 GMT\n" " \"height\" : n, (numeric) block height when " @@ -423,13 +423,30 @@ " \"descendantsize\" : n, (numeric) virtual transaction size " "of in-mempool descendants (including this one)\n" " \"descendantfees\" : n, (numeric) modified fees (see above) " - "of in-mempool descendants (including this one)\n" + "of in-mempool descendants (including this one) (DEPRECATED)\n" " \"ancestorcount\" : n, (numeric) number of in-mempool " "ancestor transactions (including this one)\n" " \"ancestorsize\" : n, (numeric) virtual transaction size " "of in-mempool ancestors (including this one)\n" " \"ancestorfees\" : n, (numeric) modified fees (see above) " - "of in-mempool ancestors (including this one)\n" + "of in-mempool ancestors (including this one) (DEPRECATED)\n" + " \"fees\" : {\n" + " \"base\" : n, (numeric) transaction fee in " + + CURRENCY_UNIT + + "\n" + " \"modified\" : n, (numeric) transaction fee with fee " + "deltas used for mining priority in " + + CURRENCY_UNIT + + "\n" + " \"ancestor\" : n, (numeric) modified fees (see above) " + "of in-mempool ancestors (including this one) in " + + CURRENCY_UNIT + + "\n" + " \"descendant\" : n, (numeric) modified fees (see above) " + "of in-mempool descendants (including this one) in " + + CURRENCY_UNIT + + "\n" + " }\n" " \"depends\" : [ (array) unconfirmed transactions " "used as inputs for this transaction\n" " \"transactionid\", (string) parent transaction id\n" @@ -444,6 +461,13 @@ EXCLUSIVE_LOCKS_REQUIRED(g_mempool.cs) { AssertLockHeld(g_mempool.cs); + UniValue fees(UniValue::VOBJ); + fees.pushKV("base", ValueFromAmount(e.GetFee())); + fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee())); + fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors())); + fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants())); + info.pushKV("fees", fees); + info.pushKV("size", (int)e.GetTxSize()); info.pushKV("fee", ValueFromAmount(e.GetFee())); info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee())); diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -82,7 +82,11 @@ assert_equal(mempool[x]['descendantcount'], descendant_count) descendant_fees += mempool[x]['fee'] assert_equal(mempool[x]['modifiedfee'], mempool[x]['fee']) + assert_equal(mempool[x]['fees']['base'], mempool[x]['fee']) + assert_equal(mempool[x]['fees']['modified'], + mempool[x]['modifiedfee']) assert_equal(mempool[x]['descendantfees'], descendant_fees * COIN) + assert_equal(mempool[x]['fees']['descendant'], descendant_fees) descendant_size += mempool[x]['size'] assert_equal(mempool[x]['descendantsize'], descendant_size) descendant_count += 1 @@ -149,6 +153,8 @@ ancestor_fees = 0 for x in chain: ancestor_fees += mempool[x]['fee'] + assert_equal(mempool[x]['fees']['ancestor'], + ancestor_fees + Decimal('0.00001')) assert_equal(mempool[x]['ancestorfees'], ancestor_fees * COIN + 1000) @@ -163,6 +169,8 @@ descendant_fees = 0 for x in reversed(chain): descendant_fees += mempool[x]['fee'] + assert_equal(mempool[x]['fees']['descendant'], + descendant_fees + Decimal('0.00001')) assert_equal(mempool[x]['descendantfees'], descendant_fees * COIN + 1000) @@ -191,8 +199,12 @@ if (x == chain[-1]): assert_equal(mempool[x]['modifiedfee'], mempool[x]['fee'] + satoshi_round(0.00002)) + assert_equal(mempool[x]['fees']['modified'], + mempool[x]['fee'] + satoshi_round(0.00002)) assert_equal(mempool[x]['descendantfees'], descendant_fees * COIN + 2000) + assert_equal(mempool[x]['fees']['descendant'], + descendant_fees + satoshi_round(0.00002)) # TODO: check that node1's mempool is as expected