Documentation ¶
Index ¶
- Constants
- Variables
- func NewErrBitcoinSubmitTx(msg string) error
- func NewErrInsufficientBalance(address string, required, current int64) error
- func NewErrUnsupportedNetwork(network string) error
- func SuggestedTxRate(txSpeed TxExecutionSpeed) (int64, error)
- type Account
- type Client
- type Tx
- type TxBuilder
- type TxExecutionSpeed
- type Wallet
Constants ¶
const ( Nil = TxExecutionSpeed(iota) Slow Standard Fast )
TxExecutionSpeed values.
const BitcoinDust = 600
const MaxBitcoinFee = int64(10000)
Variables ¶
var ErrMismatchedPubKeys = fmt.Errorf("failed to fund the transaction mismatched script public keys")
var ErrNoSpendingTransactions = fmt.Errorf("No spending transactions")
var ErrPostConditionCheckFailed = errors.New("post-condition check failed")
ErrPostConditionCheckFailed indicates that the post-condition for executing a transaction failed.
var ErrPreConditionCheckFailed = errors.New("pre-condition check failed")
ErrPreConditionCheckFailed indicates that the pre-condition for executing a transaction failed.
var ErrTimedOut = errors.New("timed out")
Functions ¶
func NewErrBitcoinSubmitTx ¶
func SuggestedTxRate ¶
func SuggestedTxRate(txSpeed TxExecutionSpeed) (int64, error)
SuggestedTxRate returns the gas price that bitcoinfees.earn.com recommends for transactions to be mined on Bitcoin blockchain based on the speed provided.
Types ¶
type Account ¶
type Account interface { Client BTCClient() Client Address() (btcutil.Address, error) SerializedPublicKey() ([]byte, error) Transfer(ctx context.Context, to string, value int64, speed TxExecutionSpeed, sendAll bool) (string, int64, error) BuildTransfer(ctx context.Context, to string, value int64, speed TxExecutionSpeed, sendAll bool) (string, []byte, error) SendTransaction( ctx context.Context, script []byte, speed TxExecutionSpeed, updateTxIn func(*wire.TxIn), preCond func(*wire.MsgTx) bool, f func(*txscript.ScriptBuilder), postCond func(*wire.MsgTx) bool, sendAll bool, ) (string, int64, error) BuildTransaction( ctx context.Context, contract []byte, speed TxExecutionSpeed, updateTxIn func(*wire.TxIn), preCond func(*wire.MsgTx) bool, f func(*txscript.ScriptBuilder), postCond func(*wire.MsgTx) bool, sendAll bool, ) (string, []byte, error) }
Account is an Bitcoin external account that can sign and submit transactions to the Bitcoin blockchain. An Account is an abstraction over the Bitcoin blockchain.
func NewAccount ¶
func NewAccount(client Client, privateKey *ecdsa.PrivateKey, logger logrus.FieldLogger) Account
NewAccount returns a user account for the provided private key which is connected to a Bitcoin client.
type Client ¶
type Client interface { clients.ClientCore // Balance of the given address on Bitcoin blockchain. Balance(ctx context.Context, address string, confirmations int64) (int64, error) // FormatTransactionView formats the message and txhash into a user friendly // message. FormatTransactionView(msg, txhash string) string // SerializePublicKey serializes the given public key. SerializePublicKey(pubKey *btcec.PublicKey) ([]byte, error) // PublicKeyToAddress converts the public key to a bitcoin address. PublicKeyToAddress(pubKeyBytes []byte) (btcutil.Address, error) // SlaveAddress creates an a deterministic unique address that can be spent // by the private key correspndong to the given master public key hash SlaveAddress(mpkh, nonce []byte) (btcutil.Address, error) // SlaveScript creates a deterministic unique script that can be spent by // the private key correspndong to the given master public key hash SlaveScript(mpkh, nonce []byte) ([]byte, error) // UTXOCount returns the number of utxos that can be spent. UTXOCount(ctx context.Context, address string, confirmations int64) (int, error) // Validate returns whether an address is valid or not Validate(address string) error }
func NewBitcoinFNClient ¶
func NewBlockchainInfoClient ¶
func NewMercuryClient ¶
type TxBuilder ¶
type TxBuilder interface {
Build(ctx context.Context, pubKey ecdsa.PublicKey, to string, contract []byte, value int64, mwUTXOs, scriptUTXOs []clients.UTXO) (Tx, error)
}
func NewTxBuilder ¶
type TxExecutionSpeed ¶
type TxExecutionSpeed uint8
The TxExecutionSpeed indicates the tier of speed that the transaction falls under while writing to the blockchain.