Skip to content

Commit c0ae07d

Browse files
committed
backend: show estimated conversions for unconfirmed ETH txs.
1 parent 5cae179 commit c0ae07d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

backend/coins/btc/handlers/handlers.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -121,18 +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 := 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-
}
124+
if timeStamp == nil {
125+
now := time.Now()
126+
timeStamp = &now
127+
}
128+
conversions, estimated := coin.ConversionsAtTime(
129+
amount,
130+
handlers.account.Coin(),
131+
false,
132+
handlers.account.Config().RateUpdater,
133+
util.FormatBtcAsSat(handlers.account.Config().BtcCurrencyUnit),
134+
timeStamp,
135+
)
136136
return FormattedAmount{
137137
Amount: accountCoin.FormatAmount(amount, false),
138138
Unit: accountCoin.GetFormatUnit(false),
@@ -200,11 +200,11 @@ func (handlers *Handlers) getTxInfoJSON(txInfo *accounts.TransactionData, detail
200200
}
201201

202202
deductedAmountAtTime := handlers.formatAmountAtTimeAsJSON(txInfo.DeductedAmount, timestamp)
203+
amountAtTime = handlers.formatAmountAtTimeAsJSON(txInfo.Amount, timestamp)
203204

204205
if timestamp != nil {
205206
t := timestamp.Format(time.RFC3339)
206207
formattedTime = &t
207-
amountAtTime = handlers.formatAmountAtTimeAsJSON(txInfo.Amount, timestamp)
208208
}
209209

210210
addresses := []string{}

0 commit comments

Comments
 (0)