Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit f89d928

Browse files
committed
Add Filecoin API wallet
1 parent 75a7602 commit f89d928

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

wallet/builder.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package wallet
33
import (
44
"errors"
55
"fmt"
6+
"github.com/OpenBazaar/multiwallet/filecoin"
67
"net"
78
"net/url"
89
"os"
@@ -89,6 +90,7 @@ func NewMultiWallet(cfg *WalletConfig) (multiwallet.MultiWallet, error) {
8990
enableAPIWallet[wallet.Litecoin] = cfg.ConfigFile.LTC
9091
}
9192
enableAPIWallet[wallet.Ethereum] = cfg.ConfigFile.ETH
93+
enableAPIWallet[wallet.Filecoin] = cfg.ConfigFile.FIL
9294

9395
var newMultiwallet = make(multiwallet.MultiWallet)
9496
for coin, coinConfig := range enableAPIWallet {
@@ -178,6 +180,18 @@ func createAPIWallet(coin wallet.CoinType, coinConfigOverrides *schema.CoinConfi
178180
return InvalidCoinType, nil, err
179181
}
180182
return actualCoin, w, nil
183+
case wallet.Filecoin:
184+
if testnet {
185+
actualCoin = wallet.TestnetFilecoin
186+
} else {
187+
actualCoin = wallet.Filecoin
188+
}
189+
//actualCoin = wallet.Filecoin
190+
w, err := filecoin.NewFilecoinWallet(*coinConfig, cfg.Mnemonic, cfg.Params, cfg.Proxy, cache.NewMockCacher(), cfg.DisableExchangeRates)
191+
if err != nil {
192+
return InvalidCoinType, nil, err
193+
}
194+
return actualCoin, w, nil
181195
}
182196
return InvalidCoinType, nil, fmt.Errorf("unable to create wallet for unknown coin %s", coin.String())
183197
}
@@ -297,6 +311,8 @@ func prepareAPICoinConfig(coin wallet.CoinType, override *schema.CoinConfig, wal
297311
defaultConfig = defaultConfigSet.LTC
298312
case wallet.Zcash:
299313
defaultConfig = defaultConfigSet.ZEC
314+
case wallet.Filecoin:
315+
defaultConfig = defaultConfigSet.FIL
300316
case wallet.Ethereum:
301317
defaultConfig = defaultConfigSet.ETH
302318
defaultCoinOptions = schema.EthereumDefaultOptions()

0 commit comments

Comments
 (0)