Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_add
}

if (calculate_fee) {
const CAmount fee = amt_total_in - amt_total_out;
CAmount fee = amt_total_in - amt_total_out;
if (tx.IsPlatformTransfer()) {
fee = CHECK_NONFATAL(GetTxPayload<CAssetUnlockPayload>(tx))->getFee();
}
CHECK_NONFATAL(MoneyRange(fee));
entry.pushKV("fee", ValueFromAmount(fee));
}
Expand Down
6 changes: 6 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <versionbits.h>
#include <warnings.h>

#include <evo/assetlocktx.h>
#include <evo/cbtx.h>
#include <evo/evodb.h>
#include <evo/mnhftx.h>
Expand Down Expand Up @@ -2450,6 +2451,11 @@ static RPCHelpMan getblockstats()
}

CAmount txfee = tx_total_in - tx_total_out;

if (tx->IsPlatformTransfer()) {
txfee = CHECK_NONFATAL(GetTxPayload<CAssetUnlockPayload>(*tx))->getFee();
}

CHECK_NONFATAL(MoneyRange(txfee));
if (do_medianfee) {
fee_array.push_back(txfee);
Expand Down
6 changes: 6 additions & 0 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <chainparams.h>
#include <evo/assetlocktx.h>
#include <evo/chainhelper.h>
#include <evo/deterministicmns.h>
#include <governance/classes.h>
Expand Down Expand Up @@ -406,6 +407,11 @@ static RPCHelpMan masternode_payments()
if (tx->IsCoinBase()) {
continue;
}
if (tx->IsPlatformTransfer()) {
Comment thread
UdjinM6 marked this conversation as resolved.
nBlockFees += CHECK_NONFATAL(GetTxPayload<CAssetUnlockPayload>(*tx))->getFee();
continue;
}

CAmount nValueIn{0};
for (const auto& txin : tx->vin) {
uint256 blockHashTmp;
Expand Down
4 changes: 4 additions & 0 deletions test/functional/feature_asset_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
self.wait_for_sporks_same()

txid = self.send_tx(asset_unlock_tx)
assert_equal(node.getmempoolentry(txid)['fee'], Decimal("0.0007"))
is_id = node_wallet.sendtoaddress(node_wallet.getnewaddress(), 1)
for node in self.nodes:
self.wait_for_instantlock(is_id, node)
Expand Down Expand Up @@ -407,6 +408,9 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
self.mempool_size -= 2
self.check_mempool_size()
block_asset_unlock = node.getrawtransaction(asset_unlock_tx.rehash(), 1)['blockhash']
self.log.info("Checking rpc `getblock` and `getblockstats` succeeds as they use own fee calculation mechanism")
assert_equal(node.getblockstats(node.getblockcount())['maxfee'], tiny_amount)
node.getblock(block_asset_unlock, 2)

self.send_tx(asset_unlock_tx,
expected_error = "Transaction already in block chain",
Expand Down