Skip to content

Commit 6f8b345

Browse files
committed
Merge #12240: [rpc] Introduced a new fees structure that aggregates all sub-field fee types denominated in BTC
7de1de7 Add new fee structure with all sub-fields denominated in BTC (mryandao) Pull request description: the denomination for `fee` is current in btc while the other such as `decendentFee` and `ancestorFee` are in satoshis. Tree-SHA512: e428f6dca1d339f89ab73e38ce5903f5465c46b159069d9bcc3f8b1140fe6657fa49a11abe0088e9f7ba9999f64af72a349a4735bf5eaa61b8e4a185b23543f3
2 parents 646b7f6 + 7de1de7 commit 6f8b345

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

doc/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ RPC changes
7070
/rest/block/ endpoints when in json mode. This is also included in `getblock`
7171
(with verbosity=2), `listsinceblock`, `listtransactions`, and
7272
`getrawtransaction` RPC commands.
73+
- New `fees` field introduced in `getrawmempool`, `getmempoolancestors`, `getmempooldescendants` and
74+
`getmempoolentry` when verbosity is set to `true` with sub-fields `ancestor`, `base`, `modified`
75+
and `descendent` denominated in BTC. This new field deprecates previous fee fields, such as
76+
`fee`, `modifiedfee`, `ancestorfee` and `descendentfee`.
7377

7478
External wallet files
7579
---------------------

src/rpc/blockchain.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,23 @@ UniValue getdifficulty(const JSONRPCRequest& request)
358358
std::string EntryDescriptionString()
359359
{
360360
return " \"size\" : n, (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.\n"
361-
" \"fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n"
362-
" \"modifiedfee\" : n, (numeric) transaction fee with fee deltas used for mining priority\n"
361+
" \"fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + " (DEPRECATED)\n"
362+
" \"modifiedfee\" : n, (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)\n"
363363
" \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n"
364364
" \"height\" : n, (numeric) block height when transaction entered pool\n"
365365
" \"descendantcount\" : n, (numeric) number of in-mempool descendant transactions (including this one)\n"
366366
" \"descendantsize\" : n, (numeric) virtual transaction size of in-mempool descendants (including this one)\n"
367-
" \"descendantfees\" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one)\n"
367+
" \"descendantfees\" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)\n"
368368
" \"ancestorcount\" : n, (numeric) number of in-mempool ancestor transactions (including this one)\n"
369369
" \"ancestorsize\" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)\n"
370-
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one)\n"
370+
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)\n"
371371
" \"wtxid\" : hash, (string) hash of serialized transaction, including witness data\n"
372+
" \"fees\" : {\n"
373+
" \"base\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n"
374+
" \"modified\" : n, (numeric) transaction fee with fee deltas used for mining priority in " + CURRENCY_UNIT + "\n"
375+
" \"ancestor\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) in " + CURRENCY_UNIT + "\n"
376+
" \"descendent\" : n, (numeric) number of in-mempool ancestor transactions (including this one) in " + CURRENCY_UNIT + "\n"
377+
" }\n"
372378
" \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
373379
" \"transactionid\", (string) parent transaction id\n"
374380
" ... ]\n"
@@ -381,6 +387,13 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
381387
{
382388
AssertLockHeld(mempool.cs);
383389

390+
UniValue fees(UniValue::VOBJ);
391+
fees.pushKV("base", ValueFromAmount(e.GetFee()));
392+
fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee()));
393+
fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()));
394+
fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()));
395+
info.pushKV("fees", fees);
396+
384397
info.pushKV("size", (int)e.GetTxSize());
385398
info.pushKV("fee", ValueFromAmount(e.GetFee()));
386399
info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee()));

test/functional/mempool_packages.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ def run_test(self):
7070
assert_equal(mempool[x]['descendantcount'], descendant_count)
7171
descendant_fees += mempool[x]['fee']
7272
assert_equal(mempool[x]['modifiedfee'], mempool[x]['fee'])
73+
assert_equal(mempool[x]['fees']['base'], mempool[x]['fee'])
74+
assert_equal(mempool[x]['fees']['modified'], mempool[x]['modifiedfee'])
7375
assert_equal(mempool[x]['descendantfees'], descendant_fees * COIN)
76+
assert_equal(mempool[x]['fees']['descendant'], descendant_fees)
7477
descendant_size += mempool[x]['size']
7578
assert_equal(mempool[x]['descendantsize'], descendant_size)
7679
descendant_count += 1
@@ -132,6 +135,7 @@ def run_test(self):
132135
ancestor_fees = 0
133136
for x in chain:
134137
ancestor_fees += mempool[x]['fee']
138+
assert_equal(mempool[x]['fees']['ancestor'], ancestor_fees + Decimal('0.00001'))
135139
assert_equal(mempool[x]['ancestorfees'], ancestor_fees * COIN + 1000)
136140

137141
# Undo the prioritisetransaction for later tests
@@ -145,6 +149,7 @@ def run_test(self):
145149
descendant_fees = 0
146150
for x in reversed(chain):
147151
descendant_fees += mempool[x]['fee']
152+
assert_equal(mempool[x]['fees']['descendant'], descendant_fees + Decimal('0.00001'))
148153
assert_equal(mempool[x]['descendantfees'], descendant_fees * COIN + 1000)
149154

150155
# Adding one more transaction on to the chain should fail.
@@ -170,7 +175,9 @@ def run_test(self):
170175
descendant_fees += mempool[x]['fee']
171176
if (x == chain[-1]):
172177
assert_equal(mempool[x]['modifiedfee'], mempool[x]['fee']+satoshi_round(0.00002))
178+
assert_equal(mempool[x]['fees']['modified'], mempool[x]['fee']+satoshi_round(0.00002))
173179
assert_equal(mempool[x]['descendantfees'], descendant_fees * COIN + 2000)
180+
assert_equal(mempool[x]['fees']['descendant'], descendant_fees+satoshi_round(0.00002))
174181

175182
# TODO: check that node1's mempool is as expected
176183

0 commit comments

Comments
 (0)