Documentation ¶
Index ¶
- func SignTransaction(keystores keystore.Keystores, txProposal *maketx.TxProposal, ...) error
- func XPubVersionForScriptType(coin *Coin, scriptType signing.ScriptType) [4]byte
- type Account
- func (account *Account) Balance() *coin.Balance
- func (account *Account) Close()
- func (account *Account) Code() string
- func (account *Account) Coin() coin.Coin
- func (account *Account) ConvertToLegacyAddress(addressID string) (btcutil.Address, error)
- func (account *Account) FeeTargets() ([]*FeeTarget, FeeTargetCode)
- func (account *Account) GetUnusedReceiveAddresses() []coin.Address
- func (account *Account) Info() *Info
- func (account *Account) Initialize() error
- func (account *Account) Initialized() bool
- func (account *Account) Keystores() keystore.Keystores
- func (account *Account) Name() string
- func (account *Account) Offline() bool
- func (account *Account) SendTx(recipientAddress string, amount coin.SendAmount, feeTargetCode FeeTargetCode, ...) error
- func (account *Account) SpendableOutputs() []*SpendableOutput
- func (account *Account) String() string
- func (account *Account) Transactions() []coin.Transaction
- func (account *Account) TxProposal(recipientAddress string, amount coin.SendAmount, feeTargetCode FeeTargetCode, ...) (coin.Amount, coin.Amount, coin.Amount, error)
- func (account *Account) VerifyAddress(addressID string) (bool, error)
- type Coin
- func (coin *Coin) BlockExplorerTransactionURLPrefix() string
- func (coin *Coin) Blockchain() blockchain.Interface
- func (coin *Coin) Code() string
- func (coin *Coin) FormatAmount(amount coinpkg.Amount) string
- func (coin *Coin) Headers() *headers.Headers
- func (coin *Coin) Initialize()
- func (coin *Coin) Net() *chaincfg.Params
- func (coin *Coin) String() string
- func (coin *Coin) ToUnit(amount coinpkg.Amount) float64
- func (coin *Coin) Unit() string
- type Event
- type FeeTarget
- type FeeTargetCode
- type Info
- type Interface
- type ProposedTransaction
- type SpendableOutput
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SignTransaction ¶
func SignTransaction( keystores keystore.Keystores, txProposal *maketx.TxProposal, previousOutputs map[wire.OutPoint]*transactions.SpendableOutput, getAddress func(blockchain.ScriptHashHex) *addresses.AccountAddress, log *logrus.Entry, ) error
SignTransaction signs all inputs. It assumes all outputs spent belong to this wallet. previousOutputs must contain all outputs which are spent by the transaction.
func XPubVersionForScriptType ¶
func XPubVersionForScriptType(coin *Coin, scriptType signing.ScriptType) [4]byte
XPubVersionForScriptType returns the xpub version bytes for the given coin and script type.
Types ¶
type Account ¶
Account is a account whose addresses are derived from an xpub.
func NewAccount ¶
func NewAccount( coin *Coin, dbFolder string, code string, name string, getSigningConfiguration func() (*signing.Configuration, error), keystores keystore.Keystores, onEvent func(Event), log *logrus.Entry, ) *Account
NewAccount creates a new account.
func (*Account) ConvertToLegacyAddress ¶
ConvertToLegacyAddress converts a ltc p2sh address to the legacy format (starting with '3'). Returns an error for non litecoin p2sh accounts.
func (*Account) FeeTargets ¶
func (account *Account) FeeTargets() ([]*FeeTarget, FeeTargetCode)
FeeTargets returns the fee targets and the default fee target.
func (*Account) GetUnusedReceiveAddresses ¶
GetUnusedReceiveAddresses returns a number of unused addresses.
func (*Account) Initialize ¶
Initialize initializes the account.
func (*Account) Initialized ¶
Initialized indicates whether the account has loaded and finished the initial sync of the addresses.
func (*Account) SendTx ¶
func (account *Account) SendTx( recipientAddress string, amount coin.SendAmount, feeTargetCode FeeTargetCode, selectedUTXOs map[wire.OutPoint]struct{}, _ []byte, ) error
SendTx creates, signs and sends tx which sends `amount` to the recipient.
func (*Account) SpendableOutputs ¶
func (account *Account) SpendableOutputs() []*SpendableOutput
SpendableOutputs returns the utxo set, sorted by the value descending.
func (*Account) Transactions ¶
func (account *Account) Transactions() []coin.Transaction
Transactions wraps transaction.Transactions.Transactions()
func (*Account) TxProposal ¶
func (account *Account) TxProposal( recipientAddress string, amount coin.SendAmount, feeTargetCode FeeTargetCode, selectedUTXOs map[wire.OutPoint]struct{}, _ []byte, ) ( coin.Amount, coin.Amount, coin.Amount, error)
TxProposal creates a tx from the relevant input and returns information about it for display in the UI (the output amount and the fee). At the same time, it validates the input.
type Coin ¶
type Coin struct { observable.Implementation // contains filtered or unexported fields }
Coin models a Bitcoin-related coin.
func NewCoin ¶
func NewCoin( code string, unit string, net *chaincfg.Params, dbFolder string, servers []*rpc.ServerInfo, blockExplorerTxPrefix string, ) *Coin
NewCoin creates a new coin with the given parameters.
func (*Coin) BlockExplorerTransactionURLPrefix ¶
BlockExplorerTransactionURLPrefix implements coin.Coin.
func (*Coin) Blockchain ¶
func (coin *Coin) Blockchain() blockchain.Interface
Blockchain connects to a blockchain backend.
func (*Coin) FormatAmount ¶
FormatAmount implements coin.Coin.
type Event ¶
type Event string
Event instances are sent to the onEvent callback of the wallet.
const ( // EventStatusChanged is fired when the status changes. Check the status using Initialized(). EventStatusChanged Event = "statusChanged" // EventSyncStarted is fired when syncing with the blockchain starts. This happens in the very // beginning for the initial sync, and repeatedly afterwards when the wallet is updated (new // transactions, confirmations, etc.). EventSyncStarted Event = "syncstarted" // EventSyncDone follows EventSyncStarted. EventSyncDone Event = "syncdone" // EventHeadersSynced is fired when the headers finished syncing. EventHeadersSynced Event = "headersSynced" // EventFeeTargetsChanged is fired when the fee targets change. EventFeeTargetsChanged Event = "feeTargetsChanged" )
type FeeTarget ¶
type FeeTarget struct { // Blocks is the target number of blocks in which the transaction should be confirmed. Blocks int // Code is the identifier for the UI. Code FeeTargetCode // FeeRatePerKb is the fee rate needed for this target. Can be nil until populated. FeeRatePerKb *btcutil.Amount }
FeeTarget contains the fee rate for a specific fee target.
type FeeTargetCode ¶
type FeeTargetCode string
FeeTargetCode models the code of a fee target. See the constants below.
const ( // FeeTargetCodeLow is the low priority fee target. FeeTargetCodeLow FeeTargetCode = "low" // FeeTargetCodeEconomy is the economy priority fee target. FeeTargetCodeEconomy FeeTargetCode = "economy" // FeeTargetCodeNormal is the normal priority fee target. FeeTargetCodeNormal FeeTargetCode = "normal" // FeeTargetCodeHigh is the high priority fee target. FeeTargetCodeHigh FeeTargetCode = "high" )
func NewFeeTargetCode ¶
func NewFeeTargetCode(code string) (FeeTargetCode, error)
NewFeeTargetCode checks if the code is valid and returns a FeeTargetCode in that case.
type Info ¶
type Info struct {
SigningConfiguration *signing.Configuration `json:"signingConfiguration"`
}
Info holds account information.
type Interface ¶
type Interface interface { Info() *Info // Code is a identifier for the account (to identify the account in databases, apis, etc.). Code() string Coin() coin.Coin // Name returns a human readable long name. Name() string // Initialize only starts the initialization, the account is not initialized right afterwards. Initialize() error Initialized() bool Offline() bool Close() Transactions() []coin.Transaction Balance() *coin.Balance // Creates, signs and broadcasts a transaction. Returns keystore.ErrSigningAborted on user // abort. SendTx(string, coin.SendAmount, FeeTargetCode, map[wire.OutPoint]struct{}, []byte) error FeeTargets() ([]*FeeTarget, FeeTargetCode) TxProposal(string, coin.SendAmount, FeeTargetCode, map[wire.OutPoint]struct{}, []byte) ( coin.Amount, coin.Amount, coin.Amount, error) GetUnusedReceiveAddresses() []coin.Address VerifyAddress(addressID string) (bool, error) ConvertToLegacyAddress(addressID string) (btcutil.Address, error) Keystores() keystore.Keystores SpendableOutputs() []*SpendableOutput }
Interface is the API of a Account.
type ProposedTransaction ¶
type ProposedTransaction struct { TXProposal *maketx.TxProposal PreviousOutputs map[wire.OutPoint]*transactions.SpendableOutput GetAddress func(blockchain.ScriptHashHex) *addresses.AccountAddress // Signatures collects the signatures (signatures[transactionInput][cosignerIndex]). Signatures [][]*btcec.Signature SigHashes *txscript.TxSigHashes }
ProposedTransaction contains all the info needed to sign a btc transaction.
type SpendableOutput ¶
type SpendableOutput struct { *transactions.SpendableOutput OutPoint wire.OutPoint }
SpendableOutput is an unspent coin.
type Status ¶
type Status string
Status indicates the connection and initialization status.
const ( // AccountSynced indicates that the account is synced. AccountSynced Status = "accountSynced" // AccountNotSynced indicates that the account is initialized, but not yet fully synced. AccountNotSynced Status = "accountNotSynced" // AccountDisabled indicates that the account has not yet been initialized. AccountDisabled Status = "accountDisabled" // OfflineMode indicates that the connection to the blockchain network could not be established. OfflineMode Status = "offlineMode" )