Documentation ¶
Index ¶
- func CreateNewWallet(am account.Manager, mnemonic string) error
- func FeeCreditRecordIDFormPublicKey(shardPart, pubKey []byte) types.UnitID
- type DustCollectionResult
- type GetBalanceCmd
- type ReceiverData
- type RpcClient
- type SendCmd
- type TxPublisher
- 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) (*api.FeeCreditBill, error)
- func (w *Wallet) GetFeeCreditBill(ctx context.Context, unitID types.UnitID) (*api.FeeCreditBill, error)
- func (w *Wallet) GetRoundNumber(ctx context.Context) (uint64, 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 DustCollectionResult ¶
type DustCollectionResult struct { AccountIndex uint64 DustCollectionResult *dc.DustCollectionResult // NB! can be nil }
type GetBalanceCmd ¶
type ReceiverData ¶
type RpcClient ¶ added in v0.4.0
type RpcClient interface { GetRoundNumber(ctx context.Context) (uint64, error) GetBill(ctx context.Context, unitID types.UnitID, includeStateProof bool) (*api.Bill, error) GetFeeCreditRecord(ctx context.Context, unitID types.UnitID, includeStateProof bool) (*api.FeeCreditBill, error) GetUnitsByOwnerID(ctx context.Context, ownerID types.Bytes) ([]types.UnitID, error) SendTransaction(ctx context.Context, tx *types.TransactionOrder) ([]byte, error) GetTransactionProof(ctx context.Context, txHash types.Bytes) (*types.TransactionRecord, *types.TxProof, error) GetBlock(ctx context.Context, roundNumber uint64) (*types.Block, error) }
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(rpcClient RpcClient, log *slog.Logger) *TxPublisher
func (*TxPublisher) Close ¶
func (w *TxPublisher) Close()
type Wallet ¶
type Wallet struct { TxPublisher *TxPublisher // contains filtered or unexported fields }
func LoadExistingWallet ¶
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 the total value of all bills currently held in the wallet, for the given account, in Tema denomination. Does not count fee credit bills.
func (*Wallet) GetBalances ¶
GetBalances returns the total value of all bills currently held in the wallet, for all accounts, in Tema denomination. Does not count fee credit bills.
func (*Wallet) GetFeeCredit ¶
func (w *Wallet) GetFeeCredit(ctx context.Context, cmd fees.GetFeeCreditCmd) (*api.FeeCreditBill, error)
GetFeeCredit returns fee credit bill for given account, can return nil if fee credit bill has not been created yet.
func (*Wallet) GetFeeCreditBill ¶
func (w *Wallet) GetFeeCreditBill(ctx context.Context, unitID types.UnitID) (*api.FeeCreditBill, error)
GetFeeCreditBill returns fee credit bill for given unitID, returns nil if fee credit bill has not been created yet.
func (*Wallet) GetRoundNumber ¶
GetRoundNumber returns the latest round number in node.
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.