Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacia committed Sep 17, 2018
1 parent 8f44d4d commit 923b5b8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
4 changes: 2 additions & 2 deletions api/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"github.com/OpenBazaar/multiwallet/api/pb"
"github.com/OpenBazaar/multiwallet/bitcoin"
"github.com/OpenBazaar/multiwallet/bitcoincash"
"github.com/OpenBazaar/multiwallet/litecoin"
"github.com/OpenBazaar/multiwallet/zcash"
"github.com/OpenBazaar/wallet-interface"
"github.com/btcsuite/btcutil"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"net"
"github.com/OpenBazaar/multiwallet/litecoin"
"github.com/OpenBazaar/multiwallet/zcash"
)

const Addr = "127.0.0.1:8234"
Expand Down
12 changes: 5 additions & 7 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
"testing"
"time"

"sync"

"github.com/OpenBazaar/golang-socketio"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
"gopkg.in/jarcoal/httpmock.v1"
"sync"
)

func NewTestClient() *InsightClient {
Expand Down Expand Up @@ -413,17 +414,14 @@ func TestInsightClient_Broadcast(t *testing.T) {
setup()
defer teardown()

type Txid struct {
Result string `json:"result"`
}
type Response struct {
Txid Txid `json:"txid"`
Txid string `json:"txid"`
}

var (
c = NewTestClient()
testPath = fmt.Sprintf("http://%s/tx/send", c.apiUrl.Host)
expected = Response{Txid{"1be612e4f2b79af279e0b307337924072b819b3aca09fcb20370dd9492b83428"}}
expected = Response{"1be612e4f2b79af279e0b307337924072b819b3aca09fcb20370dd9492b83428"}
)

response, err := httpmock.NewJsonResponse(http.StatusOK, expected)
Expand All @@ -441,7 +439,7 @@ func TestInsightClient_Broadcast(t *testing.T) {
if err != nil {
t.Error(err)
}
if id != expected.Txid.Result {
if id != expected.Txid {
t.Error("Returned incorrect txid")
}
}
Expand Down
33 changes: 30 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package config

import (
"net/url"
"os"
"time"

"github.com/OpenBazaar/multiwallet/cache"
"github.com/OpenBazaar/multiwallet/datastore"
"github.com/OpenBazaar/wallet-interface"
"github.com/btcsuite/btcd/chaincfg"
"github.com/op/go-logging"
"golang.org/x/net/proxy"
"net/url"
"os"
"time"
)

type Config struct {
Expand Down Expand Up @@ -161,5 +162,31 @@ func NewDefaultConfig(coinTypes map[wallet.CoinType]bool, params *chaincfg.Param
}
cfg.Coins = append(cfg.Coins, ltcCfg)
}
if coinTypes[wallet.Ethereum] {
var apiEndpoint string
if !testnet {
apiEndpoint = "https://rinkeby.infura.io"
} else {
apiEndpoint = "https://rinkeby.infura.io"
}
clientApi, _ := url.Parse(apiEndpoint)
db, _ := mockDB.GetDatastoreForWallet(wallet.Ethereum)
ethCfg := CoinConfig{
CoinType: wallet.Ethereum,
FeeAPI: url.URL{},
LowFee: 140,
MediumFee: 160,
HighFee: 180,
MaxFee: 2000,
ClientAPI: *clientApi,
DB: db,
Options: map[string]interface{}{
"RegistryAddress": "0xab8dd0e05b73529b440d9c9df00b5f490c8596ff",
"RinkebyRegistryAddress": "0xab8dd0e05b73529b440d9c9df00b5f490c8596ff",
"RopstenRegistryAddress": "0x029d6a0cd4ce98315690f4ea52945545d9c0f460",
},
}
cfg.Coins = append(cfg.Coins, ethCfg)
}
return cfg
}
7 changes: 7 additions & 0 deletions datastore/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ func NewMockMultiwalletDatastore() *MockMultiwalletDatastore {
&MockTxnStore{txns: make(map[string]*txnStoreEntry)},
&MockWatchedScriptsStore{scripts: make(map[string][]byte)},
})
db[wallet.Ethereum] = wallet.Datastore(&MockDatastore{
&MockKeyStore{Keys: make(map[string]*KeyStoreEntry)},
&MockUtxoStore{utxos: make(map[string]*wallet.Utxo)},
&MockStxoStore{stxos: make(map[string]*wallet.Stxo)},
&MockTxnStore{txns: make(map[string]*txnStoreEntry)},
&MockWatchedScriptsStore{scripts: make(map[string][]byte)},
})
return &MockMultiwalletDatastore{db: db}
}

Expand Down
7 changes: 7 additions & 0 deletions multiwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"
"time"

eth "github.com/OpenBazaar/go-ethwallet/wallet"
"github.com/OpenBazaar/multiwallet/bitcoin"
"github.com/OpenBazaar/multiwallet/bitcoincash"
"github.com/OpenBazaar/multiwallet/client"
Expand Down Expand Up @@ -87,6 +88,12 @@ func NewMultiWallet(cfg *config.Config) (MultiWallet, error) {
} else {
multiwallet[wallet.TestnetLitecoin] = w
}
case wallet.Ethereum:
w, err = eth.NewEthereumWallet(coin, cfg.Mnemonic)
if err != nil {
return nil, err
}
multiwallet[coin.CoinType] = w
}
}
return multiwallet, nil
Expand Down

0 comments on commit 923b5b8

Please sign in to comment.