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
16 changes: 16 additions & 0 deletions tests/unit/handlers/finance.utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ test('processTransactions - with trackFees (Ocean data)', (t) => {
t.pass()
})

test('processTransactions - trackFees reads the api spelling fees_collected_satoshis', (t) => {
const results = [
[{
transactions: [{
ts: 1700006400000,
satoshis_net_earned: 50000000,
fees_collected_satoshis: 1000000
}]
}]
]
const { daily } = processTransactions(results, { trackFees: true }, 'UTC')
const key = Object.keys(daily)[0]
t.is(daily[key].feesBTC, 0.01, 'fees land instead of silently reading 0')
t.pass()
})

test('processTransactions - with trackFees (F2Pool data)', (t) => {
const results = [
[{
Expand Down
4 changes: 3 additions & 1 deletion workers/lib/server/handlers/finance.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ function processTransactions (results, opts, timezone) {
let feeBTC = 0
if (t.satoshis_net_earned) {
amountBTC = Math.abs(t.satoshis_net_earned) / BTC_SATS
feeBTC = (t.fees_colected_satoshis || 0) / BTC_SATS
// Ocean spells it fees_collected_satoshis; the single-l spelling is
// kept for any rows stored before this fix.
feeBTC = (t.fees_collected_satoshis || t.fees_colected_satoshis || 0) / BTC_SATS
} else {
amountBTC = Math.abs(t.changed_balance || t.amount || t.value || 0)
feeBTC = (t.mining_extra?.tx_fee || 0)
Expand Down
Loading