Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Conversions ¶
func Conversions(amount Amount, coin Coin, isFee bool, ratesUpdater *rates.RateUpdater) map[string]string
Conversions handles fiat conversions
Types ¶
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 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 for formatting amounts, e.g. "BTC". // The fee unit is usually the same as the main unit, but can differ. Unit(isFee bool) string // Number of decimal places in the standard unit, e.g. 8 for Bitcoin. Must be in the range // [0..31]. Decimals(isFee bool) uint // FormatAmount formats the given amount as a number. FormatAmount(amount Amount, isFee bool) string // ToUnit returns the given amount in the unit as returned above. ToUnit(amount Amount, isFee bool) 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() // SmallestUnit returns the name of the smallest unit of a given coin SmallestUnit() string }
Coin models the currency of a blockchain.
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.