Documentation ¶
Index ¶
- Constants
- func GetBech32AccountPubKey(key *btcec.PrivateKey) (common.PubKey, error)
- type BlockMeta
- type BlockMetaAccessor
- type Client
- func (c *Client) BroadcastTx(txOut stypes.TxOutItem, payload []byte) error
- func (c *Client) FetchTxs(height int64) (types.TxIn, error)
- func (c *Client) GetAccount(pkey common.PubKey) (common.Account, error)
- func (c *Client) GetAccountByAddress(address string) (common.Account, error)
- func (c *Client) GetAddress(poolPubKey common.PubKey) string
- func (c *Client) GetChain() common.Chain
- func (c *Client) GetConfig() config.ChainConfiguration
- func (c *Client) GetHeight() (int64, error)
- func (c *Client) OnObservedTxIn(txIn types.TxInItem, blockHeight int64)
- func (c *Client) SignTx(tx stypes.TxOutItem, thorchainHeight int64) ([]byte, error)
- func (c *Client) Start(globalTxsQueue chan types.TxIn, globalErrataQueue chan types.ErrataBlock)
- func (c *Client) Stop()
- type KeySignWrapper
- type LevelDBBlockMetaAccessor
- func (t *LevelDBBlockMetaAccessor) GetBlockMeta(height int64) (*BlockMeta, error)
- func (t *LevelDBBlockMetaAccessor) GetBlockMetas() ([]*BlockMeta, error)
- func (t *LevelDBBlockMetaAccessor) GetTransactionFee() (float64, int32, error)
- func (t *LevelDBBlockMetaAccessor) PruneBlockMeta(height int64) error
- func (t *LevelDBBlockMetaAccessor) SaveBlockMeta(height int64, blockMeta *BlockMeta) error
- func (t *LevelDBBlockMetaAccessor) UpsertTransactionFee(fee float64, vSize int32) error
- type TransactionFee
- type TssSignable
- type UnspentTransactionOutput
Constants ¶
const ( TransactionFeeKey = "transactionfee-" PrefixBlocMeta = `blockmeta-` )
PrefixUTXOStorage declares prefix to use in leveldb to avoid conflicts
const ( // SatsPervBytes it should be enough , this one will only be used if signer can't find any previous UTXO , and fee info from local storage. SatsPervBytes = 25 // MinUTXOConfirmation UTXO that has less confirmation then this will not be spent , unless it is yggdrasil MinUTXOConfirmation = 10 )
const BlockCacheSize = 100
BlockCacheSize the number of block meta that get store in storage.
Variables ¶
This section is empty.
Functions ¶
func GetBech32AccountPubKey ¶
func GetBech32AccountPubKey(key *btcec.PrivateKey) (common.PubKey, error)
GetBech32AccountPubKey convert the given private key to
Types ¶
type BlockMeta ¶
type BlockMeta struct { PreviousHash string `json:"previous_hash"` Height int64 `json:"height"` BlockHash string `json:"block_hash"` UnspentTransactionOutputs []UnspentTransactionOutput `json:"utxos"` }
BlockMeta is a structure to store the blocks bifrost scanned
func NewBlockMeta ¶
NewBlockMeta create a new instance of BlockMeta
func (*BlockMeta) AddUTXO ¶
func (b *BlockMeta) AddUTXO(utxo UnspentTransactionOutput)
AddUTXO add the given utxo to blockmeta
func (*BlockMeta) GetUTXOs ¶
func (b *BlockMeta) GetUTXOs(pubKey common.PubKey) []UnspentTransactionOutput
GetUTXOs that match the given pubkey and are unspent
func (*BlockMeta) RemoveUTXO ¶
RemoveUTXO - remove a given UTXO from the storage ,because we already spent it
func (*BlockMeta) UnspendUTXO ¶
UnspendUTXO mark utxo as unspent
type BlockMetaAccessor ¶
type BlockMetaAccessor interface { GetBlockMetas() ([]*BlockMeta, error) GetBlockMeta(height int64) (*BlockMeta, error) SaveBlockMeta(height int64, blockMeta *BlockMeta) error PruneBlockMeta(height int64) error UpsertTransactionFee(fee float64, vSize int32) error GetTransactionFee() (float64, int32, error) }
BlockMetaAccessor define methods need to access block meta storage
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client observes bitcoin chain and allows to sign and broadcast tx
func NewClient ¶
func NewClient(thorKeys *thorclient.Keys, cfg config.ChainConfiguration, server *tssp.TssServer, bridge *thorclient.ThorchainBridge, m *metrics.Metrics, keySignPartyMgr *thorclient.KeySignPartyMgr) (*Client, error)
NewClient generates a new Client
func (*Client) BroadcastTx ¶
BroadcastTx will broadcast the given payload to BTC chain
func (*Client) GetAccount ¶
GetAccount returns account with balance for an address
func (*Client) GetAccountByAddress ¶
func (*Client) GetAddress ¶
GetAddress returns address from pubkey
func (*Client) GetConfig ¶
func (c *Client) GetConfig() config.ChainConfiguration
GetConfig - get the chain configuration
func (*Client) OnObservedTxIn ¶
OnObservedTxIn gets called from observer when we have a valid observation For bitcoin chain client we want to save the utxo we can spend later to sign
type KeySignWrapper ¶
type KeySignWrapper struct {
// contains filtered or unexported fields
}
KeySignWrapper is a wrap of private key and also tss instance it also implement the txscript.Signable interface, and will decide which method to use based on the pubkey
func NewKeySignWrapper ¶
func NewKeySignWrapper(privateKey *btcec.PrivateKey, bridge *thorclient.ThorchainBridge, tssKeyManager tss.ThorchainKeyManager, keySignPartyMgr *thorclient.KeySignPartyMgr) (*KeySignWrapper, error)
NewKeysignWrapper create a new instance of Keysign Wrapper
func (*KeySignWrapper) GetSignable ¶
func (w *KeySignWrapper) GetSignable(poolPubKey common.PubKey) txscript.Signable
GetSignable based on the given poolPubKey
type LevelDBBlockMetaAccessor ¶
type LevelDBBlockMetaAccessor struct {
// contains filtered or unexported fields
}
LevelDBBlockMetaAccessor struct
func NewLevelDBBlockMetaAccessor ¶
func NewLevelDBBlockMetaAccessor(db *leveldb.DB) (*LevelDBBlockMetaAccessor, error)
NewLevelDBBlockMetaAccessor creates a new level db backed BlockMeta accessor
func (*LevelDBBlockMetaAccessor) GetBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) GetBlockMeta(height int64) (*BlockMeta, error)
GetBlockMeta at given block height , when the requested block meta doesn't exist , it will return nil , thus caller need to double check it
func (*LevelDBBlockMetaAccessor) GetBlockMetas ¶
func (t *LevelDBBlockMetaAccessor) GetBlockMetas() ([]*BlockMeta, error)
GetBlockMetas returns all the block metas in storage The chain client will Prune block metas every time it finished scan a block , so at maximum it will keep BlockCacheSize blocks thus it should not grow out of control
func (*LevelDBBlockMetaAccessor) GetTransactionFee ¶
func (t *LevelDBBlockMetaAccessor) GetTransactionFee() (float64, int32, error)
GetTransactionFee from db
func (*LevelDBBlockMetaAccessor) PruneBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) PruneBlockMeta(height int64) error
PruneBlockMeta remove all block meta that is older than the given block height with exception, if there are unspent transaction output in it , then the block meta will not be removed
func (*LevelDBBlockMetaAccessor) SaveBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) SaveBlockMeta(height int64, blockMeta *BlockMeta) error
SaveBlockMeta persistent the given BlockMeta into storage
func (*LevelDBBlockMetaAccessor) UpsertTransactionFee ¶
func (t *LevelDBBlockMetaAccessor) UpsertTransactionFee(fee float64, vSize int32) error
UpsertTransactionFee update the transaction fee in storage
type TransactionFee ¶
TransactionFee on bitcoin
type TssSignable ¶
type TssSignable struct {
// contains filtered or unexported fields
}
TssSignable is a signable implementation backed by tss
func NewTssSignable ¶
func NewTssSignable(pubKey common.PubKey, manager tss.ThorchainKeyManager, keySignPartyMgr *thorclient.KeySignPartyMgr) (*TssSignable, error)
NewTssSignable create a new instance of TssSignable
func (*TssSignable) GetPubKey ¶
func (ts *TssSignable) GetPubKey() *btcec.PublicKey
type UnspentTransactionOutput ¶
type UnspentTransactionOutput struct { TxID chainhash.Hash `json:"tx_id"` N uint32 `json:"n"` Value float64 `json:"value"` BlockHeight int64 `json:"block_height"` VaultPubKey common.PubKey `json:"vault_pub_key"` Spent bool `json:"spent"` }
UnspentTransactionOutput struct
func NewUnspentTransactionOutput ¶
func NewUnspentTransactionOutput(txID chainhash.Hash, n uint32, value float64, blockHeight int64, vaultPubKey common.PubKey) UnspentTransactionOutput
NewUnspentTransactionOutput create a new instance of UnspentTransactionOutput
func (UnspentTransactionOutput) GetKey ¶
func (t UnspentTransactionOutput) GetKey() string
GetKey return a key