Skip to content

Commit 7de1de7

Browse files
committed
Add new fee structure with all sub-fields denominated in BTC
1 parent 3a8a4dc commit 7de1de7

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
@@ -360,17 +360,23 @@ UniValue getdifficulty(const JSONRPCRequest& request)
360360
std::string EntryDescriptionString()
361361
{
362362
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"
363-
" \"fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n"
364-
" \"modifiedfee\" : n, (numeric) transaction fee with fee deltas used for mining priority\n"
363+
" \"fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + " (DEPRECATED)\n"
364+
" \"modifiedfee\" : n, (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)\n"
365365
" \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n"
366366
" \"height\" : n, (numeric) block height when transaction entered pool\n"
367367
" \"descendantcount\" : n, (numeric) number of in-mempool descendant transactions (including this one)\n"
368368
" \"descendantsize\" : n, (numeric) virtual transaction size of in-mempool descendants (including this one)\n"
369-
" \"descendantfees\" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one)\n"
369+
" \"descendantfees\" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)\n"
370370
" \"ancestorcount\" : n, (numeric) number of in-mempool ancestor transactions (including this one)\n"
371371
" \"ancestorsize\" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)\n"
372-
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one)\n"
372+
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)\n"
373373
" \"wtxid\" : hash, (string) hash of serialized transaction, including witness data\n"
374+
" \"fees\" : {\n"
375+
" \"base\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n"
376+
" \"modified\" : n, (numeric) transaction fee with fee deltas used for mining priority in " + CURRENCY_UNIT + "\n"
377+
" \"ancestor\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) in " + CURRENCY_UNIT + "\n"
378+
" \"descendent\" : n, (numeric) number of in-mempool ancestor transactions (including this one) in " + CURRENCY_UNIT + "\n"
379+
" }\n"
374380
" \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
375381
" \"transactionid\", (string) parent transaction id\n"
376382
" ... ]\n"
@@ -383,6 +389,13 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
383389
{
384390
AssertLockHeld(mempool.cs);
385391

392+
UniValue fees(UniValue::VOBJ);
393+
fees.pushKV("base", ValueFromAmount(e.GetFee()));
394+
fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee()));
395+
fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()));
396+
fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()));
397+
info.pushKV("fees", fees);
398+
386399
info.pushKV("size", (int)e.GetTxSize());
387400
info.pushKV("fee", ValueFromAmount(e.GetFee()));
388401
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)