@@ -121,15 +121,27 @@ func (handlers *Handlers) formatAmountAsJSON(amount coin.Amount, isFee bool) For
121121
122122func (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 {
124+ rateUpdater := handlers .account .Config ().RateUpdater
125+ formatBtcAsSat := util .FormatBtcAsSat (handlers .account .Config ().BtcCurrencyUnit )
126+ var conversions map [string ]string
127+ var estimated bool
128+
129+ if timeStamp == nil {
130+ conversions = coin .Conversions (
131+ amount ,
132+ accountCoin ,
133+ false ,
134+ rateUpdater ,
135+ formatBtcAsSat ,
136+ )
137+ estimated = true
138+ } else {
127139 conversions , estimated = coin .ConversionsAtTime (
128140 amount ,
129- handlers . account . Coin () ,
141+ accountCoin ,
130142 false ,
131- handlers . account . Config (). RateUpdater ,
132- util . FormatBtcAsSat ( handlers . account . Config (). BtcCurrencyUnit ) ,
143+ rateUpdater ,
144+ formatBtcAsSat ,
133145 timeStamp ,
134146 )
135147 }
@@ -189,22 +201,18 @@ func (handlers *Handlers) getTxInfoJSON(txInfo *accounts.TransactionData, detail
189201 feeString = handlers .formatAmountAsJSON (* txInfo .Fee , true )
190202 }
191203 amount := handlers .formatAmountAsJSON (txInfo .Amount , false )
192- amountAtTime := FormattedAmount {
193- Amount : amount .Amount ,
194- Unit : amount .Unit ,
195- }
196204 var formattedTime * string
197205 timestamp := txInfo .Timestamp
198206 if timestamp == nil {
199207 timestamp = txInfo .CreatedTimestamp
200208 }
201209
202210 deductedAmountAtTime := handlers .formatAmountAtTimeAsJSON (txInfo .DeductedAmount , timestamp )
211+ amountAtTime := handlers .formatAmountAtTimeAsJSON (txInfo .Amount , timestamp )
203212
204213 if timestamp != nil {
205214 t := timestamp .Format (time .RFC3339 )
206215 formattedTime = & t
207- amountAtTime = handlers .formatAmountAtTimeAsJSON (txInfo .Amount , timestamp )
208216 }
209217
210218 addresses := []string {}
0 commit comments