wallet

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2023 License: AGPL-3.0, ISC Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWalletAlreadySynchronizing = errors.New("wallet is already synchronizing")
	ErrFailedToBroadcastTx        = errors.New("failed to broadcast transaction")
	ErrTxRetryCanceled            = errors.New("user canceled tx retry")
)

Functions

func NewDerivationPath added in v0.1.1

func NewDerivationPath(accountIndex uint64) string

NewDerivationPath returns derivation path for given account index

func VerifyP2PKHOwner added in v0.1.1

func VerifyP2PKHOwner(pubkeyHashes *KeyHashes, bp []byte) bool

VerifyP2PKHOwner checks if given bearer predicate equals either SHA256 or SHA512 P2PKH predicate.

Types

type AccountKey

type AccountKey struct {
	PubKey         []byte     `json:"pubKey"` // compressed secp256k1 key 33 bytes
	PrivKey        []byte     `json:"privKey"`
	PubKeyHash     *KeyHashes `json:"pubKeyHash"`
	DerivationPath []byte     `json:"derivationPath"`
}

func NewAccountKey

func NewAccountKey(masterKey *hdkeychain.ExtendedKey, derivationPath string) (*AccountKey, error)

NewAccountKey generates new account key from given master key and derivation path

type AccountManager added in v0.1.1

type AccountManager interface {
	GetAccountKey(accountIndex uint64) (*AccountKey, error)
}

type BlockProcessor

type BlockProcessor interface {

	// ProcessBlock signals given block to be processesed
	// any error returned here signals block processor to terminate,
	ProcessBlock(b *block.Block) error
}

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func New

func New() *Builder

func (*Builder) Build

func (b *Builder) Build() *Wallet

func (*Builder) SetABClient

func (b *Builder) SetABClient(abc client.ABClient) *Builder

func (*Builder) SetABClientConf

func (b *Builder) SetABClientConf(abcConf client.AlphabillClientConfig) *Builder

func (*Builder) SetBlockProcessor

func (b *Builder) SetBlockProcessor(bp BlockProcessor) *Builder

type Config

type Config struct {
	// Configuration options for connecting to alphabill nodes.
	AlphabillClientConfig client.AlphabillClientConfig
}

Config configuration options for creating and loading a wallet.

type KeyHashes

type KeyHashes struct {
	Sha256 []byte `json:"sha256"`
	Sha512 []byte `json:"sha512"`
}

func NewKeyHash added in v0.1.1

func NewKeyHash(key []byte) *KeyHashes

NewKeyHash creates sha256/sha512 hash pair from given key

type Keys

type Keys struct {
	Mnemonic   string
	MasterKey  *hdkeychain.ExtendedKey
	AccountKey *AccountKey
}

func NewKeys

func NewKeys(mnemonic string) (*Keys, error)

NewKeys generates new wallet keys from given mnemonic seed, or generates mnemonic first if empty string is provided

type SendOpts added in v0.1.1

type SendOpts struct {
	// RetryOnFullTxBuffer retries to send transaction when tx buffer is full
	RetryOnFullTxBuffer bool
}

type Wallet

type Wallet struct {
	BlockProcessor BlockProcessor

	AlphabillClient client.ABClient
	// contains filtered or unexported fields
}

Wallet To synchronize wallet with a node call Sync. Shutdown needs to be called to release resources used by wallet.

func (*Wallet) GetMaxBlockNumber

func (w *Wallet) GetMaxBlockNumber() (uint64, error)

GetMaxBlockNumber queries the node for latest block number

func (*Wallet) SendTransaction

func (w *Wallet) SendTransaction(ctx context.Context, tx *txsystem.Transaction, opts *SendOpts) error

SendTransaction broadcasts transaction to configured node. Returns nil if transaction was successfully accepted by node, otherwise returns error.

func (*Wallet) Shutdown

func (w *Wallet) Shutdown()

Shutdown terminates connection to alphabill node and cancels any background goroutines.

func (*Wallet) Sync

func (w *Wallet) Sync(ctx context.Context, lastBlockNumber uint64) error

Sync synchronises wallet from the last known block number with the given alphabill node. The function blocks forever or until alphabill connection is terminated. Returns error if wallet is already synchronizing or any error occured during syncrohronization, otherwise returns nil.

func (*Wallet) SyncToMaxBlockNumber

func (w *Wallet) SyncToMaxBlockNumber(ctx context.Context, lastBlockNumber uint64) error

SyncToMaxBlockNumber synchronises wallet from the last known block number with the given alphabill node. The function blocks until maximum block height, calculated at the start of the process, is reached. Returns error if wallet is already synchronizing or any error occured during syncrohronization, otherwise returns nil.

Directories

Path Synopsis
Package log implements a logger interface that is used for logging inside Alphabill Wallet SDK.
Package log implements a logger interface that is used for logging inside Alphabill Wallet SDK.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL