Begin update to use btcnet.Params.
This is an intial pass at converting the btcwallet and deps codebases to pass a network by their parameters, rather than by a magic number to identify the network. The parameters in params.go have been updated to embed a *btcnet.Params, and all previous uses of cfg.Net() have been replaced with activeNet.{Params,Net} (where activeNet is the global var for the active network). Although dependancy packages have not yet been updated from using btcwire.BitcoinNet to btcnet.Params, the parameters are now accessible at all callsites, and individual packages can be updated to use btcnet without requiring updates in each external btc* package at once. While here, the exported API for btcwallet internal library packages (txstore and wallet) have been updated to pass full network parameters rather than the btcwire definition of a network.
This commit is contained in:
parent
987dc8f1c4
commit
c3224f4fbc
12 changed files with 96 additions and 118 deletions
|
@ -83,7 +83,7 @@ func (a *Account) AddressUsed(addr btcutil.Address) bool {
|
||||||
credits := r.Credits()
|
credits := r.Credits()
|
||||||
for _, c := range credits {
|
for _, c := range credits {
|
||||||
// Extract addresses from this output's pkScript.
|
// Extract addresses from this output's pkScript.
|
||||||
_, addrs, _, err := c.Addresses(cfg.Net())
|
_, addrs, _, err := c.Addresses(activeNet.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ func (a *Account) CalculateAddressBalance(addr btcutil.Address, confirms int) fl
|
||||||
if credit.Confirmed(confirms, bs.Height) {
|
if credit.Confirmed(confirms, bs.Height) {
|
||||||
// We only care about the case where len(addrs) == 1, and err
|
// We only care about the case where len(addrs) == 1, and err
|
||||||
// will never be non-nil in that case
|
// will never be non-nil in that case
|
||||||
_, addrs, _, _ := credit.Addresses(cfg.Net())
|
_, addrs, _, _ := credit.Addresses(activeNet.Params)
|
||||||
if len(addrs) != 1 {
|
if len(addrs) != 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ func (a *Account) ListAddressTransactions(pkHashes map[string]struct{}) (
|
||||||
for _, c := range r.Credits() {
|
for _, c := range r.Credits() {
|
||||||
// We only care about the case where len(addrs) == 1,
|
// We only care about the case where len(addrs) == 1,
|
||||||
// and err will never be non-nil in that case.
|
// and err will never be non-nil in that case.
|
||||||
_, addrs, _, _ := c.Addresses(cfg.Net())
|
_, addrs, _, _ := c.Addresses(activeNet.Params)
|
||||||
if len(addrs) != 1 {
|
if len(addrs) != 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ func (a *Account) ImportPrivateKey(wif *btcutil.WIF, bs *wallet.BlockStamp,
|
||||||
// ExportToDirectory writes an account to a special export directory. Any
|
// ExportToDirectory writes an account to a special export directory. Any
|
||||||
// previous files are overwritten.
|
// previous files are overwritten.
|
||||||
func (a *Account) ExportToDirectory(dirBaseName string) error {
|
func (a *Account) ExportToDirectory(dirBaseName string) error {
|
||||||
dir := filepath.Join(networkDir(cfg.Net()), dirBaseName)
|
dir := filepath.Join(networkDir(activeNet.Params), dirBaseName)
|
||||||
if err := checkCreateDir(dir); err != nil {
|
if err := checkCreateDir(dir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
10
acctmgr.go
10
acctmgr.go
|
@ -170,7 +170,7 @@ var (
|
||||||
// openSavedAccount opens a named account from disk. If the wallet does not
|
// openSavedAccount opens a named account from disk. If the wallet does not
|
||||||
// exist, errNoWallet is returned as an error.
|
// exist, errNoWallet is returned as an error.
|
||||||
func openSavedAccount(name string, cfg *config) (*Account, error) {
|
func openSavedAccount(name string, cfg *config) (*Account, error) {
|
||||||
netdir := networkDir(cfg.Net())
|
netdir := networkDir(activeNet.Params)
|
||||||
if err := checkCreateDir(netdir); err != nil {
|
if err := checkCreateDir(netdir); err != nil {
|
||||||
return nil, &walletOpenError{
|
return nil, &walletOpenError{
|
||||||
Err: err.Error(),
|
Err: err.Error(),
|
||||||
|
@ -238,8 +238,8 @@ func openAccounts() *accountData {
|
||||||
// done for changing a wallet passphrase) and btcwallet closes after
|
// done for changing a wallet passphrase) and btcwallet closes after
|
||||||
// removing the network directory but before renaming the temporary
|
// removing the network directory but before renaming the temporary
|
||||||
// directory.
|
// directory.
|
||||||
netDir := networkDir(cfg.Net())
|
netDir := networkDir(activeNet.Params)
|
||||||
tmpNetDir := tmpNetworkDir(cfg.Net())
|
tmpNetDir := tmpNetworkDir(activeNet.Params)
|
||||||
if !fileExists(netDir) && fileExists(tmpNetDir) {
|
if !fileExists(netDir) && fileExists(tmpNetDir) {
|
||||||
if err := Rename(tmpNetDir, netDir); err != nil {
|
if err := Rename(tmpNetDir, netDir); err != nil {
|
||||||
log.Errorf("Cannot move temporary network dir: %v", err)
|
log.Errorf("Cannot move temporary network dir: %v", err)
|
||||||
|
@ -617,7 +617,7 @@ func (am *AccountManager) CreateEncryptedWallet(passphrase []byte) error {
|
||||||
|
|
||||||
// Create new wallet in memory.
|
// Create new wallet in memory.
|
||||||
wlt, err := wallet.NewWallet("", "Default acccount", passphrase,
|
wlt, err := wallet.NewWallet("", "Default acccount", passphrase,
|
||||||
cfg.Net(), &bs, cfg.KeypoolSize)
|
activeNet.Params, &bs, cfg.KeypoolSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -826,7 +826,7 @@ func (am *AccountManager) ListUnspent(minconf, maxconf int,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, addrs, _, _ := credit.Addresses(cfg.Net())
|
_, addrs, _, _ := credit.Addresses(activeNet.Params)
|
||||||
if filter {
|
if filter {
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
_, ok := addresses[addr.EncodeAddress()]
|
_, ok := addresses[addr.EncodeAddress()]
|
||||||
|
|
18
config.go
18
config.go
|
@ -208,7 +208,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
|
|
||||||
// Choose the active network params based on the mainnet net flag.
|
// Choose the active network params based on the mainnet net flag.
|
||||||
if cfg.MainNet {
|
if cfg.MainNet {
|
||||||
activeNetParams = netParams(btcwire.MainNet)
|
activeNet = &mainNetParams
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate debug log level
|
// Validate debug log level
|
||||||
|
@ -221,12 +221,11 @@ func loadConfig() (*config, []string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.RPCConnect == "" {
|
if cfg.RPCConnect == "" {
|
||||||
cfg.RPCConnect = activeNetParams.connect
|
cfg.RPCConnect = activeNet.connect
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add default port to connect flag if missing.
|
// Add default port to connect flag if missing.
|
||||||
cfg.RPCConnect = normalizeAddress(cfg.RPCConnect,
|
cfg.RPCConnect = normalizeAddress(cfg.RPCConnect, activeNet.btcdPort)
|
||||||
activeNetParams.btcdPort)
|
|
||||||
|
|
||||||
// If CAFile is unset, choose either the copy or local btcd cert.
|
// If CAFile is unset, choose either the copy or local btcd cert.
|
||||||
if cfg.CAFile == "" {
|
if cfg.CAFile == "" {
|
||||||
|
@ -261,7 +260,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
}
|
}
|
||||||
cfg.SvrListeners = make([]string, 0, len(addrs))
|
cfg.SvrListeners = make([]string, 0, len(addrs))
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
addr = net.JoinHostPort(addr, activeNetParams.svrPort)
|
addr = net.JoinHostPort(addr, activeNet.svrPort)
|
||||||
cfg.SvrListeners = append(cfg.SvrListeners, addr)
|
cfg.SvrListeners = append(cfg.SvrListeners, addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +268,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
// Add default port to all rpc listener addresses if needed and remove
|
// Add default port to all rpc listener addresses if needed and remove
|
||||||
// duplicate addresses.
|
// duplicate addresses.
|
||||||
cfg.SvrListeners = normalizeAddresses(cfg.SvrListeners,
|
cfg.SvrListeners = normalizeAddresses(cfg.SvrListeners,
|
||||||
activeNetParams.svrPort)
|
activeNet.svrPort)
|
||||||
|
|
||||||
// Expand environment variable and leading ~ for filepaths.
|
// Expand environment variable and leading ~ for filepaths.
|
||||||
cfg.CAFile = cleanAndExpandPath(cfg.CAFile)
|
cfg.CAFile = cleanAndExpandPath(cfg.CAFile)
|
||||||
|
@ -288,13 +287,6 @@ func loadConfig() (*config, []string, error) {
|
||||||
return &cfg, remainingArgs, nil
|
return &cfg, remainingArgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) Net() btcwire.BitcoinNet {
|
|
||||||
if cfg.MainNet {
|
|
||||||
return btcwire.MainNet
|
|
||||||
}
|
|
||||||
return btcwire.TestNet3
|
|
||||||
}
|
|
||||||
|
|
||||||
// validLogLevel returns whether or not logLevel is a valid debug log level.
|
// validLogLevel returns whether or not logLevel is a valid debug log level.
|
||||||
func validLogLevel(logLevel string) bool {
|
func validLogLevel(logLevel string) bool {
|
||||||
switch logLevel {
|
switch logLevel {
|
||||||
|
|
29
createtx.go
29
createtx.go
|
@ -20,25 +20,22 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/conformal/btcchain"
|
"github.com/conformal/btcchain"
|
||||||
"github.com/conformal/btcscript"
|
"github.com/conformal/btcscript"
|
||||||
"github.com/conformal/btcutil"
|
"github.com/conformal/btcutil"
|
||||||
"github.com/conformal/btcwallet/txstore"
|
"github.com/conformal/btcwallet/txstore"
|
||||||
"github.com/conformal/btcwallet/wallet"
|
"github.com/conformal/btcwallet/wallet"
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcwire"
|
||||||
"sort"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrInsufficientFunds represents an error where there are not enough
|
// ErrInsufficientFunds represents an error where there are not enough
|
||||||
// funds from unspent tx outputs for a wallet to create a transaction.
|
// funds from unspent tx outputs for a wallet to create a transaction.
|
||||||
var ErrInsufficientFunds = errors.New("insufficient funds")
|
var ErrInsufficientFunds = errors.New("insufficient funds")
|
||||||
|
|
||||||
// ErrUnknownBitcoinNet represents an error where the parsed or
|
|
||||||
// requested bitcoin network is invalid (neither mainnet nor testnet).
|
|
||||||
var ErrUnknownBitcoinNet = errors.New("unknown bitcoin network")
|
|
||||||
|
|
||||||
// ErrNonPositiveAmount represents an error where a bitcoin amount is
|
// ErrNonPositiveAmount represents an error where a bitcoin amount is
|
||||||
// not positive (either negative, or zero).
|
// not positive (either negative, or zero).
|
||||||
var ErrNonPositiveAmount = errors.New("amount is not positive")
|
var ErrNonPositiveAmount = errors.New("amount is not positive")
|
||||||
|
@ -71,17 +68,9 @@ type CreatedTx struct {
|
||||||
// sort a slice of Utxos by their amount.
|
// sort a slice of Utxos by their amount.
|
||||||
type ByAmount []*txstore.Credit
|
type ByAmount []*txstore.Credit
|
||||||
|
|
||||||
func (u ByAmount) Len() int {
|
func (u ByAmount) Len() int { return len(u) }
|
||||||
return len(u)
|
func (u ByAmount) Less(i, j int) bool { return u[i].Amount() < u[j].Amount() }
|
||||||
}
|
func (u ByAmount) Swap(i, j int) { u[i], u[j] = u[j], u[i] }
|
||||||
|
|
||||||
func (u ByAmount) Less(i, j int) bool {
|
|
||||||
return u[i].Amount() < u[j].Amount()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u ByAmount) Swap(i, j int) {
|
|
||||||
u[i], u[j] = u[j], u[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
// selectInputs selects the minimum number possible of unspent
|
// selectInputs selects the minimum number possible of unspent
|
||||||
// outputs to use to create a new transaction that spends amt satoshis.
|
// outputs to use to create a new transaction that spends amt satoshis.
|
||||||
|
@ -165,7 +154,7 @@ func (a *Account) txToPairs(pairs map[string]btcutil.Amount,
|
||||||
|
|
||||||
// Add outputs to new tx.
|
// Add outputs to new tx.
|
||||||
for addrStr, amt := range pairs {
|
for addrStr, amt := range pairs {
|
||||||
addr, err := btcutil.DecodeAddress(addrStr, cfg.Net())
|
addr, err := btcutil.DecodeAddress(addrStr, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot decode address: %s", err)
|
return nil, fmt.Errorf("cannot decode address: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -244,7 +233,7 @@ func (a *Account) txToPairs(pairs map[string]btcutil.Amount,
|
||||||
msgtx.AddTxIn(btcwire.NewTxIn(ip.OutPoint(), nil))
|
msgtx.AddTxIn(btcwire.NewTxIn(ip.OutPoint(), nil))
|
||||||
}
|
}
|
||||||
for i, input := range inputs {
|
for i, input := range inputs {
|
||||||
_, addrs, _, _ := input.Addresses(cfg.Net())
|
_, addrs, _, _ := input.Addresses(activeNet.Params)
|
||||||
if len(addrs) != 1 {
|
if len(addrs) != 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
25
disksync.go
25
disksync.go
|
@ -18,27 +18,34 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/conformal/btcwire"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/conformal/btcnet"
|
||||||
|
"github.com/conformal/btcwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// networkDir returns the directory name of a network directory to hold account
|
// networkDir returns the directory name of a network directory to hold account
|
||||||
// files.
|
// files.
|
||||||
func networkDir(net btcwire.BitcoinNet) string {
|
func networkDir(net *btcnet.Params) string {
|
||||||
var netname string
|
netname := net.Name
|
||||||
if net == btcwire.MainNet {
|
|
||||||
netname = "mainnet"
|
// For now, we must always name the testnet data directory as "testnet"
|
||||||
} else {
|
// and not "testnet3" or any other version, as the btcnet testnet3
|
||||||
|
// paramaters will likely be switched to being named "testnet3" in the
|
||||||
|
// future. This is done to future proof that change, and an upgrade
|
||||||
|
// plan to move the testnet3 data directory can be worked out later.
|
||||||
|
if net.Net == btcwire.TestNet3 {
|
||||||
netname = "testnet"
|
netname = "testnet"
|
||||||
}
|
}
|
||||||
|
|
||||||
return filepath.Join(cfg.DataDir, netname)
|
return filepath.Join(cfg.DataDir, netname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// tmpNetworkDir returns the temporary directory name for a given network.
|
// tmpNetworkDir returns the temporary directory name for a given network.
|
||||||
func tmpNetworkDir(net btcwire.BitcoinNet) string {
|
func tmpNetworkDir(net *btcnet.Params) string {
|
||||||
return networkDir(net) + "_tmp"
|
return networkDir(net) + "_tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,11 +225,11 @@ func (ds *DiskSyncer) Start() {
|
||||||
//
|
//
|
||||||
// This never returns and is should be called from a new goroutine.
|
// This never returns and is should be called from a new goroutine.
|
||||||
func (ds *DiskSyncer) handler() {
|
func (ds *DiskSyncer) handler() {
|
||||||
netdir := networkDir(cfg.Net())
|
netdir := networkDir(activeNet.Params)
|
||||||
if err := checkCreateDir(netdir); err != nil {
|
if err := checkCreateDir(netdir); err != nil {
|
||||||
log.Errorf("Unable to create or write to account directory: %v", err)
|
log.Errorf("Unable to create or write to account directory: %v", err)
|
||||||
}
|
}
|
||||||
tmpnetdir := tmpNetworkDir(cfg.Net())
|
tmpnetdir := tmpNetworkDir(activeNet.Params)
|
||||||
|
|
||||||
const wait = 10 * time.Second
|
const wait = 10 * time.Second
|
||||||
var timer <-chan time.Time
|
var timer <-chan time.Time
|
||||||
|
|
2
ntfns.go
2
ntfns.go
|
@ -108,7 +108,7 @@ func NtfnRecvTx(n btcjson.Cmd) error {
|
||||||
// and record the received txout.
|
// and record the received txout.
|
||||||
for outIdx, txout := range tx.MsgTx().TxOut {
|
for outIdx, txout := range tx.MsgTx().TxOut {
|
||||||
var accounts []*Account
|
var accounts []*Account
|
||||||
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, cfg.Net())
|
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, activeNet.Net)
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
a, err := AcctMgr.AccountByAddress(addr)
|
a, err := AcctMgr.AccountByAddress(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
21
params.go
21
params.go
|
@ -17,14 +17,15 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcnet"
|
||||||
)
|
)
|
||||||
|
|
||||||
var activeNetParams = netParams(defaultBtcNet)
|
var activeNet = &testNet3Params
|
||||||
|
|
||||||
// params is used to group parameters for various networks such as the main
|
// params is used to group parameters for various networks such as the main
|
||||||
// network and test networks.
|
// network and test networks.
|
||||||
type params struct {
|
type params struct {
|
||||||
|
*btcnet.Params
|
||||||
connect string
|
connect string
|
||||||
btcdPort string
|
btcdPort string
|
||||||
svrPort string
|
svrPort string
|
||||||
|
@ -33,6 +34,7 @@ type params struct {
|
||||||
// mainNetParams contains parameters specific running btcwallet and
|
// mainNetParams contains parameters specific running btcwallet and
|
||||||
// btcd on the main network (btcwire.MainNet).
|
// btcd on the main network (btcwire.MainNet).
|
||||||
var mainNetParams = params{
|
var mainNetParams = params{
|
||||||
|
Params: &btcnet.MainNetParams,
|
||||||
connect: "localhost:8334",
|
connect: "localhost:8334",
|
||||||
btcdPort: "8334",
|
btcdPort: "8334",
|
||||||
svrPort: "8332",
|
svrPort: "8332",
|
||||||
|
@ -41,21 +43,8 @@ var mainNetParams = params{
|
||||||
// testNet3Params contains parameters specific running btcwallet and
|
// testNet3Params contains parameters specific running btcwallet and
|
||||||
// btcd on the test network (version 3) (btcwire.TestNet3).
|
// btcd on the test network (version 3) (btcwire.TestNet3).
|
||||||
var testNet3Params = params{
|
var testNet3Params = params{
|
||||||
|
Params: &btcnet.TestNet3Params,
|
||||||
connect: "localhost:18334",
|
connect: "localhost:18334",
|
||||||
btcdPort: "18334",
|
btcdPort: "18334",
|
||||||
svrPort: "18332",
|
svrPort: "18332",
|
||||||
}
|
}
|
||||||
|
|
||||||
// netParams returns parameters specific to the passed bitcoin network.
|
|
||||||
func netParams(btcnet btcwire.BitcoinNet) *params {
|
|
||||||
switch btcnet {
|
|
||||||
case btcwire.TestNet3:
|
|
||||||
return &testNet3Params
|
|
||||||
|
|
||||||
// Return main net by default.
|
|
||||||
case btcwire.MainNet:
|
|
||||||
fallthrough
|
|
||||||
default:
|
|
||||||
return &mainNetParams
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
38
rpcserver.go
38
rpcserver.go
|
@ -277,7 +277,7 @@ func makeMultiSigScript(keys []string, nRequired int) ([]byte, *btcjson.Error) {
|
||||||
// mixture of the two.
|
// mixture of the two.
|
||||||
for i, a := range keys {
|
for i, a := range keys {
|
||||||
// try to parse as pubkey address
|
// try to parse as pubkey address
|
||||||
a, err := btcutil.DecodeAddress(a, cfg.Net())
|
a, err := btcutil.DecodeAddress(a, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.Error{
|
return nil, &btcjson.Error{
|
||||||
Code: btcjson.ErrParse.Code,
|
Code: btcjson.ErrParse.Code,
|
||||||
|
@ -301,7 +301,7 @@ func makeMultiSigScript(keys []string, nRequired int) ([]byte, *btcjson.Error) {
|
||||||
|
|
||||||
// This will be an addresspubkey
|
// This will be an addresspubkey
|
||||||
a, err := btcutil.DecodeAddress(apkinfo.ExportPubKey(),
|
a, err := btcutil.DecodeAddress(apkinfo.ExportPubKey(),
|
||||||
cfg.Net())
|
activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.Error{
|
return nil, &btcjson.Error{
|
||||||
Code: btcjson.ErrParse.Code,
|
Code: btcjson.ErrParse.Code,
|
||||||
|
@ -384,7 +384,7 @@ func CreateMultiSig(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
return nil, jsonerr
|
return nil, jsonerr
|
||||||
}
|
}
|
||||||
|
|
||||||
address, err := btcutil.NewAddressScriptHash(script, cfg.Net())
|
address, err := btcutil.NewAddressScriptHash(script, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// above is a valid script, shouldn't happen.
|
// above is a valid script, shouldn't happen.
|
||||||
return nil, &btcjson.Error{
|
return nil, &btcjson.Error{
|
||||||
|
@ -409,7 +409,7 @@ func DumpPrivKey(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
return nil, &btcjson.ErrInternal
|
return nil, &btcjson.ErrInternal
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err := btcutil.DecodeAddress(cmd.Address, cfg.Net())
|
addr, err := btcutil.DecodeAddress(cmd.Address, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.ErrInvalidAddressOrKey
|
return nil, &btcjson.ErrInvalidAddressOrKey
|
||||||
}
|
}
|
||||||
|
@ -616,11 +616,11 @@ func GetAccount(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is address valid?
|
// Is address valid?
|
||||||
addr, err := btcutil.DecodeAddress(cmd.Address, cfg.Net())
|
addr, err := btcutil.DecodeAddress(cmd.Address, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.ErrInvalidAddressOrKey
|
return nil, &btcjson.ErrInvalidAddressOrKey
|
||||||
}
|
}
|
||||||
if !addr.IsForNet(cfg.Net()) {
|
if !addr.IsForNet(activeNet.Net) {
|
||||||
return nil, &btcjson.ErrInvalidAddressOrKey
|
return nil, &btcjson.ErrInvalidAddressOrKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ func GetAddressBalance(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is address valid?
|
// Is address valid?
|
||||||
addr, err := btcutil.DecodeAddress(cmd.Address, cfg.Net())
|
addr, err := btcutil.DecodeAddress(cmd.Address, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.ErrInvalidAddressOrKey
|
return nil, &btcjson.ErrInvalidAddressOrKey
|
||||||
}
|
}
|
||||||
|
@ -970,7 +970,7 @@ func GetTransaction(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
received += cred.Amount()
|
received += cred.Amount()
|
||||||
|
|
||||||
var addr string
|
var addr string
|
||||||
_, addrs, _, _ := cred.Addresses(cfg.Net())
|
_, addrs, _, _ := cred.Addresses(activeNet.Params)
|
||||||
if len(addrs) == 1 {
|
if len(addrs) == 1 {
|
||||||
addr = addrs[0].EncodeAddress()
|
addr = addrs[0].EncodeAddress()
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ func GetTransaction(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
Amount: (-debits.OutputAmount(true)).ToUnit(btcutil.AmountBTC),
|
Amount: (-debits.OutputAmount(true)).ToUnit(btcutil.AmountBTC),
|
||||||
Fee: debits.Fee().ToUnit(btcutil.AmountBTC),
|
Fee: debits.Fee().ToUnit(btcutil.AmountBTC),
|
||||||
}
|
}
|
||||||
_, addrs, _, _ := debitTx.Credits()[0].Addresses(cfg.Net())
|
_, addrs, _, _ := debitTx.Credits()[0].Addresses(activeNet.Params)
|
||||||
if len(addrs) == 1 {
|
if len(addrs) == 1 {
|
||||||
info.Address = addrs[0].EncodeAddress()
|
info.Address = addrs[0].EncodeAddress()
|
||||||
}
|
}
|
||||||
|
@ -1220,12 +1220,12 @@ func ListAddressTransactions(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
// Decode addresses.
|
// Decode addresses.
|
||||||
pkHashMap := make(map[string]struct{})
|
pkHashMap := make(map[string]struct{})
|
||||||
for _, addrStr := range cmd.Addresses {
|
for _, addrStr := range cmd.Addresses {
|
||||||
addr, err := btcutil.DecodeAddress(addrStr, cfg.Net())
|
addr, err := btcutil.DecodeAddress(addrStr, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.ErrInvalidAddressOrKey
|
return nil, &btcjson.ErrInvalidAddressOrKey
|
||||||
}
|
}
|
||||||
apkh, ok := addr.(*btcutil.AddressPubKeyHash)
|
apkh, ok := addr.(*btcutil.AddressPubKeyHash)
|
||||||
if !ok || !apkh.IsForNet(cfg.Net()) {
|
if !ok || !apkh.IsForNet(activeNet.Net) {
|
||||||
return nil, &btcjson.ErrInvalidAddressOrKey
|
return nil, &btcjson.ErrInvalidAddressOrKey
|
||||||
}
|
}
|
||||||
pkHashMap[string(addr.ScriptAddress())] = struct{}{}
|
pkHashMap[string(addr.ScriptAddress())] = struct{}{}
|
||||||
|
@ -1300,7 +1300,7 @@ func ListUnspent(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
if len(cmd.Addresses) != 0 {
|
if len(cmd.Addresses) != 0 {
|
||||||
// confirm that all of them are good:
|
// confirm that all of them are good:
|
||||||
for _, as := range cmd.Addresses {
|
for _, as := range cmd.Addresses {
|
||||||
a, err := btcutil.DecodeAddress(as, cfg.Net())
|
a, err := btcutil.DecodeAddress(as, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.ErrInvalidAddressOrKey
|
return nil, &btcjson.ErrInvalidAddressOrKey
|
||||||
}
|
}
|
||||||
|
@ -1635,7 +1635,7 @@ func SignMessage(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
return nil, &btcjson.ErrInternal
|
return nil, &btcjson.ErrInternal
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err := btcutil.DecodeAddress(cmd.Address, cfg.Net())
|
addr, err := btcutil.DecodeAddress(cmd.Address, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.Error{
|
return nil, &btcjson.Error{
|
||||||
Code: btcjson.ErrParse.Code,
|
Code: btcjson.ErrParse.Code,
|
||||||
|
@ -1800,7 +1800,7 @@ func SignRawTransaction(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err := btcutil.NewAddressScriptHash(redeemScript,
|
addr, err := btcutil.NewAddressScriptHash(redeemScript,
|
||||||
cfg.Net())
|
activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.Error{
|
return nil, &btcjson.Error{
|
||||||
Code: btcjson.ErrDeserialization.Code,
|
Code: btcjson.ErrDeserialization.Code,
|
||||||
|
@ -1861,7 +1861,7 @@ func SignRawTransaction(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !wif.IsForNet(cfg.Net()) {
|
if !wif.IsForNet(activeNet.Net) {
|
||||||
return nil, &btcjson.Error{
|
return nil, &btcjson.Error{
|
||||||
Code: btcjson.ErrDeserialization.Code,
|
Code: btcjson.ErrDeserialization.Code,
|
||||||
Message: "key network doesn't match " +
|
Message: "key network doesn't match " +
|
||||||
|
@ -1870,7 +1870,7 @@ func SignRawTransaction(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err := btcutil.NewAddressPubKey(wif.SerializePubKey(),
|
addr, err := btcutil.NewAddressPubKey(wif.SerializePubKey(),
|
||||||
cfg.Net())
|
activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.Error{
|
return nil, &btcjson.Error{
|
||||||
Code: btcjson.ErrDeserialization.Code,
|
Code: btcjson.ErrDeserialization.Code,
|
||||||
|
@ -2017,7 +2017,7 @@ func SignRawTransaction(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
if (hashType&btcscript.SigHashSingle) == 0 ||
|
if (hashType&btcscript.SigHashSingle) == 0 ||
|
||||||
i < len(msgTx.TxOut) {
|
i < len(msgTx.TxOut) {
|
||||||
|
|
||||||
script, err := btcscript.SignTxOutput(cfg.Net(),
|
script, err := btcscript.SignTxOutput(activeNet.Net,
|
||||||
msgTx, i, input, byte(hashType), getKey,
|
msgTx, i, input, byte(hashType), getKey,
|
||||||
getScript, txIn.SignatureScript)
|
getScript, txIn.SignatureScript)
|
||||||
// Failure to sign isn't an error, it just means that
|
// Failure to sign isn't an error, it just means that
|
||||||
|
@ -2060,7 +2060,7 @@ func ValidateAddress(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
result := btcjson.ValidateAddressResult{}
|
result := btcjson.ValidateAddressResult{}
|
||||||
addr, err := btcutil.DecodeAddress(cmd.Address, cfg.Net())
|
addr, err := btcutil.DecodeAddress(cmd.Address, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
@ -2116,7 +2116,7 @@ func VerifyMessage(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
return nil, &btcjson.ErrInternal
|
return nil, &btcjson.ErrInternal
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err := btcutil.DecodeAddress(cmd.Address, cfg.Net())
|
addr, err := btcutil.DecodeAddress(cmd.Address, activeNet.Net)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &btcjson.Error{
|
return nil, &btcjson.Error{
|
||||||
Code: btcjson.ErrParse.Code,
|
Code: btcjson.ErrParse.Code,
|
||||||
|
|
|
@ -702,7 +702,7 @@ func Handshake(rpc ServerConn) error {
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
return jsonErr
|
return jsonErr
|
||||||
}
|
}
|
||||||
if net != cfg.Net() {
|
if net != activeNet.Net {
|
||||||
return errors.New("btcd and btcwallet running on different Bitcoin networks")
|
return errors.New("btcd and btcwallet running on different Bitcoin networks")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/conformal/btcchain"
|
"github.com/conformal/btcchain"
|
||||||
|
"github.com/conformal/btcnet"
|
||||||
"github.com/conformal/btcscript"
|
"github.com/conformal/btcscript"
|
||||||
"github.com/conformal/btcutil"
|
"github.com/conformal/btcutil"
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcwire"
|
||||||
|
@ -1282,12 +1283,12 @@ func (d *Debits) Fee() btcutil.Amount {
|
||||||
|
|
||||||
// Addresses parses the pubkey script, extracting all addresses for a
|
// Addresses parses the pubkey script, extracting all addresses for a
|
||||||
// standard script.
|
// standard script.
|
||||||
func (c *Credit) Addresses(net btcwire.BitcoinNet) (btcscript.ScriptClass,
|
func (c *Credit) Addresses(net *btcnet.Params) (btcscript.ScriptClass,
|
||||||
[]btcutil.Address, int, error) {
|
[]btcutil.Address, int, error) {
|
||||||
|
|
||||||
msgTx := c.Tx().MsgTx()
|
msgTx := c.Tx().MsgTx()
|
||||||
pkScript := msgTx.TxOut[c.OutputIndex].PkScript
|
pkScript := msgTx.TxOut[c.OutputIndex].PkScript
|
||||||
return btcscript.ExtractPkScriptAddrs(pkScript, net)
|
return btcscript.ExtractPkScriptAddrs(pkScript, net.Net)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change returns whether the credit is the result of a change output.
|
// Change returns whether the credit is the result of a change output.
|
||||||
|
|
|
@ -18,7 +18,6 @@ package wallet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"code.google.com/p/go.crypto/ripemd160"
|
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
@ -29,13 +28,17 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/conformal/btcec"
|
|
||||||
"github.com/conformal/btcscript"
|
|
||||||
"github.com/conformal/btcutil"
|
|
||||||
"github.com/conformal/btcwire"
|
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"code.google.com/p/go.crypto/ripemd160"
|
||||||
|
|
||||||
|
"github.com/conformal/btcec"
|
||||||
|
"github.com/conformal/btcnet"
|
||||||
|
"github.com/conformal/btcscript"
|
||||||
|
"github.com/conformal/btcutil"
|
||||||
|
"github.com/conformal/btcwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -527,7 +530,7 @@ type Wallet struct {
|
||||||
// desc's binary representation must not exceed 32 and 256 bytes,
|
// desc's binary representation must not exceed 32 and 256 bytes,
|
||||||
// respectively. All address private keys are encrypted with passphrase.
|
// respectively. All address private keys are encrypted with passphrase.
|
||||||
// The wallet is returned locked.
|
// The wallet is returned locked.
|
||||||
func NewWallet(name, desc string, passphrase []byte, net btcwire.BitcoinNet,
|
func NewWallet(name, desc string, passphrase []byte, net *btcnet.Params,
|
||||||
createdAt *BlockStamp, keypoolSize uint) (*Wallet, error) {
|
createdAt *BlockStamp, keypoolSize uint) (*Wallet, error) {
|
||||||
|
|
||||||
// Check sizes of inputs.
|
// Check sizes of inputs.
|
||||||
|
@ -538,11 +541,6 @@ func NewWallet(name, desc string, passphrase []byte, net btcwire.BitcoinNet,
|
||||||
return nil, errors.New("desc exceeds 256 byte maximum size")
|
return nil, errors.New("desc exceeds 256 byte maximum size")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for a valid network.
|
|
||||||
if !(net == btcwire.MainNet || net == btcwire.TestNet3) {
|
|
||||||
return nil, errors.New("wallets must use mainnet or testnet3")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Randomly-generate rootkey and chaincode.
|
// Randomly-generate rootkey and chaincode.
|
||||||
rootkey, chaincode := make([]byte, 32), make([]byte, 32)
|
rootkey, chaincode := make([]byte, 32), make([]byte, 32)
|
||||||
if _, err := rand.Read(rootkey); err != nil {
|
if _, err := rand.Read(rootkey); err != nil {
|
||||||
|
@ -562,7 +560,7 @@ func NewWallet(name, desc string, passphrase []byte, net btcwire.BitcoinNet,
|
||||||
// Create and fill wallet.
|
// Create and fill wallet.
|
||||||
w := &Wallet{
|
w := &Wallet{
|
||||||
vers: VersCurrent,
|
vers: VersCurrent,
|
||||||
net: net,
|
net: net.Net,
|
||||||
flags: walletFlags{
|
flags: walletFlags{
|
||||||
useEncryption: true,
|
useEncryption: true,
|
||||||
watchingOnly: false,
|
watchingOnly: false,
|
||||||
|
|
|
@ -20,20 +20,22 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"github.com/conformal/btcec"
|
|
||||||
"github.com/conformal/btcscript"
|
|
||||||
"github.com/conformal/btcutil"
|
|
||||||
"github.com/conformal/btcwire"
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/conformal/btcec"
|
||||||
|
"github.com/conformal/btcnet"
|
||||||
|
"github.com/conformal/btcscript"
|
||||||
|
"github.com/conformal/btcutil"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = spew.Dump
|
var netParams = &btcnet.MainNetParams
|
||||||
|
|
||||||
func TestBtcAddressSerializer(t *testing.T) {
|
func TestBtcAddressSerializer(t *testing.T) {
|
||||||
fakeWallet := &Wallet{net: btcwire.TestNet3}
|
fakeWallet := &Wallet{net: netParams.Net}
|
||||||
kdfp := &kdfParameters{
|
kdfp := &kdfParameters{
|
||||||
mem: 1024,
|
mem: 1024,
|
||||||
nIter: 5,
|
nIter: 5,
|
||||||
|
@ -86,7 +88,7 @@ func TestBtcAddressSerializer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestScriptAddressSerializer(t *testing.T) {
|
func TestScriptAddressSerializer(t *testing.T) {
|
||||||
fakeWallet := &Wallet{net: btcwire.TestNet3}
|
fakeWallet := &Wallet{net: netParams.Net}
|
||||||
script := []byte{btcscript.OP_TRUE, btcscript.OP_DUP,
|
script := []byte{btcscript.OP_TRUE, btcscript.OP_DUP,
|
||||||
btcscript.OP_DROP}
|
btcscript.OP_DROP}
|
||||||
addr, err := newScriptAddress(fakeWallet, script, &BlockStamp{})
|
addr, err := newScriptAddress(fakeWallet, script, &BlockStamp{})
|
||||||
|
@ -118,7 +120,7 @@ func TestScriptAddressSerializer(t *testing.T) {
|
||||||
func TestWalletCreationSerialization(t *testing.T) {
|
func TestWalletCreationSerialization(t *testing.T) {
|
||||||
createdAt := &BlockStamp{}
|
createdAt := &BlockStamp{}
|
||||||
w1, err := NewWallet("banana wallet", "A wallet for testing.",
|
w1, err := NewWallet("banana wallet", "A wallet for testing.",
|
||||||
[]byte("banana"), btcwire.MainNet, createdAt, 100)
|
[]byte("banana"), netParams, createdAt, 100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error creating new wallet: " + err.Error())
|
t.Error("Error creating new wallet: " + err.Error())
|
||||||
return
|
return
|
||||||
|
@ -330,7 +332,7 @@ func TestWalletPubkeyChaining(t *testing.T) {
|
||||||
const keypoolSize = 5
|
const keypoolSize = 5
|
||||||
|
|
||||||
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
||||||
[]byte("banana"), btcwire.MainNet, &BlockStamp{}, keypoolSize)
|
[]byte("banana"), netParams, &BlockStamp{}, keypoolSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error creating new wallet: " + err.Error())
|
t.Error("Error creating new wallet: " + err.Error())
|
||||||
return
|
return
|
||||||
|
@ -506,7 +508,7 @@ func TestWatchingWalletExport(t *testing.T) {
|
||||||
const keypoolSize = 10
|
const keypoolSize = 10
|
||||||
createdAt := &BlockStamp{}
|
createdAt := &BlockStamp{}
|
||||||
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
||||||
[]byte("banana"), btcwire.MainNet, createdAt, keypoolSize)
|
[]byte("banana"), netParams, createdAt, keypoolSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error creating new wallet: " + err.Error())
|
t.Error("Error creating new wallet: " + err.Error())
|
||||||
return
|
return
|
||||||
|
@ -715,7 +717,7 @@ func TestWatchingWalletExport(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pk, _ := btcec.PrivKeyFromBytes(btcec.S256(), make([]byte, 32))
|
pk, _ := btcec.PrivKeyFromBytes(btcec.S256(), make([]byte, 32))
|
||||||
wif, err := btcutil.NewWIF(pk, btcwire.MainNet, true)
|
wif, err := btcutil.NewWIF(pk, netParams.Net, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -730,7 +732,7 @@ func TestImportPrivateKey(t *testing.T) {
|
||||||
createHeight := int32(100)
|
createHeight := int32(100)
|
||||||
createdAt := &BlockStamp{Height: createHeight}
|
createdAt := &BlockStamp{Height: createHeight}
|
||||||
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
||||||
[]byte("banana"), btcwire.MainNet, createdAt, keypoolSize)
|
[]byte("banana"), netParams, createdAt, keypoolSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error creating new wallet: " + err.Error())
|
t.Error("Error creating new wallet: " + err.Error())
|
||||||
return
|
return
|
||||||
|
@ -759,7 +761,7 @@ func TestImportPrivateKey(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// import priv key
|
// import priv key
|
||||||
wif, err := btcutil.NewWIF((*btcec.PrivateKey)(pk), btcwire.MainNet, false)
|
wif, err := btcutil.NewWIF((*btcec.PrivateKey)(pk), netParams.Net, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -925,7 +927,7 @@ func TestImportScript(t *testing.T) {
|
||||||
createHeight := int32(100)
|
createHeight := int32(100)
|
||||||
createdAt := &BlockStamp{Height: createHeight}
|
createdAt := &BlockStamp{Height: createHeight}
|
||||||
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
||||||
[]byte("banana"), btcwire.MainNet, createdAt, keypoolSize)
|
[]byte("banana"), netParams, createdAt, keypoolSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error creating new wallet: " + err.Error())
|
t.Error("Error creating new wallet: " + err.Error())
|
||||||
return
|
return
|
||||||
|
@ -1196,7 +1198,7 @@ func TestChangePassphrase(t *testing.T) {
|
||||||
const keypoolSize = 10
|
const keypoolSize = 10
|
||||||
createdAt := &BlockStamp{}
|
createdAt := &BlockStamp{}
|
||||||
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
w, err := NewWallet("banana wallet", "A wallet for testing.",
|
||||||
[]byte("banana"), btcwire.MainNet, createdAt, keypoolSize)
|
[]byte("banana"), netParams, createdAt, keypoolSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error creating new wallet: " + err.Error())
|
t.Error("Error creating new wallet: " + err.Error())
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue