Documentation
¶
Overview ¶
Package primary provides primary network wallet operations.
Index ¶
Constants ¶
const ( MainnetAPIURI = "https://api.lux.network" TestnetAPIURI = "https://api.lux-test.network" LocalAPIURI = "http://localhost:9630" )
Variables ¶
This section is empty.
Functions ¶
func AddAllUTXOs ¶
func AddAllUTXOs( ctx context.Context, utxos walletcommon.UTXOs, client UTXOClient, codec codec.Manager, sourceChainID ids.ID, destinationChainID ids.ID, addrs []ids.ShortID, ) error
AddAllUTXOs fetches all the UTXOs referenced by [addresses] that were sent from [sourceChainID] to [destinationChainID] from the [client]. It then uses codec to parse the returned UTXOs and it adds them into [utxos]. If [ctx] expires, then the returned error will be immediately reported.
func NewChainUTXOs ¶
func NewChainUTXOs(chainID ids.ID, utxos UTXOs) common.ChainUTXOs
Types ¶
type KeychainAdapter ¶
type KeychainAdapter struct {
*secp256k1fx.Keychain
}
KeychainAdapter adapts secp256k1fx.Keychain to wallet/keychain.Keychain and c.EthKeychain interfaces. This allows secp256k1fx.Keychain to be used with MakeWallet.
func NewKeychainAdapter ¶
func NewKeychainAdapter(kc *secp256k1fx.Keychain) *KeychainAdapter
NewKeychainAdapter creates a KeychainAdapter from a secp256k1fx.Keychain
func (*KeychainAdapter) Addresses ¶
func (kc *KeychainAdapter) Addresses() set.Set[ids.ShortID]
Addresses implements wallet/keychain.Keychain
func (*KeychainAdapter) EthAddresses ¶
func (kc *KeychainAdapter) EthAddresses() set.Set[gethcommon.Address]
EthAddresses implements c.EthKeychain
func (*KeychainAdapter) Get ¶
Get implements wallet/keychain.Keychain (returns wallet/keychain.Signer, not utils/crypto/keychain.Signer)
func (*KeychainAdapter) GetEth ¶
func (kc *KeychainAdapter) GetEth(addr gethcommon.Address) (keychain.Signer, bool)
GetEth implements c.EthKeychain
type LUXState ¶
type LUXState struct {
PClient *platformvm.Client
PCTX *pbuilder.Context
XClient *XClient
XCTX *xbuilder.Context
// CClient *ethclient.Client // Not yet implemented
// CCTX *c.Context // Not yet implemented
UTXOs walletcommon.UTXOs
}
type UTXOClient ¶
type UTXOs ¶
type UTXOs interface {
AddUTXO(ctx context.Context, sourceChainID, destinationChainID ids.ID, utxo *lux.UTXO) error
RemoveUTXO(ctx context.Context, sourceChainID, destinationChainID, utxoID ids.ID) error
UTXOs(ctx context.Context, sourceChainID, destinationChainID ids.ID) ([]*lux.UTXO, error)
GetUTXO(ctx context.Context, sourceChainID, destinationChainID, utxoID ids.ID) (*lux.UTXO, error)
}
type Wallet ¶
Wallet provides chain wallets for the primary network.
func MakePChainWallet ¶
func MakePChainWallet(ctx context.Context, config *WalletConfig) (Wallet, error)
MakePChainWallet returns a wallet that only supports issuing P-chain transactions. This is an alias for MakeWallet for backward compatibility.
func MakeWallet ¶
func MakeWallet(ctx context.Context, config *WalletConfig) (Wallet, error)
MakeWallet returns a wallet that supports issuing transactions to the chains living in the primary network.
On creation, the wallet attaches to the provided uri and fetches all UTXOs that reference any of the provided keys. If the UTXOs are modified through an external issuance process, such as another instance of the wallet, the UTXOs may become out of sync. The wallet will also fetch all requested P-chain transactions.
The wallet manages all state locally, and performs all tx signing locally.
type WalletConfig ¶
type WalletConfig struct {
// Base URI to use for all node requests.
URI string // required
// Keys to use for signing all transactions.
LUXKeychain keychain.Keychain // required
EthKeychain c.EthKeychain // required
// Set of P-chain transactions that the wallet should know about to be able
// to generate transactions.
PChainTxs map[ids.ID]*txs.Tx // optional
// Set of P-chain transactions that the wallet should fetch to be able to
// generate transactions.
PChainTxsToFetch set.Set[ids.ID] // optional
}
type XClient ¶
type XClient struct {
// contains filtered or unexported fields
}
XClient is a client for interacting with the X-Chain
func NewXClient ¶
NewXClient returns a new X-Chain client
func NewXClientWithContext ¶
NewXClientWithContext returns a new X-Chain client with context information required for proper address formatting and UTXO queries
func (*XClient) GetAtomicUTXOs ¶
func (c *XClient) GetAtomicUTXOs( ctx context.Context, addrs []ids.ShortID, sourceChain string, limit uint32, startAddress ids.ShortID, startUTXOID ids.ID, options ...rpc.Option, ) ([][]byte, ids.ShortID, ids.ID, error)
GetAtomicUTXOs implements UTXOClient. Queries the X-chain for UTXOs controlled by the given addresses.