Skip to content

Commit

Permalink
Merge branch 'dev' into fundrawtransaction-test
Browse files Browse the repository at this point in the history
  • Loading branch information
JBetz authored Apr 22, 2024
2 parents c27b42c + 44b2bf0 commit 9d61ad1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ static std::vector<RPCResult> MempoolEntryDescription() { return {
RPCResult{RPCResult::Type::STR_AMOUNT, "modified", "transaction fee with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
RPCResult{RPCResult::Type::STR_AMOUNT, "ancestor", "transaction fees of in-mempool ancestors (including this one) with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
RPCResult{RPCResult::Type::STR_AMOUNT, "descendant", "transaction fees of in-mempool descendants (including this one) with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
RPCResult{RPCResult::Type::STR_HEX, "asset", /*optional=*/true, "asset used to pay transaction fee"},
RPCResult{RPCResult::Type::STR_AMOUNT, "value", /*optional=*/true, "value of transaction fee according to current exchange rates, denominated in reference fee unit"},
}},
RPCResult{RPCResult::Type::ARR, "depends", "unconfirmed transactions used as inputs for this transaction",
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", "parent transaction id"}}},
Expand Down Expand Up @@ -572,6 +574,10 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool
fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee()));
fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()));
fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()));
if (g_con_any_asset_fees) {
fees.pushKV("asset", e.GetFeeAsset().GetHex());
fees.pushKV("value", ValueFromAmount(e.GetFeeValue()));
}
info.pushKV("fees", fees);

const CTransaction& tx = e.GetTx();
Expand Down
49 changes: 49 additions & 0 deletions test/functional/rpc_mempool_fees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
# Copyright (c) 2017-2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Tests mempool RPCs"""

from test_framework.blocktools import COINBASE_MATURITY
from test_framework.test_framework import BitcoinTestFramework
from decimal import Decimal

class MempoolFeesTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
self.extra_args = [[
"-con_any_asset_fees=1",
"-defaultpeggedassetname=gasset",
]]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
node = self.nodes[0]
self.generate(node, COINBASE_MATURITY + 1)
gasset_hexid = 'b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23'

assert node.dumpassetlabels() == { 'gasset': gasset_hexid }
initial_rates = { 'gasset': 100000000 }
assert node.getfeeexchangerates() == initial_rates

self.issue_amount = Decimal('100')
self.issuance = node.issueasset(self.issue_amount, 1)
self.asset = self.issuance['asset']
txid = self.issuance['txid']

assert node.getmempoolinfo()['minrelaytxfee'] == Decimal('0.00001')

fees1 = node.getrawmempool(verbose=True)[txid]['fees']
assert fees1['asset'] == gasset_hexid
assert fees1['value'] == Decimal('0.00120320')

node.setfeeexchangerates({ 'gasset': 200000000 })
fees2 = node.getrawmempool(verbose=True)[txid]['fees']
assert fees2['asset'] == gasset_hexid
assert fees2['value'] == Decimal('0.00240640')

if __name__ == '__main__':
MempoolFeesTest().main()

0 comments on commit 9d61ad1

Please sign in to comment.