Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service interface {
// GetUnspents fetches and optionally unblinds utxos for the given address.
GetUnspents(addr string, blindKeys [][]byte) (unspents []Utxo, err error)
// GetUnspentsForAddresses fetches and optionally unblinds utxos of the given
// list of addresses.
GetUnspentsForAddresses(
addresses []string,
blindingKeys [][]byte,
) (unspents []Utxo, err error)
// GetUnspentStatus returns the status of the provided unspent txid:index.
GetUnspentStatus(txid string, index uint32) (status UtxoStatus, err error)
// GetTransaction fetches the transaction given its hash.
GetTransaction(txid string) (tx Transaction, err error)
// GetTransactionHex fetches the transaction in hex format given its hash.
GetTransactionHex(txid string) (txhex string, err error)
// IsTransactionConfirmed returns whether the tx identified by its hash has
// been included in the blockchain.
IsTransactionConfirmed(txid string) (confirmed bool, err error)
// GetTransactionStatus returns the status of the tx identified by its hash.
GetTransactionStatus(txid string) (status TransactionStatus, err error)
// GetTransactionsForAddress returns the list of all txs relative to the
// given address.
GetTransactionsForAddress(address string, blindingKey []byte) (txs []Transaction, err error)
// BroadcastTransaction attempts to add the given tx in hex format to the
// mempool and returns its tx hash.
BroadcastTransaction(txhex string) (txid string, err error)
// GetBlockHeight returns the the number of block of the blockchain.
GetBlockHeight() (int, error)
// PollGetKnownTransaction polls the GetTransaction method until the transaction
// is actualy returned by the explorer. It may be needed when the explorer
// suffers of delays to keep in sync with the mempool/blockchain.
PollGetKnownTransaction(txid string, interval time.Duration) (tx Transaction, err error)
/**** REGTEST ONLY ****/
// Faucet funds the given address with the amount (in BTC) of provided asset
Faucet(address string, amount float64, asset string) (txid string, err error)
// Mint funds the given address with a certain amount (in BTC) of a new issued asset.
Mint(address string, amount float64) (txid string, asset string, err error)
}
Service is representation of an explorer that allows to fetch data from the blockchain, to broadcast transactions, and for regtest ONLY, to fund and and address with LBTC or some other asset.
type Transaction ¶
type Transaction interface {
Hash() string
Version() int
Locktime() int
Inputs() []*transaction.TxInput
Outputs() []*transaction.TxOutput
Size() int
Weight() int
Confirmed() bool
}
Transaction represents a transaction in the elements chain.
type TransactionStatus ¶
type Utxo ¶
type Utxo interface {
Hash() string
Index() uint32
Value() uint64
Asset() string
ValueCommitment() string
AssetCommitment() string
ValueBlinder() []byte
AssetBlinder() []byte
Script() []byte
Nonce() []byte
RangeProof() []byte
SurjectionProof() []byte
IsConfidential() bool
IsConfirmed() bool
IsRevealed() bool
Parse() (*transaction.TxInput, *transaction.TxOutput, error)
}
Utxo represents a transaction output in the elements chain.
func SelectUnspents ¶
func SelectUnspents( utxos []Utxo, targetAmount uint64, targetAsset string, ) (coins []Utxo, change uint64, err error)
SelectUnspents performs a coin selection over the given list of Utxos and returns a subset of them of type targetAsset to cover the targetAmount. In case any utxo is confidential, it's required that's already unblinded
type UtxoStatus ¶
UtxoStatus represents whether a UTXO is spent. If it's actually spent, it provides methods to know the hash and input index of the tx that spent it.