avmwallet

package
v0.0.0-...-198cc34 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	AssetID      ids.ID
	Name         string
	Symbol       string
	Denomination uint8
}

type Keychain

type Keychain struct {
	Addrs ids.ShortSet
}

Keychain is a collection of multisig public keys that can be used to spend outputs TODO see MPS DeriveBIP32, derives a sharing of the ith child of the consortium signing key. TODO what about asset IDs? Should handling of those be in this struct?

func NewKeychain

func NewKeychain() *Keychain

NewKeychain returns a new, empty, keychain

func (*Keychain) Add

func (kc *Keychain) Add(key *crypto.PublicKeySECP256K1R)

Add a new key to the key chain

func (*Keychain) Match

func (kc *Keychain) Match(owners *secp256k1fx.OutputOwners, time uint64) bool

Match only outputs that have one owner (the multi sig key)

func (*Keychain) Spend

func (kc *Keychain) Spend(out verify.Verifiable, time uint64) (verify.Verifiable, error)

Spend attempts to create an input from an output

type UTXOSet

type UTXOSet struct {

	// List of UTXOs in this set
	// This can be used to iterate over. It should not be modified externally.
	UTXOs []*avax.UTXO
	// contains filtered or unexported fields
}

func (*UTXOSet) Get

func (us *UTXOSet) Get(id ids.ID) *avax.UTXO

func (*UTXOSet) PrefixedString

func (us *UTXOSet) PrefixedString(prefix string) string

PrefixedString returns a string with each new line prefixed with [prefix]

func (*UTXOSet) Put

func (us *UTXOSet) Put(utxo *avax.UTXO)

func (*UTXOSet) Remove

func (us *UTXOSet) Remove(id ids.ID) *avax.UTXO

func (*UTXOSet) Sorted

func (us *UTXOSet) Sorted() []*avax.UTXO

Return UTXOs sorted smallest to largest amounts. This is so new txs will spend dust first.

func (*UTXOSet) String

func (us *UTXOSet) String() string

type Wallet

type Wallet struct {
	// User-supplied name for this wallet
	Name      string
	Threshold int
	Me        user.User
	Others    []user.User

	// Raw config.Config struct we get from the MPS Keygen protocol
	// This is a SECRET so figure out best way to protect it
	KeyData []byte
	// Public address computed from the MPS config and stored here so it shows up in the persisted JSON for reference
	Address string
	// Config params for a blockchain, i.e. Avax Fuji, etc
	Config constants.AvmConfig

	CreatedAt time.Time
	// contains filtered or unexported fields
}

Wallet is a holder for keys and UTXOs for the blockchain. For now we use just one pub/priv key, maybe use BIP32 to enhance privacy?

func New

func New() *Wallet

func NewEmptyWallet

func NewEmptyWallet(network string, name string, threshold int, me user.User, others []user.User) *Wallet

NewWallet returns a new Avalanche Wallet

func (*Wallet) AllPartyIDs

func (w *Wallet) AllPartyIDs() party.IDSlice

All signers as partyIDs (required by the MSP library)

func (*Wallet) AllPartyNicks

func (w *Wallet) AllPartyNicks() []string

All signers as an array of string nicknames

func (*Wallet) Balance

func (w *Wallet) Balance(assetID ids.ID) uint64

Balance returns the amount of the assets in this wallet

func (*Wallet) BalanceForDisplay

func (w *Wallet) BalanceForDisplay(assetID ids.ID) string

Balance returns the amount of the assets in this wallet in units of AVAX

func (*Wallet) Codec

func (w *Wallet) Codec() codec.Manager

Codec returns the codec used for serialization

func (*Wallet) ConfirmTx

func (w *Wallet) ConfirmTx(txID ids.ID) bool

Blocks until confirmed, 3 attempts with 3 second delay

func (*Wallet) CreateTx

func (w *Wallet) CreateTx(assetID ids.ID, amount uint64, destAddr ids.ShortID, memo string) (*avm.Tx, error)

CreateTx returns a tx that sends [amount] of [assetID] to [destAddr] TODO this only works for avax, make it work for any asset id

func (*Wallet) DumpUTXOs

func (w *Wallet) DumpUTXOs() string

Dump all UTXOs to a formatted string for inspection

func (*Wallet) FetchUTXOs

func (w *Wallet) FetchUTXOs() error

Query the network for UTXOs Run in a Go routine, as well as called directly

func (*Wallet) FormatAmount

func (w *Wallet) FormatAmount(asset Asset, amt uint64) string

func (*Wallet) FormatAssetID

func (w *Wallet) FormatAssetID(assetID ids.ID) string

Return asset info

func (*Wallet) FormatIssueTxAsCurl

func (w *Wallet) FormatIssueTxAsCurl(tx string) string

func (*Wallet) FormatTxURL

func (w *Wallet) FormatTxURL(txID ids.ID) string

func (*Wallet) GetAsset

func (w *Wallet) GetAsset(assetID ids.ID) Asset

func (*Wallet) GetBalances

func (w *Wallet) GetBalances() map[ids.ID]uint64

func (*Wallet) GetFormattedAddress

func (w *Wallet) GetFormattedAddress() string

The string form of an Avalanche address (X-fuji1blahblah...)

func (*Wallet) GetName

func (w *Wallet) GetName() string

func (*Wallet) GetUnsignedBytes

func (w *Wallet) GetUnsignedBytes(source interface{}) ([]byte, error)

func (*Wallet) GetUnwrappedKeyData

func (w *Wallet) GetUnwrappedKeyData() mpsconfig.Config

Unmarshal the MPS config which contains the key data

func (*Wallet) Initialize

func (w *Wallet) Initialize(keydata []byte)

func (*Wallet) IsFetching

func (w *Wallet) IsFetching() bool

Is the wallet querying the network for UTXOs

func (*Wallet) IssueTx

func (w *Wallet) IssueTx(txBytes []byte) (ids.ID, error)

func (*Wallet) Marshal

func (w *Wallet) Marshal(source interface{}) (destination []byte, err error)

func (*Wallet) MpsSigToAvaSig

func (w *Wallet) MpsSigToAvaSig(hashedmsg []byte, mpssig *mpsecdsa.Signature) ([]byte, error)

Convert the signature generated by the MPS protocol into an Avalance recoverable signature

func (*Wallet) OtherPartyIDs

func (w *Wallet) OtherPartyIDs() party.IDSlice

All signers excluding me

func (*Wallet) PublicKeyAvm

func (w *Wallet) PublicKeyAvm() avacrypto.PublicKey

From the MSP key data, convert to an Avalanche public key

func (*Wallet) PublicKeyMpsPoint

func (w *Wallet) PublicKeyMpsPoint() curve.Point

func (*Wallet) SetName

func (w *Wallet) SetName(name string)

func (*Wallet) Unmarshal

func (w *Wallet) Unmarshal(source []byte) (destination interface{}, err error)

func (*Wallet) UnmarshalJSON

func (w *Wallet) UnmarshalJSON(data []byte) error

Do the funky chicken to unmarshal then init the struct TODO is this really best way init an unmarshaled struct?

func (*Wallet) VerifyHash

func (w *Wallet) VerifyHash(hashedmsg []byte, mpssig *mpsecdsa.Signature) bool

Jump to

Keyboard shortcuts

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