Use forked version of btcutil
parent
d50198cbff
commit
a130318601
|
@ -49,12 +49,6 @@
|
|||
packages = ["ripemd160"]
|
||||
revision = "53f62d9b43e87a6c56975cf862af7edf33a8d0df"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/cpacia/bchutil"
|
||||
packages = ["."]
|
||||
revision = "12e86f41eb040d3b85b5d8e3a3a4bed035517c52"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/dchest/blake256"
|
||||
packages = ["."]
|
||||
|
@ -121,6 +115,18 @@
|
|||
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/jakm/bchutil"
|
||||
packages = ["."]
|
||||
revision = "9e4fc13b082c87967b0befbcbad6fe5a5aa5ac1a"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/jakm/btcutil"
|
||||
packages = [".","base58","bech32","chaincfg","txscript"]
|
||||
revision = "a45c5a6a9cb32f0caecb14a4e5a8f82640be1f39"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/juju/errors"
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
"blockbook/bchain/coins/btc"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/cpacia/bchutil"
|
||||
"github.com/jakm/bchutil"
|
||||
"github.com/jakm/btcutil"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
"github.com/jakm/btcutil/txscript"
|
||||
"github.com/schancel/cashaddr-converter/address"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"encoding/json"
|
||||
"math/big"
|
||||
|
||||
"github.com/cpacia/bchutil"
|
||||
"github.com/golang/glog"
|
||||
"github.com/jakm/bchutil"
|
||||
"github.com/juju/errors"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ import (
|
|||
|
||||
vlq "github.com/bsm/go-vlq"
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/jakm/btcutil"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
"github.com/jakm/btcutil/txscript"
|
||||
)
|
||||
|
||||
// OutputScriptToAddressesFunc converts ScriptPubKey to bitcoin addresses
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -27,8 +27,8 @@ func init() {
|
|||
MainNetParams.Net = MainnetMagic
|
||||
|
||||
// Address encoding magics
|
||||
MainNetParams.PubKeyHashAddrID = 38 // base58 prefix: G
|
||||
MainNetParams.ScriptHashAddrID = 23 // base58 prefix: A
|
||||
MainNetParams.PubKeyHashAddrID = []byte{38} // base58 prefix: G
|
||||
MainNetParams.ScriptHashAddrID = []byte{23} // base58 prefix: A
|
||||
|
||||
TestNetParams = chaincfg.TestNet3Params
|
||||
TestNetParams.Net = TestnetMagic
|
||||
|
|
|
@ -3,8 +3,8 @@ package dash
|
|||
import (
|
||||
"blockbook/bchain/coins/btc"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -24,22 +24,22 @@ func init() {
|
|||
MainNetParams.Net = MainnetMagic
|
||||
|
||||
// Address encoding magics
|
||||
MainNetParams.PubKeyHashAddrID = 76 // base58 prefix: X
|
||||
MainNetParams.ScriptHashAddrID = 16 // base58 prefix: 7
|
||||
MainNetParams.PubKeyHashAddrID = []byte{76} // base58 prefix: X
|
||||
MainNetParams.ScriptHashAddrID = []byte{16} // base58 prefix: 7
|
||||
|
||||
TestNetParams = chaincfg.TestNet3Params
|
||||
TestNetParams.Net = TestnetMagic
|
||||
|
||||
// Address encoding magics
|
||||
TestNetParams.PubKeyHashAddrID = 140 // base58 prefix: y
|
||||
TestNetParams.ScriptHashAddrID = 19 // base58 prefix: 8 or 9
|
||||
TestNetParams.PubKeyHashAddrID = []byte{140} // base58 prefix: y
|
||||
TestNetParams.ScriptHashAddrID = []byte{19} // base58 prefix: 8 or 9
|
||||
|
||||
RegtestParams = chaincfg.RegressionNetParams
|
||||
RegtestParams.Net = RegtestMagic
|
||||
|
||||
// Address encoding magics
|
||||
RegtestParams.PubKeyHashAddrID = 140 // base58 prefix: y
|
||||
RegtestParams.ScriptHashAddrID = 19 // base58 prefix: 8 or 9
|
||||
RegtestParams.PubKeyHashAddrID = []byte{140} // base58 prefix: y
|
||||
RegtestParams.ScriptHashAddrID = []byte{19} // base58 prefix: 8 or 9
|
||||
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
if err == nil {
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"blockbook/bchain/coins/utils"
|
||||
"bytes"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -21,8 +21,8 @@ var (
|
|||
func init() {
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
MainNetParams.PubKeyHashAddrID = 30
|
||||
MainNetParams.ScriptHashAddrID = 22
|
||||
MainNetParams.PubKeyHashAddrID = []byte{30}
|
||||
MainNetParams.ScriptHashAddrID = []byte{22}
|
||||
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
if err != nil {
|
||||
|
|
|
@ -3,8 +3,8 @@ package litecoin
|
|||
import (
|
||||
"blockbook/bchain/coins/btc"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -21,14 +21,14 @@ var (
|
|||
func init() {
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
MainNetParams.PubKeyHashAddrID = 48
|
||||
MainNetParams.ScriptHashAddrID = 50
|
||||
MainNetParams.PubKeyHashAddrID = []byte{48}
|
||||
MainNetParams.ScriptHashAddrID = []byte{50}
|
||||
MainNetParams.Bech32HRPSegwit = "ltc"
|
||||
|
||||
TestNetParams = chaincfg.TestNet3Params
|
||||
TestNetParams.Net = TestnetMagic
|
||||
TestNetParams.PubKeyHashAddrID = 111
|
||||
TestNetParams.ScriptHashAddrID = 58
|
||||
TestNetParams.PubKeyHashAddrID = []byte{111}
|
||||
TestNetParams.ScriptHashAddrID = []byte{58}
|
||||
TestNetParams.Bech32HRPSegwit = "tltc"
|
||||
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"blockbook/bchain"
|
||||
"blockbook/bchain/coins/btc"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
monacoinCfg "github.com/wakiyamap/monad/chaincfg"
|
||||
"github.com/wakiyamap/monad/txscript"
|
||||
monacoinWire "github.com/wakiyamap/monad/wire"
|
||||
|
@ -29,8 +29,8 @@ var (
|
|||
func init() {
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
MainNetParams.PubKeyHashAddrID = 50
|
||||
MainNetParams.ScriptHashAddrID = 55
|
||||
MainNetParams.PubKeyHashAddrID = []byte{50}
|
||||
MainNetParams.ScriptHashAddrID = []byte{55}
|
||||
MainNetParams.Bech32HRPSegwit = "mona"
|
||||
MonaMainParams = monacoinCfg.MainNetParams
|
||||
MonaMainParams.Net = MonaMainMagic
|
||||
|
@ -40,8 +40,8 @@ func init() {
|
|||
|
||||
TestNetParams = chaincfg.TestNet3Params
|
||||
TestNetParams.Net = TestnetMagic
|
||||
TestNetParams.PubKeyHashAddrID = 111
|
||||
TestNetParams.ScriptHashAddrID = 117
|
||||
TestNetParams.PubKeyHashAddrID = []byte{111}
|
||||
TestNetParams.ScriptHashAddrID = []byte{117}
|
||||
TestNetParams.Bech32HRPSegwit = "tmona"
|
||||
MonaTestParams = monacoinCfg.TestNet4Params
|
||||
MonaTestParams.Net = MonaTestMagic
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"blockbook/bchain/coins/utils"
|
||||
"bytes"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -21,8 +21,8 @@ var (
|
|||
func init() {
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
MainNetParams.PubKeyHashAddrID = 52
|
||||
MainNetParams.ScriptHashAddrID = 13
|
||||
MainNetParams.PubKeyHashAddrID = []byte{52}
|
||||
MainNetParams.ScriptHashAddrID = []byte{13}
|
||||
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
|
||||
"github.com/btcsuite/btcutil/base58"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrChecksumMismatch describes an error where decoding failed due
|
||||
// to a bad checksum.
|
||||
ErrChecksumMismatch = errors.New("checksum mismatch")
|
||||
|
||||
// ErrInvalidFormat describes an error where decoding failed due to invalid version
|
||||
ErrInvalidFormat = errors.New("invalid format: version and/or checksum bytes missing")
|
||||
)
|
||||
|
||||
// checksum: first four bytes of sha256^2
|
||||
func checksum(input []byte) (cksum [4]byte) {
|
||||
h := sha256.Sum256(input)
|
||||
h2 := sha256.Sum256(h[:])
|
||||
copy(cksum[:], h2[:4])
|
||||
return
|
||||
}
|
||||
|
||||
// CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.
|
||||
func CheckDecode(input string) (result []byte, version []byte, err error) {
|
||||
decoded := base58.Decode(input)
|
||||
if len(decoded) < 5 {
|
||||
return nil, nil, ErrInvalidFormat
|
||||
}
|
||||
version = append(version, decoded[0:2]...)
|
||||
var cksum [4]byte
|
||||
copy(cksum[:], decoded[len(decoded)-4:])
|
||||
if checksum(decoded[:len(decoded)-4]) != cksum {
|
||||
return nil, nil, ErrChecksumMismatch
|
||||
}
|
||||
payload := decoded[2 : len(decoded)-4]
|
||||
result = append(result, payload...)
|
||||
return
|
||||
}
|
|
@ -3,8 +3,8 @@ package vertcoin
|
|||
import (
|
||||
"blockbook/bchain/coins/btc"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -21,14 +21,14 @@ var (
|
|||
func init() {
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
MainNetParams.PubKeyHashAddrID = 71
|
||||
MainNetParams.ScriptHashAddrID = 5
|
||||
MainNetParams.PubKeyHashAddrID = []byte{71}
|
||||
MainNetParams.ScriptHashAddrID = []byte{5}
|
||||
MainNetParams.Bech32HRPSegwit = "vtc"
|
||||
|
||||
TestNetParams = chaincfg.TestNet3Params
|
||||
TestNetParams.Net = TestnetMagic
|
||||
TestNetParams.PubKeyHashAddrID = 74
|
||||
TestNetParams.ScriptHashAddrID = 196
|
||||
TestNetParams.PubKeyHashAddrID = []byte{74}
|
||||
TestNetParams.ScriptHashAddrID = []byte{196}
|
||||
TestNetParams.Bech32HRPSegwit = "tvtc"
|
||||
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
|
|
|
@ -3,11 +3,9 @@ package zec
|
|||
import (
|
||||
"blockbook/bchain"
|
||||
"blockbook/bchain/coins/btc"
|
||||
"blockbook/bchain/coins/utils"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/juju/errors"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -16,18 +14,48 @@ const (
|
|||
RegtestMagic wire.BitcoinNet = 0x5f3fe8aa
|
||||
)
|
||||
|
||||
var (
|
||||
MainNetParams chaincfg.Params
|
||||
TestNetParams chaincfg.Params
|
||||
)
|
||||
|
||||
func init() {
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
|
||||
// Address encoding magics
|
||||
MainNetParams.AddressMagicLen = 2
|
||||
MainNetParams.PubKeyHashAddrID = []byte{0x1C, 0xB8} // base58 prefix: t1
|
||||
MainNetParams.ScriptHashAddrID = []byte{0x1C, 0xBD} // base58 prefix: t3
|
||||
|
||||
TestNetParams = chaincfg.TestNet3Params
|
||||
TestNetParams.Net = TestnetMagic
|
||||
|
||||
// Address encoding magics
|
||||
TestNetParams.AddressMagicLen = 2
|
||||
TestNetParams.PubKeyHashAddrID = []byte{0x1D, 0x25} // base58 prefix: tm
|
||||
TestNetParams.ScriptHashAddrID = []byte{0x1C, 0xBA} // base58 prefix: t2
|
||||
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
if err == nil {
|
||||
err = chaincfg.Register(&TestNetParams)
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// ZCashParser handle
|
||||
type ZCashParser struct {
|
||||
*bchain.BaseParser
|
||||
*btc.BitcoinParser
|
||||
baseparser *bchain.BaseParser
|
||||
}
|
||||
|
||||
// NewZCashParser returns new ZCashParser instance
|
||||
func NewZCashParser(c *btc.Configuration) *ZCashParser {
|
||||
func NewZCashParser(params *chaincfg.Params, c *btc.Configuration) *ZCashParser {
|
||||
return &ZCashParser{
|
||||
&bchain.BaseParser{
|
||||
BlockAddressesToKeep: c.BlockAddressesToKeep,
|
||||
AmountDecimalPoint: 8,
|
||||
},
|
||||
BitcoinParser: btc.NewBitcoinParser(params, c),
|
||||
baseparser: &bchain.BaseParser{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,42 +66,23 @@ func GetChainParams(chain string) *chaincfg.Params {
|
|||
var params *chaincfg.Params
|
||||
switch chain {
|
||||
case "test":
|
||||
params = &chaincfg.TestNet3Params
|
||||
params.Net = TestnetMagic
|
||||
return &TestNetParams
|
||||
case "regtest":
|
||||
params = &chaincfg.RegressionNetParams
|
||||
params.Net = RegtestMagic
|
||||
default:
|
||||
params = &chaincfg.MainNetParams
|
||||
params.Net = MainnetMagic
|
||||
return &MainNetParams
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
// GetAddrDescFromVout returns internal address representation of given transaction output
|
||||
func (p *ZCashParser) GetAddrDescFromVout(output *bchain.Vout) (bchain.AddressDescriptor, error) {
|
||||
if len(output.ScriptPubKey.Addresses) != 1 {
|
||||
return nil, nil
|
||||
}
|
||||
hash, _, err := utils.CheckDecode(output.ScriptPubKey.Addresses[0])
|
||||
return hash, err
|
||||
// PackTx packs transaction to byte array using protobuf
|
||||
func (p *ZCashParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error) {
|
||||
return p.baseparser.PackTx(tx, height, blockTime)
|
||||
}
|
||||
|
||||
// GetAddrDescFromAddress returns internal address representation of given address
|
||||
func (p *ZCashParser) GetAddrDescFromAddress(address string) (bchain.AddressDescriptor, error) {
|
||||
hash, _, err := utils.CheckDecode(address)
|
||||
return hash, err
|
||||
}
|
||||
|
||||
// GetAddressesFromAddrDesc returns addresses for given address descriptor with flag if the addresses are searchable
|
||||
func (p *ZCashParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]string, bool, error) {
|
||||
// TODO implement
|
||||
return nil, false, errors.New("GetAddressesFromAddrDesc: not implemented")
|
||||
}
|
||||
|
||||
// GetScriptFromAddrDesc returns output script for given address descriptor
|
||||
func (p *ZCashParser) GetScriptFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]byte, error) {
|
||||
// TODO implement
|
||||
return nil, errors.New("GetScriptFromAddrDesc: not implemented")
|
||||
// UnpackTx unpacks transaction from protobuf byte array
|
||||
func (p *ZCashParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error) {
|
||||
return p.baseparser.UnpackTx(buf)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ package zec
|
|||
import (
|
||||
"blockbook/bchain"
|
||||
"blockbook/bchain/coins/btc"
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"math/big"
|
||||
"reflect"
|
||||
|
@ -90,6 +91,51 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGetAddrDesc(t *testing.T) {
|
||||
type args struct {
|
||||
tx bchain.Tx
|
||||
parser *ZCashParser
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
}{
|
||||
{
|
||||
name: "zec-1",
|
||||
args: args{
|
||||
tx: testTx1,
|
||||
parser: NewZCashParser(GetChainParams("main"), &btc.Configuration{}),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "zec-2",
|
||||
args: args{
|
||||
tx: testTx2,
|
||||
parser: NewZCashParser(GetChainParams("main"), &btc.Configuration{}),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
for n, vout := range tt.args.tx.Vout {
|
||||
got1, err := tt.args.parser.GetAddrDescFromVout(&vout)
|
||||
if err != nil {
|
||||
t.Errorf("getAddrDescFromVout() error = %v, vout = %d", err, n)
|
||||
return
|
||||
}
|
||||
got2, err := tt.args.parser.GetAddrDescFromAddress(vout.ScriptPubKey.Addresses[0])
|
||||
if err != nil {
|
||||
t.Errorf("getAddrDescFromAddress() error = %v, vout = %d", err, n)
|
||||
return
|
||||
}
|
||||
if !bytes.Equal(got1, got2) {
|
||||
t.Errorf("Address descriptors mismatch: got1 = %v, got2 = %v", got1, got2)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackTx(t *testing.T) {
|
||||
type args struct {
|
||||
tx bchain.Tx
|
||||
|
@ -109,7 +155,7 @@ func TestPackTx(t *testing.T) {
|
|||
tx: testTx1,
|
||||
height: 292272,
|
||||
blockTime: 1521645728,
|
||||
parser: NewZCashParser(&btc.Configuration{}),
|
||||
parser: NewZCashParser(GetChainParams("main"), &btc.Configuration{}),
|
||||
},
|
||||
want: testTxPacked1,
|
||||
wantErr: false,
|
||||
|
@ -120,7 +166,7 @@ func TestPackTx(t *testing.T) {
|
|||
tx: testTx2,
|
||||
height: 292217,
|
||||
blockTime: 1521637604,
|
||||
parser: NewZCashParser(&btc.Configuration{}),
|
||||
parser: NewZCashParser(GetChainParams("main"), &btc.Configuration{}),
|
||||
},
|
||||
want: testTxPacked2,
|
||||
wantErr: false,
|
||||
|
@ -157,7 +203,7 @@ func TestUnpackTx(t *testing.T) {
|
|||
name: "zec-1",
|
||||
args: args{
|
||||
packedTx: testTxPacked1,
|
||||
parser: NewZCashParser(&btc.Configuration{}),
|
||||
parser: NewZCashParser(GetChainParams("main"), &btc.Configuration{}),
|
||||
},
|
||||
want: &testTx1,
|
||||
want1: 292272,
|
||||
|
@ -167,7 +213,7 @@ func TestUnpackTx(t *testing.T) {
|
|||
name: "zec-2",
|
||||
args: args{
|
||||
packedTx: testTxPacked2,
|
||||
parser: NewZCashParser(&btc.Configuration{}),
|
||||
parser: NewZCashParser(GetChainParams("main"), &btc.Configuration{}),
|
||||
},
|
||||
want: &testTx2,
|
||||
want1: 292217,
|
||||
|
|
|
@ -35,7 +35,7 @@ func (z *ZCashRPC) Initialize() error {
|
|||
|
||||
params := GetChainParams(chainName)
|
||||
|
||||
z.Parser = NewZCashParser(z.ChainConfig)
|
||||
z.Parser = NewZCashParser(params, z.ChainConfig)
|
||||
|
||||
// parameters for getInfo request
|
||||
if params.Net == MainnetMagic {
|
||||
|
|
|
@ -11,15 +11,17 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func getRPCClient(cfg json.RawMessage) (bchain.BlockChain, error) {
|
||||
c, err := NewZCashRPC(cfg, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
func getRPCClient(chain string) func(cfg json.RawMessage) (bchain.BlockChain, error) {
|
||||
return func(cfg json.RawMessage) (bchain.BlockChain, error) {
|
||||
c, err := NewZCashRPC(cfg, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cli := c.(*ZCashRPC)
|
||||
cli.Parser = NewZCashParser(GetChainParams(chain), cli.ChainConfig)
|
||||
cli.Mempool = bchain.NewUTXOMempool(cli, cli.ChainConfig.MempoolWorkers, cli.ChainConfig.MempoolSubWorkers)
|
||||
return cli, nil
|
||||
}
|
||||
cli := c.(*ZCashRPC)
|
||||
cli.Parser = NewZCashParser(cli.ChainConfig)
|
||||
cli.Mempool = bchain.NewUTXOMempool(cli, cli.ChainConfig.MempoolWorkers, cli.ChainConfig.MempoolSubWorkers)
|
||||
return cli, nil
|
||||
}
|
||||
|
||||
var tests struct {
|
||||
|
@ -30,14 +32,14 @@ var tests struct {
|
|||
func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
|
||||
t, err := rpc.NewTest("Zcash", getRPCClient)
|
||||
t, err := rpc.NewTest("Zcash", getRPCClient("main"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
tests.mainnet = t
|
||||
|
||||
t, err = rpc.NewTest("Zcash Testnet", getRPCClient)
|
||||
t, err = rpc.NewTest("Zcash Testnet", getRPCClient("test"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue