Documentation
¶
Index ¶
- Variables
- func NewErrBitcoinSubmitTx(msg string) error
- func NewErrInsufficientBalance(address string, required, current int64) error
- func NewErrUnsupportedNetwork(network string) error
- type Account
- type Address
- type Block
- type Blocks
- type Client
- type Input
- type LatestBlock
- type MultiAddress
- type Output
- type PreviousOut
- type SingleAddress
- type Transaction
- type Unspent
- type UnspentOutput
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMismatchedPubKeys = fmt.Errorf("failed to fund the transaction mismatched script public keys")
View Source
var ErrNoSpendingTransactions = fmt.Errorf("No spending transactions")
View Source
var ErrPostConditionCheckFailed = errors.New("post-condition check failed")
ErrPostConditionCheckFailed indicates that the post-condition for executing a transaction failed.
View Source
var ErrPreConditionCheckFailed = errors.New("pre-condition check failed")
ErrPreConditionCheckFailed indicates that the pre-condition for executing a transaction failed.
View Source
var ErrTimedOut = errors.New("timed out")
Functions ¶
func NewErrBitcoinSubmitTx ¶
Types ¶
type Account ¶
type Account interface {
Client
Address() (btcutil.Address, error)
SerializedPublicKey() ([]byte, error)
Transfer(ctx context.Context, to string, value, fee int64, sendAll bool) (string, error)
SendTransaction(
ctx context.Context,
script []byte,
fee int64,
updateTxIn func(*wire.TxIn),
preCond func(*wire.MsgTx) bool,
f func(*txscript.ScriptBuilder),
postCond func(*wire.MsgTx) bool,
) 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) Account
NewAccount returns a user account for the provided private key which is connected to a Bitcoin client.
type Block ¶
type Block struct {
BlockHash string `json:"hash"`
Version uint8 `json:"ver"`
PreviousBlockHash string `json:"prev_block"`
MerkleRoot string `json:"mrkl_root"`
Time int64 `json:"time"`
Bits int64 `json:"bits"`
Nonce int64 `json:"nonce"`
TransactionCount int `json:"n_tx"`
Size int64 `json:"size"`
BlockIndex uint64 `json:"block_index"`
MainChain bool `json:"main_chain"`
Height int64 `json:"height"`
ReceivedTime int64 `json:"received_time"`
RelayedBy string `json:"relayed_by"`
Transactions []Transaction `json:"tx"`
}
type Client ¶
type Client interface {
// NetworkParams should return the network parameters of the underlying
// Bitcoin blockchain.
NetworkParams() *chaincfg.Params
GetUnspentOutputs(ctx context.Context, address string, limit, confitmations int64) (Unspent, error)
GetRawTransaction(ctx context.Context, txhash string) (Transaction, error)
GetRawAddressInformation(ctx context.Context, addr string) (SingleAddress, error)
// PublishTransaction should publish a signed transaction to the Bitcoin
// blockchain.
PublishTransaction(ctx context.Context, signedTransaction []byte) error
// Balance of the given address on Bitcoin blockchain.
Balance(ctx context.Context, address string, confirmations int64) (int64, error)
// ScriptSpent checks whether a script is spent.
ScriptSpent(ctx context.Context, address string) (bool, error)
// ScriptFunded checks whether a script is funded.
ScriptFunded(ctx context.Context, address string, value int64) (bool, int64, error)
ScriptRedeemed(ctx context.Context, address string, value int64) (bool, int64, error)
GetScriptFromSpentP2SH(ctx context.Context, address string) ([]byte, error)
Confirmations(ctx context.Context, txHash string) (int64, error)
// FormatTransactionView formats the message and txhash into a user friendly
// message.
FormatTransactionView(msg, txhash string) string
}
func NewBlockchainInfoClient ¶
type Input ¶
type Input struct {
PrevOut PreviousOut `json:"prev_out"`
Script string `json:"script"`
}
type LatestBlock ¶
type MultiAddress ¶
type MultiAddress struct {
Addresses []Address `json:"addresses"`
Transactions []Transaction `json:"txs"`
}
type PreviousOut ¶
type SingleAddress ¶
type SingleAddress struct {
PublicKeyHash string `json:"hash160"`
Address string `json:"address"`
TransactionCount int64 `json:"n_tx"`
UnredeemedTransactionCount int64 `json:"n_unredeemed"`
Received int64 `json:"total_received"`
Sent int64 `json:"total_sent"`
Balance int64 `json:"final_balance"`
Transactions []Transaction `json:"txs"`
}
type Transaction ¶
type Transaction struct {
TransactionHash string `json:"hash"`
Version uint8 `json:"ver"`
VinSize uint32 `json:"vin_sz"`
VoutSize uint32 `json:"vout_sz"`
Size int64 `json:"size"`
RelayedBy string `json:"relayed_by"`
BlockHeight int64 `json:"block_height"`
TransactionIndex uint64 `json:"tx_index"`
Inputs []Input `json:"inputs"`
Outputs []Output `json:"out"`
}
type Unspent ¶
type Unspent struct {
Outputs []UnspentOutput `json:"unspent_outputs"`
}
Click to show internal directories.
Click to hide internal directories.