bitcoin

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BtcToSat

func BtcToSat(btc string) (int64, error)

Types

type AddressGenerator

type AddressGenerator struct {
	// contains filtered or unexported fields
}

func NewAddressGenerator

func NewAddressGenerator(masterPublicKeyString string, chainParams *chaincfg.Params) (*AddressGenerator, error)

NewAddressGenerator return AddressGenerator from the master public key

func (*AddressGenerator) Generate

func (g *AddressGenerator) Generate(index uint32) (string, error)

Generate return public key corresponding to the index

type Client

type Client interface {
	GetBlockCount() (int64, error)
	GetBlockHash(blockHeight int64) (*chainhash.Hash, error)
	GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error)
}

type Listener

type Listener struct {
	Enabled              bool
	Client               Client          `inject:""`
	Storage              storage.Storage `inject:""`
	TransactionHandler   TransactionHandler
	Testnet              bool
	ConfirmedBlockNumber uint64
	// contains filtered or unexported fields
}

Listener listens for transactions using bitcoin-core RPC. It calls TransactionHandler for each new transactions. It will reprocess the block if TransactionHandler returns error. It will start from the block number returned from Storage.GetBlockToProcess("bitcoin") or the latest block if it returned 0. Transactions can be processed more than once, it's TransactionHandler responsibility to ignore duplicates. Listener tracks only P2PKH payments. You can run multiple Listeners if Storage is implemented correctly.

func (*Listener) Start

func (l *Listener) Start() error

type Transaction

type Transaction struct {
	Hash       string
	TxOutIndex int
	// Value in sats
	ValueSat int64
	To       string
}

func (*Transaction) ValueToTomo

func (t *Transaction) ValueToTomo() string

ValueToTomo need to convert BTC to ETH, because Tomo using ETH as unit

func (*Transaction) ValueToWei

func (t *Transaction) ValueToWei() string

type TransactionHandler

type TransactionHandler func(transaction Transaction) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL