Documentation ¶
Index ¶
- Constants
- func AddressBalance(rpool *redis.Pool, address string) (balance uint64, err error)
- func AddressFirstSeen(rpool *redis.Pool, address string) (firstseen uint64, err error)
- func CallBitcoinRPC(address string, method string, id interface{}, params []interface{}) (map[string]interface{}, error)
- func CatchUpLatestBlock(conf *Config, rpool *redis.Pool, spool *redis.Pool) (done bool)
- func FloatToUint(x float64) uint64
- func GetBlockCountRPC(conf *Config) uint
- func GetBlockHash(rpool *redis.Pool, height uint) (hash string, err error)
- func GetBlockHashRPC(conf *Config, height uint) string
- func GetBlockReward(height uint) uint
- func GetLastBitcoinPrice() (price float64, err error)
- func GetRawMemPoolRPC(conf *Config) (unconfirmedtxs []string, err error)
- func GetRawMemPoolVerboseRPC(conf *Config) (unconfirmedtxs map[string]interface{}, err error)
- func GetReceivedByAddress(rpool *redis.Pool, address string) (total uint64, err error)
- func GetRedis(conf *Config) (pool *redis.Pool, err error)
- func GetSSDB(conf *Config) (pool *redis.Pool, err error)
- func GetSentByAddress(rpool *redis.Pool, address string) (total uint64, err error)
- func IsAddress(q string) (s bool, res string)
- func IsBlockHash(rpool *redis.Pool, q string) (s bool, res string)
- func IsBlockHeight(rpool *redis.Pool, q string) (s bool, res string)
- func IsTxHash(rpool *redis.Pool, q string) (s bool, res string)
- func IsUnconfirmedTx(pool *redis.Pool, hash string) (status bool, res string)
- func ProcessNewBlock(conf *Config, rpool *redis.Pool, spool *redis.Pool)
- func ProcessUnconfirmedTxs(conf *Config, pool *redis.Pool, running *bool)
- func TxBlockTime(tx1, tx2 *Tx) bool
- func TxFirstSeenAsc(tx1, tx2 *Tx) bool
- func TxFirstSeenDesc(tx1, tx2 *Tx) bool
- func TxIndex(tx1, tx2 *Tx) bool
- func ValidA58(a58 []byte) (ok bool, err error)
- type A25
- type AddressData
- type AddressHash
- type BitcoindInfo
- type Block
- func GetBlockByHash(rpool *redis.Pool, hash string) (block *Block, err error)
- func GetBlockCachedByHash(rpool *redis.Pool, hash string) (block *Block, err error)
- func GetLastXBlocks(rpool *redis.Pool, start uint, stop uint) (blocks []*Block, err error)
- func SaveBlockFromRPC(conf *Config, pool *redis.Pool, hash string) (block *Block, err error)
- type BlockMeta
- type By
- type Config
- type PrevOut
- type Tx
- func GetTx(rpool *redis.Pool, hash string) (tx *Tx, err error)
- func GetTxRPC(conf *Config, tx_id string, block *Block) (tx *Tx, err error)
- func GetUnconfirmedTx(pool *redis.Pool, hash string) (tx *Tx, err error)
- func GetUnconfirmedTxs(pool *redis.Pool) (utxs []*Tx, err error)
- func SaveTxFromRPC(conf *Config, pool *redis.Pool, tx_id string, block *Block, tx_index int) (tx *Tx, err error)
- type TxAddressInfo
- type TxIn
- type TxOut
- type TxoSpent
Constants ¶
const GenesisTx = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"
Variables ¶
This section is empty.
Functions ¶
func AddressBalance ¶
func AddressFirstSeen ¶
Return the block time at which the address first appeared
func CallBitcoinRPC ¶
func CallBitcoinRPC(address string, method string, id interface{}, params []interface{}) (map[string]interface{}, error)
Helper to make call to bitcoind RPC API
func CatchUpLatestBlock ¶
func GetBlockCountRPC ¶
func GetBlockHash ¶
Return block hash for the given height
func GetBlockHashRPC ¶
func GetLastBitcoinPrice ¶
Return last USD price from BitcoinAverage API
func GetRawMemPoolRPC ¶
func GetRawMemPoolVerboseRPC ¶
func GetReceivedByAddress ¶
func GetSentByAddress ¶
func IsUnconfirmedTx ¶
Check if the Tx is in Redis (not SSDB, Redis!) (in rawmempool)
func ProcessUnconfirmedTxs ¶
Get unconfirmed transactions from memory pool, along with first seem time/block height, requires a recent bitcoind version
func TxBlockTime ¶
func TxFirstSeenAsc ¶
func TxFirstSeenDesc ¶
func ValidA58 ¶
ValidA58 validates a base58 encoded bitcoin address. An address is valid if it can be decoded into a 25 byte address, the version number is 0, and the checksum validates. Return value ok will be true for valid addresses. If ok is false, the address is invalid and the error value may indicate why.
Types ¶
type A25 ¶
type A25 [25]byte
A25 is a type for a 25 byte (not base58 encoded) bitcoin address.
func (*A25) ComputeChecksum ¶
ComputeChecksum returns a four byte checksum computed from the first 21 bytes of the address. The embedded checksum is not updated.
func (*A25) EmbeddedChecksum ¶
type AddressData ¶
type AddressData struct { Address string `json:"address"` TxCnt uint64 `json:"n_tx"` ReceivedCnt uint64 `json:"-"` SentCnt uint64 `json:"-"` TotalReceived uint64 `json:"total_received"` TotalSent uint64 `json:"total_sent"` FinalBalance uint64 `json:"final_balance"` Txs []*Tx `json:"txs"` Links map[string]map[string]string `json:"_links,omitempty"` }
func GetAddress ¶
func GetAddress(rpool *redis.Pool, address string) (addressdata *AddressData, err error)
type AddressHash ¶
type BitcoindInfo ¶
type BitcoindInfo struct { Version int64 `json:"version"` ProtocolVersion int64 `json:"protocolversion"` Blocks int64 `json:"blocks"` TimeOffset int64 `json:"timeoffset"` Connections int64 `json:"connections"` Proxy string `json:"proxy"` Difficulty float64 `json:"difficulty"` Testnet bool `json:"testnet"` Errors string `json:"errors"` }
func GetInfoRPC ¶
func GetInfoRPC(conf *Config) (bitcoindinfo *BitcoindInfo, err error)
type Block ¶
type Block struct { Hash string `json:"hash"` Height uint `json:"height"` Txs []*Tx `json:"tx,omitempty"` Version uint32 `json:"ver"` MerkleRoot string `json:"mrkl_root"` BlockTime uint32 `json:"time"` Bits uint32 `json:"bits"` Nonce uint32 `json:"nonce"` Size uint32 `json:"size"` TxCnt uint32 `json:"n_tx"` TotalBTC uint64 `json:"total_out"` // BlockReward float64 `json:"-"` Parent string `json:"prev_block"` Next string `json:"next_block"` Links map[string]map[string]string `json:"_links,omitempty"` Meta *BlockMeta `json:"-"` Main bool `json:"-"` }
func GetBlockByHash ¶
Get a block by its hash
func GetBlockCachedByHash ¶
Get a block by its hash along with its full transactions
func GetLastXBlocks ¶
Return last X blocks from stop to start (both included)
func SaveBlockFromRPC ¶
type BlockMeta ¶
type Config ¶
type Config struct { BitcoindBlocksPath string `json:"bitcoind_blocks_path"` BitcoindRpcUrl string `json:"bitcoind_rpc_url"` SsdbHost string `json:"ssdb_host"` RedisHost string `json:"redis_host"` LevelDbPath string `json:"leveldb_path"` AppUrl string `json:"app_url"` AppPort uint `json:"app_port"` AppApiRateLimited bool `json:"app_api_rate_limited"` AppTemplatesPath string `json:"app_templates_path"` AppGoogleAnalytics string `json:"app_google_analytics"` }
Struct holding our configuration
func LoadConfig ¶
Load configuration from json file
type Tx ¶
type Tx struct { Hash string `json:"hash"` Index uint32 `json:"-"` Size uint32 `json:"size"` LockTime uint32 `json:"lock_time"` Version uint32 `json:"ver"` TxInCnt uint32 `json:"vin_sz"` TxOutCnt uint32 `json:"vout_sz"` TxIns []*TxIn `json:"in"` TxOuts []*TxOut `json:"out"` TotalOut uint64 `json:"vout_total"` TotalIn uint64 `json:"vin_total"` BlockHash string `json:"block_hash"` BlockHeight uint `json:"block_height"` BlockTime uint32 `json:"block_time"` FirstSeenTime uint32 `json:"first_seen_time"` FirstSeenHeight uint `json:"first_seen_height"` TxAddressInfo *TxAddressInfo `json:"-"` Links map[string]map[string]string `json:"_links,omitempty"` }
func GetUnconfirmedTx ¶
Fetch unconfirmed tx from Redis
func GetUnconfirmedTxs ¶
Return all unconfirmed transactions from Redis
func SaveTxFromRPC ¶
func SaveTxFromRPC(conf *Config, pool *redis.Pool, tx_id string, block *Block, tx_index int) (tx *Tx, err error)
Fetch a transaction via bticoind RPC API
func (*Tx) AddressesChannels ¶
Return a set containing every addresses listed in txis/txos