Documentation ¶
Index ¶
Constants ¶
const ( // DefaultClientTimeout used by the Client. DefaultClientTimeout = time.Minute // DefaultClientTimeoutRetry used by the Client. DefaultClientTimeoutRetry = time.Second // DefaultClientHost used by the Client. This should only be used for local // deployments of the multichain. DefaultClientHost = "http://0.0.0.0:18443" // DefaultClientUser used by the Client. This is insecure, and should only // be used for local — or publicly accessible — deployments of the // multichain. DefaultClientUser = "user" // DefaultClientPassword used by the Client. This is insecure, and should // only be used for local — or publicly accessible — deployments of the // multichain. DefaultClientPassword = "password" )
const Version int32 = 2
Version of Bitcoin transactions supported by the multichain.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressDecoder ¶
type AddressDecoder struct {
// contains filtered or unexported fields
}
AddressDecoder encapsulates the chain specific configurations and implements the address.Decoder interface
func NewAddressDecoder ¶
func NewAddressDecoder(params *chaincfg.Params) AddressDecoder
NewAddressDecoder constructs a new AddressDecoder with the chain specific configurations
func (AddressDecoder) DecodeAddress ¶
func (decoder AddressDecoder) DecodeAddress(addr address.Address) (address.RawAddress, error)
DecodeAddress implements the address.Decoder interface
type AddressEncodeDecoder ¶
type AddressEncodeDecoder struct { AddressEncoder AddressDecoder }
AddressEncodeDecoder implements the address.EncodeDecoder interface
func NewAddressEncodeDecoder ¶
func NewAddressEncodeDecoder(params *chaincfg.Params) AddressEncodeDecoder
NewAddressEncodeDecoder constructs a new AddressEncodeDecoder with the chain specific configurations
type AddressEncoder ¶
type AddressEncoder struct {
// contains filtered or unexported fields
}
AddressEncoder encapsulates the chain specific configurations and implements the address.Encoder interface
func NewAddressEncoder ¶
func NewAddressEncoder(params *chaincfg.Params) AddressEncoder
NewAddressEncoder constructs a new AddressEncoder with the chain specific configurations
func (AddressEncoder) EncodeAddress ¶
func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress) (address.Address, error)
EncodeAddress implements the address.Encoder interface
type Client ¶
type Client interface { utxo.Client // UnspentOutputs spendable by the given address. UnspentOutputs(ctx context.Context, minConf, maxConf int64, address address.Address) ([]utxo.Output, error) // Confirmations of a transaction in the Bitcoin network. Confirmations(ctx context.Context, txHash pack.Bytes) (int64, error) // EstimateSmartFee EstimateSmartFee(ctx context.Context, numBlocks int64) (float64, error) // EstimateFeeLegacy EstimateFeeLegacy(ctx context.Context, numBlocks int64) (float64, error) }
A Client interacts with an instance of the Bitcoin network using the RPC interface exposed by a Bitcoin node.
type ClientOptions ¶
type ClientOptions struct { Timeout time.Duration TimeoutRetry time.Duration Host string User string Password string }
ClientOptions are used to parameterise the behaviour of the Client.
func DefaultClientOptions ¶
func DefaultClientOptions() ClientOptions
DefaultClientOptions returns ClientOptions with the default settings. These settings are valid for use with the default local deployment of the multichain. In production, the host, user, and password should be changed.
func (ClientOptions) WithHost ¶
func (opts ClientOptions) WithHost(host string) ClientOptions
WithHost sets the URL of the Bitcoin node.
func (ClientOptions) WithPassword ¶
func (opts ClientOptions) WithPassword(password string) ClientOptions
WithPassword sets the password that will be used to authenticate with the Bitcoin node.
func (ClientOptions) WithUser ¶
func (opts ClientOptions) WithUser(user string) ClientOptions
WithUser sets the username that will be used to authenticate with the Bitcoin node.
type GasEstimator ¶
type GasEstimator struct {
// contains filtered or unexported fields
}
A GasEstimator returns the SATs-per-byte that is needed in order to confirm transactions with an estimated maximum delay of one block. In distributed networks that collectively build, sign, and submit transactions, it is important that all nodes in the network have reached consensus on the SATs-per-byte.
func NewGasEstimator ¶
func NewGasEstimator(client Client, numBlocks int64, fallbackGas pack.U256) GasEstimator
NewGasEstimator returns a simple gas estimator that always returns the given number of SATs-per-byte.
func (GasEstimator) EstimateGas ¶
EstimateGas returns the number of SATs-per-byte (for both price and cap) that is needed in order to confirm transactions with an estimated maximum delay of `numBlocks` block. It is the responsibility of the caller to know the number of bytes in their transaction. This method calls the `estimatesmartfee` RPC call to the node, which based on a conservative (considering longer history) strategy returns the estimated BTC per kilobyte of data in the transaction. An error will be returned if the bitcoin node hasn't observed enough blocks to make an estimate for the provided target `numBlocks`.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a simple Bitcoin transaction that implements the Bitcoin Compat API.
type TxBuilder ¶
type TxBuilder struct {
// contains filtered or unexported fields
}
The TxBuilder is an implementation of a UTXO-compatible transaction builder for Bitcoin.
func NewTxBuilder ¶
NewTxBuilder returns a transaction builder that builds UTXO-compatible Bitcoin transactions for the given chain configuration (this means that it can be used for regnet, testnet, and mainnet, but also for networks that are minimally modified forks of the Bitcoin network).
func (TxBuilder) BuildTx ¶
func (txBuilder TxBuilder) BuildTx(inputs []utxo.Input, recipients []utxo.Recipient) (utxo.Tx, error)
BuildTx returns a Bitcoin transaction that consumes funds from the given inputs, and sends them to the given recipients. The difference in the sum value of the inputs and the sum value of the recipients is paid as a fee to the Bitcoin network. This fee must be calculated independently of this function. Outputs produced for recipients will use P2PKH, P2SH, P2WPKH, or P2WSH scripts as the pubkey script, based on the format of the recipient address.