bitcoin

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RESERVE              = "reserveTracker"
	FREEZE_FOR_BROADCAST = "freezeForBroadcast"
	REPORT_BROADCAST     = "reportBroadcastSuccess"
	CLEANUP              = "cleanup"
)
View Source
const (
	ProcessTypeNone   = 0x00
	ProcessTypeLock   = 0x01
	ProcessTypeRedeem = 0x02
)

Variables

View Source
var (
	ErrTrackerBusy                    = errors.New("tracker is busy")
	ErrTrackerNotCollectionSignatures = errors.New("tracker not collecting signatures")
)
View Source
var (
	ErrTrackerNotFound = errors.New("tracker not found")
)
View Source
var NilTxHash *chainhash.Hash

Functions

This section is empty.

Types

type BTCConfig added in v0.14.0

type BTCConfig struct {
	BTCAddress     string
	BTCRPCPort     string
	BTCRPCUsername string
	BTCRPCPassword string
	BTCChainnet    string

	BTCParams *chaincfg.Params

	BlockCypherToken     string
	BlockCypherChainType string
}

func NewBTCConfig added in v0.14.0

func NewBTCConfig(cfg *config.ChainDriverConfig, chainType string) BTCConfig

type BTCTransitionContext

type BTCTransitionContext struct {
	Tracker    *Tracker
	JobStore   *jobs.JobStore
	Validators *identity.ValidatorStore
}

func NewTrackerCtx

func NewTrackerCtx(tracker *Tracker, js *jobs.JobStore, vs *identity.ValidatorStore) *BTCTransitionContext

type LockScriptStore

type LockScriptStore struct {
	storage.SessionedStorage
	// contains filtered or unexported fields
}

func NewLockScriptStore

func NewLockScriptStore(config config.Server, dbDir string) *LockScriptStore

func (*LockScriptStore) GetLockScript

func (ls *LockScriptStore) GetLockScript(lockScriptAddress []byte) ([]byte, error)

func (*LockScriptStore) SaveLockScript

func (ls *LockScriptStore) SaveLockScript(lockScriptAddress, lockScript []byte) error

type Tracker

type Tracker struct {
	Name string

	// Multisig manages the signature collection and storage in a distributed way
	Multisig *keys.BTCMultiSig `json:"multisig"`

	// State tracks the current state of the tracker, Also used for locking distributed access
	State TrackerState `json:"state"`

	// Is the transaction ID of the latest UTXO that has all the tracker bitcoin
	CurrentTxId *chainhash.Hash

	// the balance of the latest UTXO in satoshi (10^-8 BTC)
	CurrentBalance int64

	CurrentLockScriptAddress []byte

	ProcessTxId              *chainhash.Hash
	ProcessBalance           int64
	ProcessLockScriptAddress []byte
	ProcessUnsignedTx        []byte

	ProcessOwner keys.Address
	ProcessType  int

	// validator addresses who have voted to finalize the current in process transaction
	FinalityVotes []keys.Address

	// validator addresses who have voted to reset the current in process transaction
	ResetVotes []keys.Address
}

Tracker

func NewTracker

func NewTracker(lockScriptAddress []byte, m int, signers []keys.Address) (*Tracker, error)

func (*Tracker) AddSignature

func (t *Tracker) AddSignature(signatureBytes []byte, addr keys.Address) error

func (*Tracker) GetAddress

func (t *Tracker) GetAddress() ([]byte, error)

func (*Tracker) GetBalance

func (t *Tracker) GetBalance() int64

func (*Tracker) GetBalanceSatoshi

func (t *Tracker) GetBalanceSatoshi() int64

GetBalance gets the current balance of the utxo tracker

func (*Tracker) GetJobID

func (t *Tracker) GetJobID(state TrackerState) string

func (*Tracker) GetSignatures

func (t *Tracker) GetSignatures() [][]byte

func (*Tracker) HasEnoughSignatures

func (t *Tracker) HasEnoughSignatures() bool

func (*Tracker) HasVotedFinality

func (t *Tracker) HasVotedFinality(addr keys.Address) bool

func (*Tracker) IsAvailable

func (t *Tracker) IsAvailable() bool

IsAvailable returns whether the tracker is available for new transaction

func (*Tracker) IsBusy

func (t *Tracker) IsBusy() bool

IsBusy returns whether the tracker is in any of the busy states

func (Tracker) NextStep

func (t Tracker) NextStep() string

func (*Tracker) ProcessLock

func (t *Tracker) ProcessLock(newUTXO *UTXO,
	txn []byte, validatorsPubKeys []keys.Address,
) error

func (*Tracker) StateChangeBroadcast

func (t *Tracker) StateChangeBroadcast() bool

type TrackerState

type TrackerState int
const (
	Available TrackerState = iota
	Requested
	BusySigning
	BusyScheduleBroadcasting
	BusyBroadcasting
	BusyScheduleFinalizing
	BusyFinalizing
	Finalized
)

type TrackerStore

type TrackerStore struct {
	State *storage.State
	// contains filtered or unexported fields
}

func NewTrackerStore

func NewTrackerStore(prefix string, state *storage.State) *TrackerStore

func (*TrackerStore) Get

func (ts *TrackerStore) Get(name string) (*Tracker, error)

func (*TrackerStore) GetConfig added in v0.14.0

func (ts *TrackerStore) GetConfig() BTCConfig

func (*TrackerStore) GetLockScript

func (ts *TrackerStore) GetLockScript(lockAddress []byte) ([]byte, error)

func (*TrackerStore) GetMaxAvailableBalance added in v0.14.0

func (ts *TrackerStore) GetMaxAvailableBalance() int64

func (*TrackerStore) GetOption added in v0.14.0

func (ts *TrackerStore) GetOption() bitcoin.ChainDriverOption

func (*TrackerStore) GetTrackerForLock

func (ts *TrackerStore) GetTrackerForLock() (*Tracker, error)

func (*TrackerStore) GetTrackerForRedeem

func (ts *TrackerStore) GetTrackerForRedeem() (*Tracker, error)

func (*TrackerStore) Iterate

func (ts *TrackerStore) Iterate(fn func(k, v []byte) bool)

func (*TrackerStore) SetConfig added in v0.14.0

func (ts *TrackerStore) SetConfig(config BTCConfig)

func (*TrackerStore) SetLockScript

func (ts *TrackerStore) SetLockScript(lockAddress, lockScript []byte) error

func (*TrackerStore) SetOption added in v0.14.0

func (ts *TrackerStore) SetOption(option bitcoin.ChainDriverOption)

func (*TrackerStore) SetTracker

func (ts *TrackerStore) SetTracker(name string, tracker *Tracker) error

func (*TrackerStore) WithState

func (ts *TrackerStore) WithState(state *storage.State) *TrackerStore

WithState updates the storage state of the tracker and returns the tracker address back

type UTXO

type UTXO struct {
	TxID    *chainhash.Hash
	Index   uint32
	Balance int64
}

func NewUTXO

func NewUTXO(txID *chainhash.Hash, index uint32, balance int64) *UTXO

Jump to

Keyboard shortcuts

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