Documentation ¶
Index ¶
- Constants
- Variables
- func GetChainParams(chain string) *chaincfg.Params
- func NewDecredRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error)
- type DecodeRawTransactionResult
- type DecredParser
- func (p *DecredParser) DerivationBasePath(xpub string) (string, error)
- func (p *DecredParser) DeriveAddressDescriptors(xpub string, change uint32, indexes []uint32) ([]bchain.AddressDescriptor, error)
- func (p *DecredParser) DeriveAddressDescriptorsFromTo(xpub string, change uint32, fromIndex uint32, toIndex uint32) ([]bchain.AddressDescriptor, error)
- func (p *DecredParser) GetAddrDescForUnknownInput(tx *bchain.Tx, input int) bchain.AddressDescriptor
- func (p *DecredParser) GetAddrDescFromAddress(address string) (bchain.AddressDescriptor, error)
- func (p *DecredParser) GetAddrDescFromVout(output *bchain.Vout) (bchain.AddressDescriptor, error)
- func (p *DecredParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]string, bool, error)
- func (p *DecredParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error)
- func (p *DecredParser) ParseBlock(b []byte) (*bchain.Block, error)
- func (p *DecredParser) ParseTxFromJson(jsonTx json.RawMessage) (*bchain.Tx, error)
- func (p *DecredParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error)
- type DecredRPC
- func (d *DecredRPC) Call(req interface{}, res interface{}) error
- func (d *DecredRPC) EstimateFee(blocks int) (big.Int, error)
- func (d *DecredRPC) EstimateSmartFee(blocks int, conservative bool) (big.Int, error)
- func (d *DecredRPC) GetBestBlockHash() (string, error)
- func (d *DecredRPC) GetBestBlockHeight() (uint32, error)
- func (d *DecredRPC) GetBlock(hash string, height uint32) (*bchain.Block, error)
- func (d *DecredRPC) GetBlockHash(height uint32) (string, error)
- func (d *DecredRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error)
- func (d *DecredRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error)
- func (d *DecredRPC) GetChainInfo() (*bchain.ChainInfo, error)
- func (d *DecredRPC) GetMempoolTransactions() ([]string, error)
- func (d *DecredRPC) GetTransaction(txid string) (*bchain.Tx, error)
- func (d *DecredRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error)
- func (d *DecredRPC) GetTransactionSpecific(tx *bchain.Tx) (json.RawMessage, error)
- func (d *DecredRPC) Initialize() error
- func (d *DecredRPC) SendRawTransaction(tx string) (string, error)
- type Error
- type EstimateFeeResult
- type EstimateSmartFeeResult
- type GenericCmd
- type GetBestBlockResult
- type GetBlockChainInfoResult
- type GetBlockHashResult
- type GetBlockHeaderResult
- type GetBlockResult
- type GetInfoChainResult
- type GetNetworkInfoResult
- type GetTransactionResult
- type MempoolTxsResult
- type RawTx
- type ScriptPubKeyResult
- type ScriptSig
- type SendRawTransactionResult
- type TxExtraInfo
- type Vin
- type Vout
Constants ¶
const ( // MainnetMagic is mainnet network constant MainnetMagic wire.BitcoinNet = 0xd9b400f9 // TestnetMagic is testnet network constant TestnetMagic wire.BitcoinNet = 0xb194aa75 )
Variables ¶
var ( // MainNetParams are parser parameters for mainnet MainNetParams chaincfg.Params // TestNet3Params are parser parameters for testnet TestNet3Params chaincfg.Params )
Functions ¶
func GetChainParams ¶
GetChainParams contains network parameters for the main Decred network, and the test Decred network.
func NewDecredRPC ¶
func NewDecredRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error)
NewDecredRPC returns new DecredRPC instance.
Types ¶
type DecredParser ¶
type DecredParser struct { *btc.BitcoinParser // contains filtered or unexported fields }
DecredParser handle
func NewDecredParser ¶
func NewDecredParser(params *chaincfg.Params, c *btc.Configuration) *DecredParser
NewDecredParser returns new DecredParser instance
func (*DecredParser) DerivationBasePath ¶
func (p *DecredParser) DerivationBasePath(xpub string) (string, error)
DerivationBasePath returns base path of xpub which whose full format is m/44'/<coin type>'/<account>'/<branch>/<address index>. This function only returns a path up to m/44'/<coin type>'/<account>'/ whereby the rest of the other details (<branch>/<address index>) are populated automatically.
func (*DecredParser) DeriveAddressDescriptors ¶
func (p *DecredParser) DeriveAddressDescriptors(xpub string, change uint32, indexes []uint32) ([]bchain.AddressDescriptor, error)
DeriveAddressDescriptors derives address descriptors from given xpub for listed indexes
func (*DecredParser) DeriveAddressDescriptorsFromTo ¶
func (p *DecredParser) DeriveAddressDescriptorsFromTo(xpub string, change uint32, fromIndex uint32, toIndex uint32) ([]bchain.AddressDescriptor, error)
DeriveAddressDescriptorsFromTo derives address descriptors from given xpub for addresses in index range
func (*DecredParser) GetAddrDescForUnknownInput ¶
func (p *DecredParser) GetAddrDescForUnknownInput(tx *bchain.Tx, input int) bchain.AddressDescriptor
GetAddrDescForUnknownInput returns nil AddressDescriptor.
func (*DecredParser) GetAddrDescFromAddress ¶
func (p *DecredParser) GetAddrDescFromAddress(address string) (bchain.AddressDescriptor, error)
GetAddrDescFromAddress returns internal address representation of a given address.
func (*DecredParser) GetAddrDescFromVout ¶
func (p *DecredParser) GetAddrDescFromVout(output *bchain.Vout) (bchain.AddressDescriptor, error)
GetAddrDescFromVout returns internal address representation of a given transaction output.
func (*DecredParser) GetAddressesFromAddrDesc ¶
func (p *DecredParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]string, bool, error)
GetAddressesFromAddrDesc returns addresses obtained from the internal address representation
func (*DecredParser) ParseBlock ¶
func (p *DecredParser) ParseBlock(b []byte) (*bchain.Block, error)
ParseBlock parses raw block to our Block struct.
func (*DecredParser) ParseTxFromJson ¶
func (p *DecredParser) ParseTxFromJson(jsonTx json.RawMessage) (*bchain.Tx, error)
ParseTxFromJson parses JSON message containing transaction and returns Tx struct
type DecredRPC ¶
type DecredRPC struct { *btc.BitcoinRPC // contains filtered or unexported fields }
func (*DecredRPC) Call ¶
Call calls Backend RPC interface, using RPCMarshaler interface to marshall the request
func (*DecredRPC) EstimateFee ¶
EstimateFee returns fee estimation.
func (*DecredRPC) EstimateSmartFee ¶
EstimateSmartFee returns fee estimation
func (*DecredRPC) GetBestBlockHash ¶
GetBestBlockHash returns the block hash of the most recent block to be mined and has a minimum of 1 confirming block.
func (*DecredRPC) GetBestBlockHeight ¶
GetBestBlockHeight returns the block height of the most recent block to be mined and has a minimum of 1 confirming block.
func (*DecredRPC) GetBlock ¶
GetBlock returns the block retrieved using the provided block hash by default or using the block height if an empty hash string was provided. If the requested block has less than 2 confirmation bchain.ErrBlockNotFound error is returned. This rule is in places to guarrantee that only validated block details (txs) are saved to the db. Access to the bestBlock height is threadsafe.
func (*DecredRPC) GetBlockHash ¶
GetBlockHash returns the block hash of the block at the provided height.
func (*DecredRPC) GetBlockHeader ¶
func (d *DecredRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error)
GetBlockHeader returns the block header of the block the provided block hash.
func (*DecredRPC) GetBlockInfo ¶
func (*DecredRPC) GetMempoolTransactions ¶
GetMempoolTransactions returns a slice of regular transactions currently in the mempool. The block whose validation is still undecided will have its txs, listed like they are still in the mempool till the block is confirmed.
func (*DecredRPC) GetTransaction ¶
GetTransaction returns a transaction by the transaction ID
func (*DecredRPC) GetTransactionForMempool ¶
GetTransactionForMempool returns the full tx information identified by the provided txid.
func (*DecredRPC) GetTransactionSpecific ¶
GetTransactionSpecific returns the json raw message for the tx identified by the provided txid.
func (*DecredRPC) Initialize ¶
Initialize initializes DecredRPC instance.
type EstimateFeeResult ¶
type EstimateSmartFeeResult ¶
type GenericCmd ¶
type GetBestBlockResult ¶
type GetBlockChainInfoResult ¶
type GetBlockChainInfoResult struct { Error Error `json:"error"` Result struct { Chain string `json:"chain"` Blocks int64 `json:"blocks"` Headers int64 `json:"headers"` SyncHeight int64 `json:"syncheight"` BestBlockHash string `json:"bestblockhash"` Difficulty uint32 `json:"difficulty"` VerificationProgress float64 `json:"verificationprogress"` ChainWork string `json:"chainwork"` InitialBlockDownload bool `json:"initialblockdownload"` MaxBlockSize int64 `json:"maxblocksize"` } `json:"result"` }
type GetBlockHashResult ¶
type GetBlockHeaderResult ¶
type GetBlockHeaderResult struct { Error Error `json:"error"` Result struct { Hash string `json:"hash"` Confirmations int64 `json:"confirmations"` Version json.Number `json:"version"` MerkleRoot string `json:"merkleroot"` StakeRoot string `json:"stakeroot"` VoteBits uint16 `json:"votebits"` FinalState string `json:"finalstate"` Voters uint16 `json:"voters"` FreshStake uint8 `json:"freshstake"` Revocations uint8 `json:"revocations"` PoolSize uint32 `json:"poolsize"` Bits string `json:"bits"` SBits float64 `json:"sbits"` Height uint32 `json:"height"` Size uint32 `json:"size"` Time int64 `json:"time"` Nonce uint32 `json:"nonce"` ExtraData string `json:"extradata"` StakeVersion uint32 `json:"stakeversion"` Difficulty float64 `json:"difficulty"` ChainWork string `json:"chainwork"` PreviousHash string `json:"previousblockhash,omitempty"` NextHash string `json:"nextblockhash,omitempty"` } `json:"result"` }
type GetBlockResult ¶
type GetBlockResult struct { Error Error `json:"error"` Result struct { Hash string `json:"hash"` Confirmations int64 `json:"confirmations"` Size int32 `json:"size"` Height uint32 `json:"height"` Version json.Number `json:"version"` MerkleRoot string `json:"merkleroot"` StakeRoot string `json:"stakeroot"` RawTx []RawTx `json:"rawtx"` Tx []string `json:"tx,omitempty"` STx []string `json:"stx,omitempty"` Time int64 `json:"time"` Nonce json.Number `json:"nonce"` VoteBits uint16 `json:"votebits"` FinalState string `json:"finalstate"` Voters uint16 `json:"voters"` FreshStake uint8 `json:"freshstake"` Revocations uint8 `json:"revocations"` PoolSize uint32 `json:"poolsize"` Bits string `json:"bits"` SBits float64 `json:"sbits"` ExtraData string `json:"extradata"` StakeVersion uint32 `json:"stakeversion"` Difficulty float64 `json:"difficulty"` ChainWork string `json:"chainwork"` PreviousHash string `json:"previousblockhash"` NextHash string `json:"nextblockhash,omitempty"` } `json:"result"` }
type GetInfoChainResult ¶
type GetInfoChainResult struct { Error Error `json:"error"` Result struct { Version int32 `json:"version"` ProtocolVersion int32 `json:"protocolversion"` Blocks int64 `json:"blocks"` TimeOffset int64 `json:"timeoffset"` Connections int32 `json:"connections"` Proxy string `json:"proxy"` Difficulty float64 `json:"difficulty"` TestNet bool `json:"testnet"` RelayFee float64 `json:"relayfee"` Errors string `json:"errors"` } }
type GetNetworkInfoResult ¶
type GetTransactionResult ¶
type MempoolTxsResult ¶
type RawTx ¶
type RawTx struct { Hex string `json:"hex"` Txid string `json:"txid"` Version int32 `json:"version"` LockTime uint32 `json:"locktime"` Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` Expiry uint32 `json:"expiry"` BlockIndex uint32 `json:"blockindex,omitempty"` Confirmations int64 `json:"confirmations,omitempty"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime,omitempty"` TxExtraInfo }
type ScriptPubKeyResult ¶
type TxExtraInfo ¶
type Vin ¶
type Vin struct { Coinbase string `json:"coinbase"` Stakebase string `json:"stakebase"` Txid string `json:"txid"` Vout uint32 `json:"vout"` Tree int8 `json:"tree"` Sequence uint32 `json:"sequence"` AmountIn float64 `json:"amountin"` BlockHeight uint32 `json:"blockheight"` BlockIndex uint32 `json:"blockindex"` ScriptSig *ScriptSig `json:"scriptsig"` }