Resolve some linting issues
parent
70330273c0
commit
e06ff194de
|
@ -12,22 +12,31 @@ import (
|
||||||
"github.com/schancel/cashaddr-converter/address"
|
"github.com/schancel/cashaddr-converter/address"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AddressFormat type is used to specify different formats of address
|
||||||
type AddressFormat = uint8
|
type AddressFormat = uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// Legacy AddressFormat is the same as Bitcoin
|
||||||
Legacy AddressFormat = iota
|
Legacy AddressFormat = iota
|
||||||
|
// CashAddr AddressFormat is new Bitcoin Cash standard
|
||||||
CashAddr
|
CashAddr
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// MainNetPrefix is CashAddr prefix for mainnet
|
||||||
MainNetPrefix = "bitcoincash:"
|
MainNetPrefix = "bitcoincash:"
|
||||||
|
// TestNetPrefix is CashAddr prefix for testnet
|
||||||
TestNetPrefix = "bchtest:"
|
TestNetPrefix = "bchtest:"
|
||||||
|
// RegTestPrefix is CashAddr prefix for regtest
|
||||||
RegTestPrefix = "bchreg:"
|
RegTestPrefix = "bchreg:"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// MainNetParams are parser parameters for mainnet
|
||||||
MainNetParams chaincfg.Params
|
MainNetParams chaincfg.Params
|
||||||
|
// TestNetParams are parser parameters for testnet
|
||||||
TestNetParams chaincfg.Params
|
TestNetParams chaincfg.Params
|
||||||
|
// RegtestParams are parser parameters for regtest
|
||||||
RegtestParams chaincfg.Params
|
RegtestParams chaincfg.Params
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -118,17 +127,16 @@ func (p *BCashParser) addressToOutputScript(address string) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return script, nil
|
return script, nil
|
||||||
} else {
|
|
||||||
da, err := btcutil.DecodeAddress(address, p.Params)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
script, err := txscript.PayToAddrScript(da)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return script, nil
|
|
||||||
}
|
}
|
||||||
|
da, err := btcutil.DecodeAddress(address, p.Params)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
script, err := txscript.PayToAddrScript(da)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return script, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isCashAddr(addr string) bool {
|
func isCashAddr(addr string) bool {
|
||||||
|
@ -163,9 +171,8 @@ func (p *BCashParser) outputScriptToAddresses(script []byte) ([]string, bool, er
|
||||||
return []string{or}, false, nil
|
return []string{or}, false, nil
|
||||||
}
|
}
|
||||||
return []string{}, false, nil
|
return []string{}, false, nil
|
||||||
} else {
|
|
||||||
return nil, false, err
|
|
||||||
}
|
}
|
||||||
|
return nil, false, err
|
||||||
}
|
}
|
||||||
// EncodeAddress returns CashAddr address
|
// EncodeAddress returns CashAddr address
|
||||||
addr := a.EncodeAddress()
|
addr := a.EncodeAddress()
|
||||||
|
|
|
@ -9,14 +9,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// MainnetMagic is mainnet network constant
|
||||||
MainnetMagic wire.BitcoinNet = 0xbd6b0cbf
|
MainnetMagic wire.BitcoinNet = 0xbd6b0cbf
|
||||||
|
// TestnetMagic is testnet network constant
|
||||||
TestnetMagic wire.BitcoinNet = 0xffcae2ce
|
TestnetMagic wire.BitcoinNet = 0xffcae2ce
|
||||||
|
// RegtestMagic is regtest network constant
|
||||||
RegtestMagic wire.BitcoinNet = 0xdcb7c1fc
|
RegtestMagic wire.BitcoinNet = 0xdcb7c1fc
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// MainNetParams are parser parameters for mainnet
|
||||||
MainNetParams chaincfg.Params
|
MainNetParams chaincfg.Params
|
||||||
|
// TestNetParams are parser parameters for testnet
|
||||||
TestNetParams chaincfg.Params
|
TestNetParams chaincfg.Params
|
||||||
|
// RegtestParams are parser parameters for regtest
|
||||||
RegtestParams chaincfg.Params
|
RegtestParams chaincfg.Params
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,12 @@ import (
|
||||||
|
|
||||||
const firstBlockWithSpecialTransactions = 1028160
|
const firstBlockWithSpecialTransactions = 1028160
|
||||||
|
|
||||||
// DashRPC is an interface to JSON-RPC bitcoind service.
|
// DashRPC is an interface to JSON-RPC bitcoind service
|
||||||
type DashRPC struct {
|
type DashRPC struct {
|
||||||
*btc.BitcoinRPC
|
*btc.BitcoinRPC
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDashRPC returns new DashRPC instance.
|
// NewDashRPC returns new DashRPC instance
|
||||||
func NewDashRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
|
func NewDashRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
|
||||||
b, err := btc.NewBitcoinRPC(config, pushHandler)
|
b, err := btc.NewBitcoinRPC(config, pushHandler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -58,7 +58,7 @@ func (b *DashRPC) Initialize() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlock returns block with given hash.
|
// GetBlock returns block with given hash
|
||||||
func (b *DashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
func (b *DashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
||||||
if hash == "" && height < firstBlockWithSpecialTransactions {
|
if hash == "" && height < firstBlockWithSpecialTransactions {
|
||||||
return b.BitcoinRPC.GetBlock(hash, height)
|
return b.BitcoinRPC.GetBlock(hash, height)
|
||||||
|
@ -108,6 +108,6 @@ func (b *DashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
||||||
|
|
||||||
// GetTransactionForMempool returns a transaction by the transaction ID.
|
// GetTransactionForMempool returns a transaction by the transaction ID.
|
||||||
// It could be optimized for mempool, i.e. without block time and confirmations
|
// It could be optimized for mempool, i.e. without block time and confirmations
|
||||||
func (z *DashRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
|
func (b *DashRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
|
||||||
return z.GetTransaction(txid)
|
return b.GetTransaction(txid)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// MainnetMagic is mainnet network constant
|
||||||
MainnetMagic wire.BitcoinNet = 0x6427e924
|
MainnetMagic wire.BitcoinNet = 0x6427e924
|
||||||
|
// TestnetMagic is testnet network constant
|
||||||
TestnetMagic wire.BitcoinNet = 0xbff91afa
|
TestnetMagic wire.BitcoinNet = 0xbff91afa
|
||||||
|
// RegtestMagic is regtest network constant
|
||||||
RegtestMagic wire.BitcoinNet = 0x5f3fe8aa
|
RegtestMagic wire.BitcoinNet = 0x5f3fe8aa
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// MainNetParams are parser parameters for mainnet
|
||||||
MainNetParams chaincfg.Params
|
MainNetParams chaincfg.Params
|
||||||
|
// TestNetParams are parser parameters for testnet
|
||||||
TestNetParams chaincfg.Params
|
TestNetParams chaincfg.Params
|
||||||
|
// RegtestParams are parser parameters for regtest
|
||||||
RegtestParams chaincfg.Params
|
RegtestParams chaincfg.Params
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,12 @@ import (
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ZCashRPC is an interface to JSON-RPC bitcoind service
|
||||||
type ZCashRPC struct {
|
type ZCashRPC struct {
|
||||||
*btc.BitcoinRPC
|
*btc.BitcoinRPC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewZCashRPC returns new ZCashRPC instance
|
||||||
func NewZCashRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
|
func NewZCashRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
|
||||||
b, err := btc.NewBitcoinRPC(config, pushHandler)
|
b, err := btc.NewBitcoinRPC(config, pushHandler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -26,7 +28,7 @@ func NewZCashRPC(config json.RawMessage, pushHandler func(bchain.NotificationTyp
|
||||||
return z, nil
|
return z, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize initializes ZCashRPC instance.
|
// Initialize initializes ZCashRPC instance
|
||||||
func (z *ZCashRPC) Initialize() error {
|
func (z *ZCashRPC) Initialize() error {
|
||||||
chainName, err := z.GetChainInfoAndInitializeMempool(z)
|
chainName, err := z.GetChainInfoAndInitializeMempool(z)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue