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

Require ethereum key at startup to use eth #2099

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
@@ -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 {
19 changes: 15 additions & 4 deletions core/listings.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion core/listings_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

12 changes: 9 additions & 3 deletions vendor/github.com/OpenBazaar/go-ethwallet/wallet/wallet.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion wallet/builder.go
Original file line number Diff line number Diff line change
@@ -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 {