txwatcher

package
v0.2.97 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitcoinBlockchainRpc

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

func NewBitcoinRpc

func NewBitcoinRpc(bcli *gbitcoin.Bitcoin) *BitcoinBlockchainRpc

func (*BitcoinBlockchainRpc) GetBlockHash

func (b *BitcoinBlockchainRpc) GetBlockHash(height uint32) (string, error)

func (*BitcoinBlockchainRpc) GetBlockHeight

func (b *BitcoinBlockchainRpc) GetBlockHeight() (uint64, error)

func (*BitcoinBlockchainRpc) GetBlockHeightByHash

func (b *BitcoinBlockchainRpc) GetBlockHeightByHash(blockhash string) (uint32, error)

func (*BitcoinBlockchainRpc) GetRawtransactionWithBlockHash

func (b *BitcoinBlockchainRpc) GetRawtransactionWithBlockHash(txId string, blockHash string) (string, error)

func (*BitcoinBlockchainRpc) GetTxOut

func (b *BitcoinBlockchainRpc) GetTxOut(txid string, vout uint32) (*TxOutResp, error)

func (*BitcoinBlockchainRpc) String

func (b *BitcoinBlockchainRpc) String() string

type BlockchainRpc

type BlockchainRpc interface {
	GetBlockHeight() (uint64, error)
	GetTxOut(txid string, vout uint32) (*TxOutResp, error)
	GetBlockHash(height uint32) (string, error)
	GetRawtransactionWithBlockHash(txId string, blockHash string) (string, error)
	GetBlockHeightByHash(blockhash string) (uint32, error)
}

type BlockchainRpcTxWatcher

type BlockchainRpcTxWatcher struct {
	sync.Mutex
	// contains filtered or unexported fields
}

BlockchainRpcTxWatcher handles notifications of confirmed and csv-passed events

func NewBlockchainRpcTxWatcher

func NewBlockchainRpcTxWatcher(ctx context.Context, blockchain BlockchainRpc, requiredConfs uint32, csv uint32) *BlockchainRpcTxWatcher

func (*BlockchainRpcTxWatcher) AddConfirmationCallback

func (l *BlockchainRpcTxWatcher) AddConfirmationCallback(f func(swapId string, txHex string) error)

func (*BlockchainRpcTxWatcher) AddCsvCallback

func (l *BlockchainRpcTxWatcher) AddCsvCallback(f func(swapId string) error)

func (*BlockchainRpcTxWatcher) AddWaitForConfirmationTx

func (l *BlockchainRpcTxWatcher) AddWaitForConfirmationTx(swapId, txId string, vout, startingBlockheight uint32, _ []byte)

func (*BlockchainRpcTxWatcher) AddWaitForCsvTx

func (l *BlockchainRpcTxWatcher) AddWaitForCsvTx(swapId, txId string, vout uint32, startingBlockheight uint32, _ []byte)

func (*BlockchainRpcTxWatcher) CheckTxConfirmed

func (s *BlockchainRpcTxWatcher) CheckTxConfirmed(swapId string, txId string, vout uint32) string

func (*BlockchainRpcTxWatcher) GetBlockHeight

func (s *BlockchainRpcTxWatcher) GetBlockHeight() (uint32, error)

func (*BlockchainRpcTxWatcher) HandleConfirmedTx

func (s *BlockchainRpcTxWatcher) HandleConfirmedTx(blockheight uint64) error

HandleConfirmedTx looks for transactions that are confirmed fixme: why does this function return an error if no error ever is returned?

func (*BlockchainRpcTxWatcher) HandleCsvTx

func (s *BlockchainRpcTxWatcher) HandleCsvTx(blockheight uint64) error

HandleCsvTx looks for transactions that have enough confirmations to be spend using the csv path

func (*BlockchainRpcTxWatcher) StartBlockWatcher

func (s *BlockchainRpcTxWatcher) StartBlockWatcher(currentBlock uint64) error

StartBlockWatcher starts listening for new blocks

func (*BlockchainRpcTxWatcher) StartWatchingTxs

func (s *BlockchainRpcTxWatcher) StartWatchingTxs() error

StartWatchingTxs starts the txwatcher

func (*BlockchainRpcTxWatcher) TxClaimed

func (l *BlockchainRpcTxWatcher) TxClaimed(swaps []string)

func (*BlockchainRpcTxWatcher) TxHexFromId

func (l *BlockchainRpcTxWatcher) TxHexFromId(resp *TxOutResp, txId string) (string, error)

type ElementsBlockChainRpc

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

func NewElementsCli

func NewElementsCli(ecli *gelements.Elements) *ElementsBlockChainRpc

func (*ElementsBlockChainRpc) GetBlockHash

func (e *ElementsBlockChainRpc) GetBlockHash(height uint32) (string, error)

func (*ElementsBlockChainRpc) GetBlockHeight

func (e *ElementsBlockChainRpc) GetBlockHeight() (uint64, error)

func (*ElementsBlockChainRpc) GetBlockHeightByHash

func (e *ElementsBlockChainRpc) GetBlockHeightByHash(blockhash string) (uint32, error)

func (*ElementsBlockChainRpc) GetRawtransactionWithBlockHash

func (e *ElementsBlockChainRpc) GetRawtransactionWithBlockHash(txId string, blockHash string) (string, error)

func (*ElementsBlockChainRpc) GetTxOut

func (e *ElementsBlockChainRpc) GetTxOut(txid string, vout uint32) (*TxOutResp, error)

func (*ElementsBlockChainRpc) String

func (e *ElementsBlockChainRpc) String() string

type SwapTxInfo

type SwapTxInfo struct {
	TxId                string
	TxVout              uint32
	StartingBlockHeight uint32
	Csv                 uint32
}

type TxOutResp

type TxOutResp struct {
	BestBlockHash string  `json:"bestblock"`
	Confirmations uint32  `json:"confirmations"`
	Value         float64 `json:"value"`
	Coinbase      bool    `json:"coinbase"`
}

Jump to

Keyboard shortcuts

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