Documentation ¶
Index ¶
- Constants
- func AddAllUTXOs(ctx context.Context, utxos UTXOs, client UTXOClient, codec codec.Manager, ...) error
- type AXIAWallet
- func NewAXIAWallet(core core.AXIAWallet, swap swap.AXIAWallet) AXIAWallet
- func NewAXIAWalletFromURI(ctx context.Context, uri string, kc *secp256k1fx.Keychain) (AXIAWallet, error)
- func NewAXIAWalletWithOptions(w AXIAWallet, options ...common.Option) AXIAWallet
- func NewAXIAWalletWithState(uri string, pCTX core.Context, xCTX swap.Context, utxos UTXOs, ...) AXIAWallet
- type ChainUTXOs
- type UTXOClient
- type UTXOs
Examples ¶
Constants ¶
const ( MainnetAPIURI = "https://api.axc.network" TestAPIURI = "https://api.axc-test.network" LocalAPIURI = "http://localhost:9650" )
Variables ¶
This section is empty.
Functions ¶
func AddAllUTXOs ¶
func AddAllUTXOs( ctx context.Context, utxos 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.
Types ¶
type AXIAWallet ¶
type AXIAWallet interface { Core() core.AXIAWallet Swap() swap.AXIAWallet }
AXIAWallet provides chain axiawallets for the primary network.
Example ¶
ctx := context.Background() kc := secp256k1fx.NewKeychain(genesis.EWOQKey) // NewAXIAWalletFromURI fetches the available UTXOs owned by [kc] on the network // that [LocalAPIURI] is hosting. axiawalletSyncStartTime := time.Now() axiawallet, err := NewAXIAWalletFromURI(ctx, LocalAPIURI, kc) if err != nil { fmt.Printf("failed to initialize axiawallet with: %s\n", err) return } fmt.Printf("synced axiawallet in %s\n", time.Since(axiawalletSyncStartTime)) // Get the Corechain and the Swapchain axiawallets pAXIAWallet := axiawallet.Core() xAXIAWallet := axiawallet.Swap() // Pull out useful constants to use when issuing transactions. swapChainID := xAXIAWallet.BlockchainID() axcAssetID := xAXIAWallet.AXCAssetID() owner := &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{ genesis.EWOQKey.PublicKey().Address(), }, } // Send 100 schmeckles to the Corechain. exportStartTime := time.Now() exportTxID, err := xAXIAWallet.IssueExportTx( constants.CoreChainID, []*axc.TransferableOutput{ { Asset: axc.Asset{ ID: axcAssetID, }, Out: &secp256k1fx.TransferOutput{ Amt: 100 * units.Schmeckle, OutputOwners: *owner, }, }, }, ) if err != nil { fmt.Printf("failed to issue X->P export transaction with: %s\n", err) return } fmt.Printf("issued X->P export %s in %s\n", exportTxID, time.Since(exportStartTime)) // Import the 100 schmeckles from the Swapchain into the Corechain. importStartTime := time.Now() importTxID, err := pAXIAWallet.IssueImportTx(swapChainID, owner) if err != nil { fmt.Printf("failed to issue X->P import transaction with: %s\n", err) return } fmt.Printf("issued X->P import %s in %s\n", importTxID, time.Since(importStartTime))
Output:
func NewAXIAWallet ¶
func NewAXIAWallet(core core.AXIAWallet, swap swap.AXIAWallet) AXIAWallet
func NewAXIAWalletFromURI ¶
func NewAXIAWalletFromURI(ctx context.Context, uri string, kc *secp256k1fx.Keychain) (AXIAWallet, error)
NewAXIAWalletFromURI returns a axiawallet that supports issuing transactions to the chains living in the primary network to a provided [uri].
On creation, the axiawallet attaches to the provided [uri] and fetches all UTXOs that reference any of the keys contained in [kc]. If the UTXOs are modified through an external issuance process, such as another instance of the axiawallet, the UTXOs may become out of sync.
The axiawallet manages all UTXOs locally, and performs all tx signing locally.
func NewAXIAWalletWithOptions ¶
func NewAXIAWalletWithOptions(w AXIAWallet, options ...common.Option) AXIAWallet
func NewAXIAWalletWithState ¶
func NewAXIAWalletWithState( uri string, pCTX core.Context, xCTX swap.Context, utxos UTXOs, kc *secp256k1fx.Keychain, ) AXIAWallet
type ChainUTXOs ¶
type ChainUTXOs interface { AddUTXO(ctx context.Context, destinationChainID ids.ID, utxo *axc.UTXO) error RemoveUTXO(ctx context.Context, sourceChainID, utxoID ids.ID) error UTXOs(ctx context.Context, sourceChainID ids.ID) ([]*axc.UTXO, error) GetUTXO(ctx context.Context, sourceChainID, utxoID ids.ID) (*axc.UTXO, error) }
func NewChainUTXOs ¶
func NewChainUTXOs(chainID ids.ID, utxos UTXOs) ChainUTXOs
type UTXOClient ¶
type UTXOs ¶
type UTXOs interface { AddUTXO(ctx context.Context, sourceChainID, destinationChainID ids.ID, utxo *axc.UTXO) error RemoveUTXO(ctx context.Context, sourceChainID, destinationChainID, utxoID ids.ID) error UTXOs(ctx context.Context, sourceChainID, destinationChainID ids.ID) ([]*axc.UTXO, error) GetUTXO(ctx context.Context, sourceChainID, destinationChainID, utxoID ids.ID) (*axc.UTXO, error) }