diff --git a/cmd/start.go b/cmd/start.go index 6b25445824..e1f35fc70a 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -87,7 +87,7 @@ type Start struct { DisableWallet bool `long:"disablewallet" description:"disable the wallet functionality of the node"` DisableExchangeRates bool `long:"disableexchangerates" description:"disable the exchange rate service to prevent api queries"` Storage string `long:"storage" description:"set the outgoing message storage option [self-hosted, dropbox] default=self-hosted"` - + InfuraKey string `long:"infurakey" description:"if you want to use the ethereum wallet you will need to enter your ethereum infura key. This can acquire for free from infura."` ForceKeyCachePurge bool `long:"forcekeypurge" description:"repair test for issue OpenBazaar/openbazaar-go#1593; use as instructed only"` } @@ -449,6 +449,7 @@ func (x *Start) Execute(args []string) error { WalletCreationDate: creationDate, Mnemonic: mn, DisableExchangeRates: x.DisableExchangeRates, + InfuraKey: x.InfuraKey, } mw, err := wallet.NewMultiWallet(multiwalletConfig) if err != nil { @@ -672,6 +673,10 @@ func (x *Start) Execute(args []string) error { core.Node.StartRecordAgingNotifier() core.Node.StartInboundMsgScanner() + if err := core.Node.RemoveDisabledCurrenciesFromListings(); err != nil { + log.Error(err) + } + core.Node.PublishLock.Unlock() err = core.Node.UpdateFollow() if err != nil { diff --git a/core/listings.go b/core/listings.go index 8c59957e56..8bda716d4d 100644 --- a/core/listings.go +++ b/core/listings.go @@ -697,7 +697,7 @@ func (n *OpenBazaarNode) SetPriceOnListings(percentage float64) error { } // SetCurrencyOnListings - set currencies accepted for a listing -func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error { +func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string, seedNode bool) error { absPath, err := filepath.Abs(path.Join(n.RepoPath, "root", "listings")) if err != nil { return err @@ -740,9 +740,20 @@ func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error { return err } - err = n.SeedNode() - if err != nil { - return err + if seedNode { + err = n.SeedNode() + if err != nil { + return err + } } return nil } + +func (n *OpenBazaarNode) RemoveDisabledCurrenciesFromListings() error { + var cur []string + for cc := range n.Multiwallet { + cur = append(cur, cc.CurrencyCode()) + } + + return n. SetCurrencyOnListings(cur, false) +} diff --git a/core/listings_test.go b/core/listings_test.go index c647621d59..0b3cbdff79 100644 --- a/core/listings_test.go +++ b/core/listings_test.go @@ -52,7 +52,7 @@ func TestOpenBazaarNode_SetCurrencyOnListings(t *testing.T) { t.Fatal(err) } - if err := node.SetCurrencyOnListings(newAcceptedCurrencies); err != nil { + if err := node.SetCurrencyOnListings(newAcceptedCurrencies, true); err != nil { t.Fatal(err) } diff --git a/vendor/github.com/OpenBazaar/go-ethwallet/wallet/wallet.go b/vendor/github.com/OpenBazaar/go-ethwallet/wallet/wallet.go index 3698cbfb28..f7eb4239aa 100644 --- a/vendor/github.com/OpenBazaar/go-ethwallet/wallet/wallet.go +++ b/vendor/github.com/OpenBazaar/go-ethwallet/wallet/wallet.go @@ -45,8 +45,6 @@ var _ = wi.Wallet(&EthereumWallet{}) var done, doneBalanceTicker chan bool const ( - // InfuraAPIKey is the hard coded Infura API key - InfuraAPIKey = "v3/91c82af0169c4115940c76d331410749" // EtherScanAPIKey is needed for all Eherscan requests EtherScanAPIKey = "KA15D8FCHGBFZ4CQ25Y4NZM24417AXWF7M" maxGasLimit = 400000 @@ -206,7 +204,15 @@ func NewEthereumWalletWithKeyfile(url, keyFile, passwd string) *EthereumWallet { // NewEthereumWallet will return a reference to the Eth Wallet func NewEthereumWallet(cfg config.CoinConfig, params *chaincfg.Params, mnemonic string, proxy proxy.Dialer) (*EthereumWallet, error) { - client, err := NewEthClient(cfg.ClientAPIs[0] + "/" + InfuraAPIKey) + ikey, ok := cfg.Options["infuraKey"] + if !ok { + return nil, errors.New("no infura key in config") + } + infuraKey, ok := ikey.(string) + if !ok { + return nil, errors.New("no infura key in config") + } + client, err := NewEthClient(cfg.ClientAPIs[0] + "/" + infuraKey) if err != nil { log.Errorf("error initializing wallet: %v", err) return nil, err diff --git a/vendor/github.com/filecoin-project/lotus/extern/filecoin-ffi/rust/filecoin.pc b/vendor/github.com/filecoin-project/lotus/extern/filecoin-ffi/rust/filecoin.pc new file mode 100644 index 0000000000..e69de29bb2 diff --git a/wallet/builder.go b/wallet/builder.go index 0e60158b5c..1e2c6487c0 100644 --- a/wallet/builder.go +++ b/wallet/builder.go @@ -53,6 +53,8 @@ type WalletConfig struct { Proxy proxy.Dialer // DisableExchangeRates will disable usage of the internal exchange rate API DisableExchangeRates bool + // Key for infura if you want to use the ethereum wallet. + InfuraKey string } // NewMultiWallet returns a functional set of wallets using the provided WalletConfig. @@ -92,7 +94,7 @@ func NewMultiWallet(cfg *WalletConfig) (multiwallet.MultiWallet, error) { var newMultiwallet = make(multiwallet.MultiWallet) for coin, coinConfig := range enableAPIWallet { - if coinConfig != nil { + if coinConfig != nil && (coin != wallet.Ethereum || cfg.InfuraKey != "") { actualCoin, newWallet, err := createAPIWallet(coin, coinConfig, cfg) if err != nil { logger.Errorf("failed creating wallet for %s: %s", actualCoin, err) @@ -172,6 +174,7 @@ func createAPIWallet(coin wallet.CoinType, coinConfigOverrides *schema.CoinConfi } else { actualCoin = wallet.Ethereum } + coinConfig.Options["infuraKey"] = cfg.InfuraKey //actualCoin = wallet.Ethereum w, err := eth.NewEthereumWallet(*coinConfig, cfg.Params, cfg.Mnemonic, cfg.Proxy) if err != nil {