Skip to content

Commit bc3a811

Browse files
committed
suggestions
1 parent 6cd7490 commit bc3a811

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/core_write.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,16 +330,14 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_add
330330
} else if (tx.nType == TRANSACTION_ASSET_UNLOCK) {
331331
if (const auto opt_assetUnlockTx = GetTxPayload<CAssetUnlockPayload>(tx)) {
332332
entry.pushKV("assetUnlockTx", opt_assetUnlockTx->ToJson());
333-
if (calculate_fee) {
334-
const CAmount fee = opt_assetUnlockTx->getFee();
335-
CHECK_NONFATAL(MoneyRange(fee));
336-
entry.pushKV("fee", ValueFromAmount(fee));
337-
}
338333
}
339334
}
340335

341-
if (calculate_fee && tx.nType != TRANSACTION_ASSET_UNLOCK) {
342-
const CAmount fee = amt_total_in - amt_total_out;
336+
if (calculate_fee) {
337+
CAmount fee = amt_total_in - amt_total_out;
338+
if (tx.nType == TRANSACTION_ASSET_UNLOCK) {
339+
fee = CHECK_NONFATAL(GetTxPayload<CAssetUnlockPayload>(tx))->getFee();
340+
}
343341
CHECK_NONFATAL(MoneyRange(fee));
344342
entry.pushKV("fee", ValueFromAmount(fee));
345343
}

src/rpc/blockchain.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,11 +2453,7 @@ static RPCHelpMan getblockstats()
24532453
CAmount txfee = tx_total_in - tx_total_out;
24542454

24552455
if (tx->nType == TRANSACTION_ASSET_UNLOCK) {
2456-
if (const auto opt_assetUnlockTx = GetTxPayload<CAssetUnlockPayload>(*tx)) {
2457-
txfee = opt_assetUnlockTx->getFee();
2458-
} else {
2459-
txfee = 0;
2460-
}
2456+
txfee = CHECK_NONFATAL(GetTxPayload<CAssetUnlockPayload>(*tx))->getFee();
24612457
}
24622458

24632459
CHECK_NONFATAL(MoneyRange(txfee));

0 commit comments

Comments
 (0)