Fix linting errors
parent
d089a84ba9
commit
3a8da67752
|
@ -1047,7 +1047,7 @@ func (w *Worker) GetFeeStats(bid string) (*FeeStats, error) {
|
||||||
return nil, errors.Annotatef(err, "GetTxAddresses")
|
return nil, errors.Annotatef(err, "GetTxAddresses")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Caclulate total fees in Satoshis
|
// Calculate total fees in Satoshis
|
||||||
feeSat := big.NewInt(0)
|
feeSat := big.NewInt(0)
|
||||||
for _, input := range txAddresses.Inputs {
|
for _, input := range txAddresses.Inputs {
|
||||||
feeSat = feeSat.Add(&input.ValueSat, feeSat)
|
feeSat = feeSat.Add(&input.ValueSat, feeSat)
|
||||||
|
|
|
@ -125,6 +125,7 @@ func (p *DecredParser) ParseBlock(b []byte) (*bchain.Block, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParseTxFromJson parses JSON message containing transaction and returns Tx struct
|
||||||
func (p *DecredParser) ParseTxFromJson(jsonTx json.RawMessage) (*bchain.Tx, error) {
|
func (p *DecredParser) ParseTxFromJson(jsonTx json.RawMessage) (*bchain.Tx, error) {
|
||||||
var getTxResult GetTransactionResult
|
var getTxResult GetTransactionResult
|
||||||
if err := json.Unmarshal([]byte(jsonTx), &getTxResult.Result); err != nil {
|
if err := json.Unmarshal([]byte(jsonTx), &getTxResult.Result); err != nil {
|
||||||
|
|
|
@ -491,11 +491,7 @@ func (d *DecredRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error) {
|
||||||
return header, nil
|
return header, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DecredRPC) GetBlockHeaderByHeight(height uint32) (*bchain.BlockHeader, error) {
|
// GetBlock returns the block retrieved using the provided block hash by default
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetBlock returns the block retreived using the provided block hash by default
|
|
||||||
// or using the block height if an empty hash string was provided. If the
|
// or using the block height if an empty hash string was provided. If the
|
||||||
// requested block has less than 2 confirmation bchain.ErrBlockNotFound error
|
// requested block has less than 2 confirmation bchain.ErrBlockNotFound error
|
||||||
// is returned. This rule is in places to guarrantee that only validated block
|
// is returned. This rule is in places to guarrantee that only validated block
|
||||||
|
@ -503,18 +499,16 @@ func (d *DecredRPC) GetBlockHeaderByHeight(height uint32) (*bchain.BlockHeader,
|
||||||
func (d *DecredRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
func (d *DecredRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
||||||
// Confirm if the block at provided height has at least 2 confirming blocks.
|
// Confirm if the block at provided height has at least 2 confirming blocks.
|
||||||
d.mtx.Lock()
|
d.mtx.Lock()
|
||||||
var bestBlockHeight = d.bestBlock
|
if height > d.bestBlock {
|
||||||
if height > bestBlockHeight {
|
|
||||||
bestBlock, err := d.getBestBlock()
|
bestBlock, err := d.getBestBlock()
|
||||||
if err != nil || height > bestBlock.Result.Height {
|
if err != nil || height > bestBlock.Result.Height {
|
||||||
// If an error occured or the current height doesn't have a minimum
|
// If an error occurred or the current height doesn't have a minimum
|
||||||
// of two confirming blocks (greater than best block), quit.
|
// of two confirming blocks (greater than best block), quit.
|
||||||
d.mtx.Unlock()
|
d.mtx.Unlock()
|
||||||
return nil, bchain.ErrBlockNotFound
|
return nil, bchain.ErrBlockNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
d.bestBlock = bestBlock.Result.Height
|
d.bestBlock = bestBlock.Result.Height
|
||||||
bestBlockHeight = bestBlock.Result.Height
|
|
||||||
}
|
}
|
||||||
d.mtx.Unlock() // Releases the lock soonest possible
|
d.mtx.Unlock() // Releases the lock soonest possible
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ func Test_UnpackTx(t *testing.T) {
|
||||||
type testBlock struct {
|
type testBlock struct {
|
||||||
size int
|
size int
|
||||||
time int64
|
time int64
|
||||||
tx []string
|
tx []string
|
||||||
}
|
}
|
||||||
|
|
||||||
var testParseBlockTxs = map[int]testBlock{
|
var testParseBlockTxs = map[int]testBlock{
|
||||||
|
|
|
@ -8,12 +8,14 @@ import (
|
||||||
"github.com/martinboehm/btcutil/chaincfg"
|
"github.com/martinboehm/btcutil/chaincfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// magic numbers
|
||||||
const (
|
const (
|
||||||
MainnetMagic wire.BitcoinNet = 0x6f746f4b
|
MainnetMagic wire.BitcoinNet = 0x6f746f4b
|
||||||
TestnetMagic wire.BitcoinNet = 0x6f6b6f54
|
TestnetMagic wire.BitcoinNet = 0x6f6b6f54
|
||||||
RegtestMagic wire.BitcoinNet = 0x6f6b6552
|
RegtestMagic wire.BitcoinNet = 0x6f6b6552
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// chain parameters
|
||||||
var (
|
var (
|
||||||
MainNetParams chaincfg.Params
|
MainNetParams chaincfg.Params
|
||||||
TestNetParams chaincfg.Params
|
TestNetParams chaincfg.Params
|
||||||
|
|
|
@ -19,8 +19,8 @@ import (
|
||||||
"github.com/martinboehm/btcutil/chaincfg"
|
"github.com/martinboehm/btcutil/chaincfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// magic numbers
|
||||||
const (
|
const (
|
||||||
// Net Magics
|
|
||||||
MainnetMagic wire.BitcoinNet = 0xe9fdc490
|
MainnetMagic wire.BitcoinNet = 0xe9fdc490
|
||||||
TestnetMagic wire.BitcoinNet = 0xba657645
|
TestnetMagic wire.BitcoinNet = 0xba657645
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ const (
|
||||||
OP_ZEROCOINSPEND = 0xc2
|
OP_ZEROCOINSPEND = 0xc2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// chain parameters
|
||||||
var (
|
var (
|
||||||
MainNetParams chaincfg.Params
|
MainNetParams chaincfg.Params
|
||||||
TestNetParams chaincfg.Params
|
TestNetParams chaincfg.Params
|
||||||
|
@ -143,7 +144,7 @@ func (p *PivXParser) ParseTx(b []byte) (*bchain.Tx, error) {
|
||||||
return &tx, nil
|
return &tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses tx and adds handling for OP_ZEROCOINSPEND inputs
|
// TxFromMsgTx parses tx and adds handling for OP_ZEROCOINSPEND inputs
|
||||||
func (p *PivXParser) TxFromMsgTx(t *wire.MsgTx, parseAddresses bool) bchain.Tx {
|
func (p *PivXParser) TxFromMsgTx(t *wire.MsgTx, parseAddresses bool) bchain.Tx {
|
||||||
vin := make([]bchain.Vin, len(t.TxIn))
|
vin := make([]bchain.Vin, len(t.TxIn))
|
||||||
for i, in := range t.TxIn {
|
for i, in := range t.TxIn {
|
||||||
|
|
|
@ -5,15 +5,18 @@ import (
|
||||||
"blockbook/bchain/coins/btc"
|
"blockbook/bchain/coins/btc"
|
||||||
"blockbook/bchain/coins/utils"
|
"blockbook/bchain/coins/utils"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/martinboehm/btcd/wire"
|
"github.com/martinboehm/btcd/wire"
|
||||||
"github.com/martinboehm/btcutil/chaincfg"
|
"github.com/martinboehm/btcutil/chaincfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// magic numbers
|
||||||
const (
|
const (
|
||||||
MainnetMagic wire.BitcoinNet = 0xcbc6680f
|
MainnetMagic wire.BitcoinNet = 0xcbc6680f
|
||||||
RegtestMagic wire.BitcoinNet = 0x377b972d
|
RegtestMagic wire.BitcoinNet = 0x377b972d
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// chain parameters
|
||||||
var (
|
var (
|
||||||
MainNetParams chaincfg.Params
|
MainNetParams chaincfg.Params
|
||||||
RegtestParams chaincfg.Params
|
RegtestParams chaincfg.Params
|
||||||
|
|
|
@ -16,8 +16,8 @@ import (
|
||||||
const (
|
const (
|
||||||
OpZeroCoinMint = 0xc1
|
OpZeroCoinMint = 0xc1
|
||||||
OpZeroCoinSpend = 0xc2
|
OpZeroCoinSpend = 0xc2
|
||||||
OpSigmaMint = 0xc3
|
OpSigmaMint = 0xc3
|
||||||
OpSigmaSpend = 0xc4
|
OpSigmaSpend = 0xc4
|
||||||
|
|
||||||
MainnetMagic wire.BitcoinNet = 0xe3d9fef1
|
MainnetMagic wire.BitcoinNet = 0xe3d9fef1
|
||||||
TestnetMagic wire.BitcoinNet = 0xcffcbeea
|
TestnetMagic wire.BitcoinNet = 0xcffcbeea
|
||||||
|
|
Loading…
Reference in New Issue