Skip to content

Commit

Permalink
Resolve some linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
martinboehm committed Mar 6, 2019
1 parent 7033027 commit e06ff19
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
31 changes: 19 additions & 12 deletions bchain/coins/bch/bcashparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions bchain/coins/dash/dashparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
10 changes: 5 additions & 5 deletions bchain/coins/dash/dashrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
6 changes: 6 additions & 0 deletions bchain/coins/zec/zcashparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 3 additions & 1 deletion bchain/coins/zec/zcashrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit e06ff19

Please sign in to comment.