@@ -35,7 +35,6 @@ import (
35
35
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc"
36
36
accountHandlers "github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc/handlers"
37
37
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc/util"
38
- "github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/coin"
39
38
coinpkg "github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/coin"
40
39
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/eth"
41
40
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/config"
@@ -703,17 +702,17 @@ func (handlers *Handlers) postBtcFormatUnit(r *http.Request) interface{} {
703
702
// getAccountsBalanceHandler returns the balance of all the accounts, grouped by keystore and coin.
704
703
func (handlers * Handlers ) getAccountsBalance (* http.Request ) interface {} {
705
704
type response struct {
706
- Success bool `json:"success"`
707
- Balance map [string ]map [coin .Code ]accountHandlers.FormattedAmount `json:"balance,omitempty"`
705
+ Success bool `json:"success"`
706
+ Balance map [string ]map [coinpkg .Code ]accountHandlers.FormattedAmount `json:"balance,omitempty"`
708
707
}
709
- totalAmount := make (map [string ]map [coin .Code ]accountHandlers.FormattedAmount )
708
+ totalAmount := make (map [string ]map [coinpkg .Code ]accountHandlers.FormattedAmount )
710
709
accountsByKeystore , err := handlers .backend .AccountsByKeystore ()
711
710
if err != nil {
712
711
return response {Success : false }
713
712
}
714
713
for rootFingerprint , accountList := range accountsByKeystore {
715
- totalPerCoin := make (map [coin .Code ]* big.Int )
716
- conversionsPerCoin := make (map [coin .Code ]map [string ]string )
714
+ totalPerCoin := make (map [coinpkg .Code ]* big.Int )
715
+ conversionsPerCoin := make (map [coinpkg .Code ]map [string ]string )
717
716
for _ , account := range accountList {
718
717
if account .Config ().Config .Inactive || account .Config ().Config .HiddenBecauseUnused {
719
718
continue
@@ -738,22 +737,22 @@ func (handlers *Handlers) getAccountsBalance(*http.Request) interface{} {
738
737
totalPerCoin [coinCode ] = new (big.Int ).Add (totalPerCoin [coinCode ], amount .BigInt ())
739
738
}
740
739
741
- conversionsPerCoin [coinCode ] = coin .Conversions (
742
- coin .NewAmount (totalPerCoin [coinCode ]),
740
+ conversionsPerCoin [coinCode ] = coinpkg .Conversions (
741
+ coinpkg .NewAmount (totalPerCoin [coinCode ]),
743
742
account .Coin (),
744
743
false ,
745
744
account .Config ().RateUpdater ,
746
745
util .FormatBtcAsSat (handlers .backend .Config ().AppConfig ().Backend .BtcUnit ))
747
746
}
748
747
749
- totalAmount [rootFingerprint ] = make (map [coin .Code ]accountHandlers.FormattedAmount )
748
+ totalAmount [rootFingerprint ] = make (map [coinpkg .Code ]accountHandlers.FormattedAmount )
750
749
for k , v := range totalPerCoin {
751
750
currentCoin , err := handlers .backend .Coin (k )
752
751
if err != nil {
753
752
return response {Success : false }
754
753
}
755
754
totalAmount [rootFingerprint ][k ] = accountHandlers.FormattedAmount {
756
- Amount : currentCoin .FormatAmount (coin .NewAmount (v ), false ),
755
+ Amount : currentCoin .FormatAmount (coinpkg .NewAmount (v ), false ),
757
756
Unit : currentCoin .GetFormatUnit (false ),
758
757
Conversions : conversionsPerCoin [k ],
759
758
}
@@ -767,7 +766,7 @@ func (handlers *Handlers) getAccountsBalance(*http.Request) interface{} {
767
766
}
768
767
769
768
type coinFormattedAmount struct {
770
- CoinCode coin .Code `json:"coinCode"`
769
+ CoinCode coinpkg .Code `json:"coinCode"`
771
770
CoinName string `json:"coinName"`
772
771
FormattedAmount accountHandlers.FormattedAmount `json:"formattedAmount"`
773
772
}
@@ -779,8 +778,8 @@ func (handlers *Handlers) getCoinsTotalBalance(_ *http.Request) interface{} {
779
778
CoinsTotalBalance []coinFormattedAmount `json:"coinsTotalBalance,omitempty"`
780
779
}
781
780
var coinFormattedAmounts []coinFormattedAmount
782
- var sortedCoins []coin .Code
783
- totalCoinsBalances := make (map [coin .Code ]* big.Int )
781
+ var sortedCoins []coinpkg .Code
782
+ totalCoinsBalances := make (map [coinpkg .Code ]* big.Int )
784
783
785
784
for _ , account := range handlers .backend .Accounts () {
786
785
if account .Config ().Config .Inactive || account .Config ().Config .HiddenBecauseUnused {
@@ -817,10 +816,10 @@ func (handlers *Handlers) getCoinsTotalBalance(_ *http.Request) interface{} {
817
816
CoinCode : coinCode ,
818
817
CoinName : currentCoin .Name (),
819
818
FormattedAmount : accountHandlers.FormattedAmount {
820
- Amount : currentCoin .FormatAmount (coin .NewAmount (totalCoinsBalances [coinCode ]), false ),
819
+ Amount : currentCoin .FormatAmount (coinpkg .NewAmount (totalCoinsBalances [coinCode ]), false ),
821
820
Unit : currentCoin .GetFormatUnit (false ),
822
- Conversions : coin .Conversions (
823
- coin .NewAmount (totalCoinsBalances [coinCode ]),
821
+ Conversions : coinpkg .Conversions (
822
+ coinpkg .NewAmount (totalCoinsBalances [coinCode ]),
824
823
currentCoin ,
825
824
false ,
826
825
handlers .backend .RatesUpdater (),
@@ -1037,7 +1036,7 @@ func (handlers *Handlers) getConvertFromFiat(r *http.Request) interface{} {
1037
1036
}
1038
1037
1039
1038
rate := handlers .backend .RatesUpdater ().LatestPrice ()[unit ][from ]
1040
- result := coin .NewAmountFromInt64 (0 )
1039
+ result := coinpkg .NewAmountFromInt64 (0 )
1041
1040
if rate != 0.0 {
1042
1041
amountRat := new (big.Rat ).Quo (fiatRat , new (big.Rat ).SetFloat64 (rate ))
1043
1042
result = currentCoin .SetAmount (amountRat , false )
0 commit comments