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