Documentation ¶
Index ¶
- func SignTransaction(keystores keystore.Keystores, txProposal *maketx.TxProposal, ...) error
- type Account
- func (account *Account) Balance() *transactions.Balance
- func (account *Account) Close()
- func (account *Account) Code() string
- func (account *Account) Coin() *Coin
- func (account *Account) ConvertToLegacyAddress(scriptHashHex blockchain.ScriptHashHex) (btcutil.Address, error)
- func (account *Account) FeeTargets() ([]*FeeTarget, FeeTargetCode)
- func (account *Account) GetUnusedReceiveAddresses() []*addresses.AccountAddress
- func (account *Account) HeadersStatus() (*headers.Status, error)
- func (account *Account) Init() error
- func (account *Account) InitialSyncDone() bool
- func (account *Account) Keystores() keystore.Keystores
- func (account *Account) MarshalJSON() ([]byte, error)
- func (account *Account) Offline() bool
- func (account *Account) SendTx(recipientAddress string, amount SendAmount, feeTargetCode FeeTargetCode, ...) error
- func (account *Account) SpendableOutputs() []*SpendableOutput
- func (account *Account) String() string
- func (account *Account) Transactions() []*transactions.TxInfo
- func (account *Account) TxProposal(recipientAddress string, amount SendAmount, feeTargetCode FeeTargetCode, ...) (btcutil.Amount, btcutil.Amount, btcutil.Amount, error)
- func (account *Account) VerifyAddress(scriptHashHex blockchain.ScriptHashHex) (bool, error)
- type Coin
- func (coin *Coin) Blockchain() blockchain.Interface
- func (coin *Coin) FormatAmount(amount int64) string
- func (coin *Coin) FormatAmountAsJSON(amount int64) coinpkg.FormattedAmount
- func (coin *Coin) Headers() *headers.Headers
- func (coin *Coin) Init()
- func (coin *Coin) Name() string
- func (coin *Coin) Net() *chaincfg.Params
- func (coin *Coin) RatesUpdater() coinpkg.RatesUpdater
- func (coin *Coin) String() string
- func (coin *Coin) Unit() string
- type Event
- type FeeTarget
- type FeeTargetCode
- type Interface
- type ProposedTransaction
- type RatesUpdater
- type SendAmount
- type SpendableOutput
- type Status
- type TxValidationError
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.
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 creats a new Account.
func (*Account) Balance ¶
func (account *Account) Balance() *transactions.Balance
Balance wraps transaction.Transactions.Balance()
func (*Account) ConvertToLegacyAddress ¶
func (account *Account) ConvertToLegacyAddress(scriptHashHex blockchain.ScriptHashHex) (btcutil.Address, error)
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 ¶
func (account *Account) GetUnusedReceiveAddresses() []*addresses.AccountAddress
GetUnusedReceiveAddresses returns a number of unused addresses.
func (*Account) HeadersStatus ¶
HeadersStatus returns the status of the headers.
func (*Account) InitialSyncDone ¶
InitialSyncDone indicates whether the account has loaded and finished the initial sync of the addresses.
func (*Account) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Account) SendTx ¶
func (account *Account) SendTx( recipientAddress string, amount SendAmount, feeTargetCode FeeTargetCode, selectedUTXOs map[wire.OutPoint]struct{}, ) 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() []*transactions.TxInfo
Transactions wraps transaction.Transactions.Transactions()
func (*Account) TxProposal ¶
func (account *Account) TxProposal( recipientAddress string, amount SendAmount, feeTargetCode FeeTargetCode, selectedUTXOs map[wire.OutPoint]struct{}, ) ( btcutil.Amount, btcutil.Amount, btcutil.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.
func (*Account) VerifyAddress ¶
func (account *Account) VerifyAddress(scriptHashHex blockchain.ScriptHashHex) (bool, error)
VerifyAddress verifies a receive address on a keystore. Returns false, nil if no secure output exists.
type Coin ¶
type Coin struct { observable.Implementation // contains filtered or unexported fields }
Coin models a Bitcoin-related coin.
func NewCoin ¶
func NewCoin( name string, unit string, net *chaincfg.Params, dbFolder string, servers []*rpc.ServerInfo, blockExplorerTxPrefix string, ratesUpdater coinpkg.RatesUpdater, ) *Coin
NewCoin creates a new coin with the given parameters.
func (*Coin) Blockchain ¶
func (coin *Coin) Blockchain() blockchain.Interface
Blockchain connects to a blockchain backend.
func (*Coin) FormatAmount ¶
FormatAmount implements coin.Coin.
func (*Coin) FormatAmountAsJSON ¶
func (coin *Coin) FormatAmountAsJSON(amount int64) coinpkg.FormattedAmount
FormatAmountAsJSON implements coin.Coin.
func (*Coin) RatesUpdater ¶
func (coin *Coin) RatesUpdater() coinpkg.RatesUpdater
RatesUpdater returns current exchange rates.
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, log *logrus.Entry) (FeeTargetCode, error)
NewFeeTargetCode checks if the code is valid and returns a FeeTargetCode in that case.
type Interface ¶
type Interface interface { Code() string Coin() *Coin Init() error InitialSyncDone() bool Offline() bool Close() Transactions() []*transactions.TxInfo Balance() *transactions.Balance SendTx(string, SendAmount, FeeTargetCode, map[wire.OutPoint]struct{}) error FeeTargets() ([]*FeeTarget, FeeTargetCode) TxProposal(string, SendAmount, FeeTargetCode, map[wire.OutPoint]struct{}) ( btcutil.Amount, btcutil.Amount, btcutil.Amount, error) GetUnusedReceiveAddresses() []*addresses.AccountAddress VerifyAddress(blockchain.ScriptHashHex) (bool, error) ConvertToLegacyAddress(blockchain.ScriptHashHex) (btcutil.Address, error) Keystores() keystore.Keystores HeadersStatus() (*headers.Status, error) 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 RatesUpdater ¶
type RatesUpdater struct { observable.Implementation // contains filtered or unexported fields }
RatesUpdater implements coin.RatesUpdater.
func NewRatesUpdater ¶
func NewRatesUpdater() *RatesUpdater
NewRatesUpdater returns a new rates updater.
type SendAmount ¶
type SendAmount struct {
// contains filtered or unexported fields
}
SendAmount is either a concrete amount, or "all"/"max".
func NewSendAmount ¶
func NewSendAmount(amount btcutil.Amount) (SendAmount, error)
NewSendAmount creates a new SendAmount based on a concrete amount.
func NewSendAmountAll ¶
func NewSendAmountAll() SendAmount
NewSendAmountAll creates a new Sendall-amount.
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" )
type TxValidationError ¶
type TxValidationError string
TxValidationError represents errors in the tx proposal input data.
func (TxValidationError) Error ¶
func (err TxValidationError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
mocks
Code generated by mockery v1.0.0.
|
Code generated by mockery v1.0.0. |
client
Package client implements an Electrum JSON RPC client.
|
Package client implements an Electrum JSON RPC client. |
mocks
Code generated by mockery v1.0.0.
|
Code generated by mockery v1.0.0. |
Package maketx provides transaction creation code for wallets.
|
Package maketx provides transaction creation code for wallets. |