Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidAddress is used when the recipient address is invalid or does not match the correct // network. ErrInvalidAddress = TxValidationError("invalidAddress") // ErrInvalidAmount is used when the user entered amount is malformatted or not positive. ErrInvalidAmount = TxValidationError("invalidAmount") // ErrInvalidData is used when the user entered data is not hexadecimal. ErrInvalidData = TxValidationError("invalidData") // ErrInsufficientFunds is returned when there are not enough funds to cover the target amount // and fee. ErrInsufficientFunds = TxValidationError("insufficientFunds") )
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address interface { // ID is an identifier for the address. ID() string EncodeForHumans() string }
Address models a blockchain address to which coins can be sent.
type Amount ¶
type Amount struct {
// contains filtered or unexported fields
}
Amount represents an amount in the smallest coin unit (e.g. satoshi).
func NewAmountFromInt64 ¶
NewAmountFromInt64 creates a new amount.
func NewAmountFromString ¶
NewAmountFromString parses a user given coin amount, converting it from the default coin unit to the the smallest unit.
type Balance ¶
type Balance struct {
// contains filtered or unexported fields
}
Balance contains the available and incoming balance of an account.
func NewBalance ¶
NewBalance creates a new balance with the given amounts.
type Coin ¶
type Coin interface { observable.Interface // Code returns the code used to identify the coin (should be the acronym of the coin in // lowercase). Code() string // Unit is the unit code of the string for formatting amounts. Unit() string // FormatAmount formats the given amount as a number. FormatAmount(Amount) string // ToUnit returns the given amount in the unit as returned above. ToUnit(Amount) float64 // BlockExplorerTransactionURLPrefix returns the URL prefix of the block explorer. BlockExplorerTransactionURLPrefix() string // Initialize initializes the coin by connecting to a full node, downloading the headers, etc. Initialize() }
Coin models the currency of a blockchain.
type ProposedTransaction ¶
type ProposedTransaction interface { }
ProposedTransaction models a proposed but not yet fully signed transaction of the given coin.
type SendAmount ¶
type SendAmount struct {
// contains filtered or unexported fields
}
SendAmount is either a concrete amount, or "all"/"max". The concrete amount is user input and is parsed/validated in Amount().
func NewSendAmount ¶
func NewSendAmount(amount string) SendAmount
NewSendAmount creates a new SendAmount based on a concrete amount.
func NewSendAmountAll ¶
func NewSendAmountAll() SendAmount
NewSendAmountAll creates a new Sendall-amount.
func (SendAmount) Amount ¶
Amount parses the amount and converts it from the default unit to the smallest unit (e.g. satoshi = 1e8). Returns an error if the amount is negative, or depending on allowZero, if it is zero.
func (*SendAmount) SendAll ¶
func (sendAmount *SendAmount) SendAll() bool
SendAll returns if this represents a send-all input.
type Transaction ¶
type Transaction interface { // Fee is nil for a receiving tx. The fee is only displayed (and relevant) when sending funds // from the wallet. Fee() *Amount // Time of confirmation. nil for unconfirmed tx or when the headers are not synced yet. Timestamp() *time.Time // ID is the tx ID. ID() string // NumConfirmations is the number of confirmations. 0 for unconfirmed. NumConfirmations() int // Type returns the type of the transaction. Type() TxType // Amount is always >0 and is the amount received or sent (not including the fee). Amount() Amount // Addresses money was sent to / received on. Addresses() []string }
Transaction models a transaction with common transaction info.
type TxValidationError ¶
type TxValidationError string
TxValidationError represents errors in the tx proposal input data.
func (TxValidationError) Error ¶
func (err TxValidationError) Error() string