Documentation
¶
Index ¶
- Constants
- func GatewayPubKeyScript(gpubkey pack.Bytes, ghash pack.Bytes32) ([]byte, error)
- func GatewayScript(gpubkey pack.Bytes, ghash pack.Bytes32) ([]byte, error)
- type Address
- type AddressDecoder
- type AddressDecoderCallbacks
- type Client
- type ClientOptions
- type GasEstimator
- type Input
- type Outpoint
- type Output
- type Recipient
- type Tx
- type TxBuilder
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" )
Variables ¶
This section is empty.
Functions ¶
func GatewayPubKeyScript ¶
GatewayPubKeyScript returns the pubkey script of a Bitcoin gateway script. This is the pubkey script that is expected to be in the underlying transaction output for lock-and-mint cross-chain transactions (when working with BTC).
Types ¶
type Address ¶
An Address is a public address that can be encoded/decoded to/from strings. Addresses are usually formatted different between different network configurations.
type AddressDecoder ¶
The AddressDecoder defines an interface for decoding string representations of Bitcoin address into the Address interface.
type AddressDecoderCallbacks ¶
AddressDecoderCallbacks implements the AddressDecoder interface by allowing users to define closures for all required methods.
func (AddressDecoderCallbacks) DecodeAddress ¶
func (cbs AddressDecoderCallbacks) DecodeAddress(encoded pack.String) (Address, error)
DecodeAddress delegates the method to an inner callback. If not callback exists, then an error is returned.
type Client ¶
type Client interface {
// Output associated with an outpoint, and its number of confirmations.
Output(ctx context.Context, outpoint Outpoint) (Output, int64, error)
// UnspentOutputs spendable by the given address.
UnspentOutputs(ctx context.Context, minConf, maxConf int64, address Address) ([]Output, error)
// Confirmations of a transaction in the Bitcoin network.
Confirmations(ctx context.Context, txHash pack.Bytes32) (int64, error)
// SubmitTx to the Bitcoin network.
SubmitTx(ctx context.Context, tx Tx) (pack.Bytes32, 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 ¶
A GasEstimator returns the gas-per-byte that is needed in order to confirm transactions with relatively high speed. In distributed networks that work to collectively build transactions, it is important that all nodes return the same values from this interface.
func NewGasEstimator ¶
func NewGasEstimator(satsPerByte pack.U64) GasEstimator
NewGasEstimator returns a simple gas estimator that always returns the same amount of gas-per-byte.
type Input ¶
An Input to a Bitcoin transaction. It consumes an outpoint, and contains a signature script that satisfies the pubkey script of the output that it is consuming.
https://developer.bitcoin.org/reference/transactions.html#txin-a-transaction-input-non-coinbase
type Outpoint ¶
An Outpoint is a transaction outpoint, identifying a specific part of a transaction output.
type Output ¶
type Output struct {
Outpoint Outpoint `json:"outpoint"`
Value pack.U64 `json:"value"`
PubKeyScript pack.Bytes `json:"pubKeyScript"`
}
An Output of a Bitcoin transaction. It contains a pubkey script that defines the conditions required to spend the output.
https://developer.bitcoin.org/reference/transactions.html#txout-a-transaction-output
type Recipient ¶
A Recipient of funds from a Bitcoin transaction. This is useful for buidling simple pay-to-address Bitcoin transactions.
type Tx ¶
type Tx interface {
// Hash of the transaction.
Hash() pack.Bytes32
// Sighashes that need to be signed before this transaction can be
// submitted.
Sighashes() ([]pack.Bytes32, error)
// Sign the transaction by injecting signatures and the serialized pubkey of
// the signer.
Sign([]pack.Bytes65, pack.Bytes) error
// Serialize the transaction.
Serialize() (pack.Bytes, error)
}
Tx defines an interface that must be implemented by all types of Bitcoin transactions.
type TxBuilder ¶
type TxBuilder interface {
// BuildTx returns a simple Bitcoin transaction that consumes a set of
// Bitcoin outputs and uses the funds to make payments to a set of Bitcoin
// recipients. The sum value of the inputs must be greater than the sum
// value of the outputs, and the difference is paid as a fee to the Bitcoin
// network.
BuildTx(inputs []Output, recipients []Recipient) (Tx, error)
}
TxBuilder defines an interface that can be used to build simple Bitcoin transactions.