Documentation ¶
Index ¶
- func CreateNewWallet(am account.Manager, mnemonic string) error
- func FeeCreditRecordIDFormPublicKey(shardPart, pubKey []byte) types.UnitID
- type BackendAPI
- type DustCollectionResult
- type GetBalanceCmd
- type ReceiverData
- type SendCmd
- type TxPublisher
- type UnitLocker
- type Wallet
- func (w *Wallet) AddFeeCredit(ctx context.Context, cmd fees.AddFeeCmd) (*fees.AddFeeCmdResponse, error)
- func (w *Wallet) Close()
- func (w *Wallet) CollectDust(ctx context.Context, accountNumber uint64) ([]*DustCollectionResult, error)
- func (w *Wallet) GetAccountManager() account.Manager
- func (w *Wallet) GetBalance(ctx context.Context, cmd GetBalanceCmd) (uint64, error)
- func (w *Wallet) GetBalances(ctx context.Context, cmd GetBalanceCmd) ([]uint64, uint64, error)
- func (w *Wallet) GetFeeCredit(ctx context.Context, cmd fees.GetFeeCreditCmd) (*wallet.Bill, error)
- func (w *Wallet) GetFeeCreditBill(ctx context.Context, unitID types.UnitID) (*wallet.Bill, error)
- func (w *Wallet) GetRoundNumber(ctx context.Context) (*wallet.RoundNumber, error)
- func (w *Wallet) ReclaimFeeCredit(ctx context.Context, cmd fees.ReclaimFeeCmd) (*fees.ReclaimFeeCmdResponse, error)
- func (w *Wallet) Send(ctx context.Context, cmd SendCmd) ([]*wallet.Proof, error)
- func (w *Wallet) SendTx(ctx context.Context, tx *types.TransactionOrder, senderPubKey []byte) (*wallet.Proof, error)
- func (w *Wallet) SystemID() types.SystemID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNewWallet ¶
CreateNewWallet creates a new wallet. To synchronize wallet with a node call Sync. Shutdown needs to be called to release resources used by wallet. If mnemonic seed is empty then new mnemonic will ge generated, otherwise wallet is restored using given mnemonic.
Types ¶
type BackendAPI ¶
type BackendAPI interface { GetBalance(ctx context.Context, pubKey []byte, includeDCBills bool) (uint64, error) ListBills(ctx context.Context, pubKey []byte, includeDCBills bool, offsetKey string, limit int) (*backend.ListBillsResponse, error) GetBills(ctx context.Context, pubKey []byte) ([]*wallet.Bill, error) GetRoundNumber(ctx context.Context) (*wallet.RoundNumber, error) GetFeeCreditBill(ctx context.Context, unitID types.UnitID) (*wallet.Bill, error) PostTransactions(ctx context.Context, pubKey wallet.PubKey, txs *wallet.Transactions) error GetTxProof(ctx context.Context, unitID types.UnitID, txHash wallet.TxHash) (*wallet.Proof, error) }
type DustCollectionResult ¶
type DustCollectionResult struct { AccountIndex uint64 DustCollectionResult *dc.DustCollectionResult // NB! can be nil }
type GetBalanceCmd ¶
type ReceiverData ¶
type SendCmd ¶
type SendCmd struct { Receivers []ReceiverData WaitForConfirmation bool AccountIndex uint64 }
type TxPublisher ¶
type TxPublisher struct {
// contains filtered or unexported fields
}
func NewTxPublisher ¶
func NewTxPublisher(backend BackendAPI, log *slog.Logger) *TxPublisher
func (*TxPublisher) Close ¶
func (w *TxPublisher) Close()
type UnitLocker ¶
type UnitLocker interface { LockUnit(lockedBill *unitlock.LockedUnit) error UnlockUnit(accountID, unitID []byte) error GetUnit(accountID, unitID []byte) (*unitlock.LockedUnit, error) GetUnits(accountID []byte) ([]*unitlock.LockedUnit, error) Close() error }
type Wallet ¶
type Wallet struct { TxPublisher *TxPublisher // contains filtered or unexported fields }
func LoadExistingWallet ¶
func LoadExistingWallet(am account.Manager, unitLocker UnitLocker, feeManagerDB fees.FeeManagerDB, backend BackendAPI, log *slog.Logger) (*Wallet, error)
func (*Wallet) AddFeeCredit ¶
func (w *Wallet) AddFeeCredit(ctx context.Context, cmd fees.AddFeeCmd) (*fees.AddFeeCmdResponse, error)
AddFeeCredit creates fee credit for the given amount. Wallet must have a bill large enough for the required amount plus fees. Returns transferFC and addFC transaction proofs.
func (*Wallet) Close ¶
func (w *Wallet) Close()
Close terminates connection to alphabill node, closes account manager and cancels any background goroutines.
func (*Wallet) CollectDust ¶
func (w *Wallet) CollectDust(ctx context.Context, accountNumber uint64) ([]*DustCollectionResult, error)
CollectDust starts the dust collector process for the requested accounts in the wallet. Dust collection process joins up to N units into existing target unit, prioritizing small units first. The largest unit in wallet is selected as the target unit. If accountNumber is equal to 0 then dust collection is run for all accounts, returns list of swap tx proofs together with account numbers, the proof can be nil if swap tx was not sent e.g. if there's not enough bills to swap. If accountNumber is greater than 0 then dust collection is run only for the specific account, returns single swap tx proof, the proof can be nil e.g. if there's not enough bills to swap.
func (*Wallet) GetAccountManager ¶
func (*Wallet) GetBalance ¶
GetBalance returns sum value of all bills currently owned by the wallet, for given account. The value returned is the smallest denomination of alphabills.
func (*Wallet) GetBalances ¶
GetBalances returns sum value of all bills currently owned by the wallet, for all accounts. The value returned is the smallest denomination of alphabills.
func (*Wallet) GetFeeCredit ¶
GetFeeCredit returns fee credit bill for given account, can return nil if fee credit bill has not been created yet.
func (*Wallet) GetFeeCreditBill ¶
GetFeeCreditBill returns fee credit bill for given unitID can return nil if fee credit bill has not been created yet.
func (*Wallet) GetRoundNumber ¶
GetRoundNumber returns the latest round number in node and backend.
func (*Wallet) ReclaimFeeCredit ¶
func (w *Wallet) ReclaimFeeCredit(ctx context.Context, cmd fees.ReclaimFeeCmd) (*fees.ReclaimFeeCmdResponse, error)
ReclaimFeeCredit reclaims fee credit. Reclaimed fee credit is added to the largest bill in wallet. Returns closeFC and reclaimFC transaction proofs.
func (*Wallet) Send ¶
Send creates, signs and broadcasts transactions, in total for the given amount, to the given public key, the public key must be in compressed secp256k1 format. Sends one transaction per bill, prioritizing larger bills. Waits for initial response from the node, returns error if any transaction was not accepted to the mempool. Returns list of tx proofs, if waitForConfirmation=true, otherwise nil.