Skip to content

Commit 5bd8659

Browse files
committed
Merge branch 'deductedAmount' into release-v4.47.0
2 parents 5592464 + efc5db4 commit 5bd8659

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

backend/accounts/transaction_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ func TestOrderedTransactionsDeductedAmount(t *testing.T) {
277277
Amount: amount,
278278
Fee: &fee,
279279
},
280+
{
281+
// timestamp is nil, deductedAmount is still set
282+
Timestamp: nil,
283+
Height: 15,
284+
Type: TxTypeSend,
285+
Amount: amount,
286+
Fee: &fee,
287+
},
280288
}
281289

282290
orderedTxs := NewOrderedTransactions(txs)
@@ -285,4 +293,5 @@ func TestOrderedTransactionsDeductedAmount(t *testing.T) {
285293
requireAmountIsEqualTo(t, orderedTxs[1].DeductedAmount, 10)
286294
requireAmountIsEqualTo(t, orderedTxs[2].DeductedAmount, 0)
287295
requireAmountIsEqualTo(t, orderedTxs[3].DeductedAmount, 100)
296+
requireAmountIsEqualTo(t, orderedTxs[4].DeductedAmount, 110)
288297
}

backend/coins/btc/handlers/handlers.go

+14-10
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,18 @@ func (handlers *Handlers) formatAmountAsJSON(amount coin.Amount, isFee bool) For
121121

122122
func (handlers *Handlers) formatAmountAtTimeAsJSON(amount coin.Amount, timeStamp *time.Time) FormattedAmount {
123123
accountCoin := handlers.account.Coin()
124-
conversions, estimated := coin.ConversionsAtTime(
125-
amount,
126-
handlers.account.Coin(),
127-
false,
128-
handlers.account.Config().RateUpdater,
129-
util.FormatBtcAsSat(handlers.account.Config().BtcCurrencyUnit),
130-
timeStamp,
131-
)
124+
conversions := map[string]string{}
125+
estimated := false
126+
if timeStamp != nil {
127+
conversions, estimated = coin.ConversionsAtTime(
128+
amount,
129+
handlers.account.Coin(),
130+
false,
131+
handlers.account.Config().RateUpdater,
132+
util.FormatBtcAsSat(handlers.account.Config().BtcCurrencyUnit),
133+
timeStamp,
134+
)
135+
}
132136
return FormattedAmount{
133137
Amount: accountCoin.FormatAmount(amount, false),
134138
Unit: accountCoin.GetFormatUnit(false),
@@ -195,12 +199,12 @@ func (handlers *Handlers) getTxInfoJSON(txInfo *accounts.TransactionData, detail
195199
timestamp = txInfo.CreatedTimestamp
196200
}
197201

198-
var deductedAmountAtTime FormattedAmount
202+
deductedAmountAtTime := handlers.formatAmountAtTimeAsJSON(txInfo.DeductedAmount, timestamp)
203+
199204
if timestamp != nil {
200205
t := timestamp.Format(time.RFC3339)
201206
formattedTime = &t
202207
amountAtTime = handlers.formatAmountAtTimeAsJSON(txInfo.Amount, timestamp)
203-
deductedAmountAtTime = handlers.formatAmountAtTimeAsJSON(txInfo.DeductedAmount, timestamp)
204208
}
205209

206210
addresses := []string{}

frontends/web/src/components/amount/conversion-amount.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const ConversionAmount = ({
5454

5555
return (
5656
<span className={styles.txConversionAmount}>
57-
{conversion && amountToShow ? (
57+
{(conversion || sendToSelf) && amountToShow ? (
5858
<>
5959
{sendToSelf && (
6060
<span className={styles.txSmallInlineIcon}>

0 commit comments

Comments
 (0)