mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
Route registration, client URL builders, and log lines all move to /v1/ (wallet primary api, chains/rpc handler_manager+chain_integration, xvm client+wallet_client, xsvm api client, multi-network example, manager logs). Zero /ext/ literals remain. One endpoint namespace, no transition alias. Co-authored-by: Hanzo Dev <dev@hanzo.ai>
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package xvm
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/luxfi/constants"
|
|
"github.com/luxfi/formatting"
|
|
"github.com/luxfi/ids"
|
|
apitypes "github.com/luxfi/api/types"
|
|
"github.com/luxfi/rpc"
|
|
)
|
|
|
|
// WalletClient for interacting with exchangevm managed wallet.
|
|
//
|
|
// Deprecated: Transactions should be issued using the
|
|
// `luxfi/node/wallet/chain/x.Wallet` utility.
|
|
type WalletClient struct {
|
|
Requester rpc.EndpointRequester
|
|
}
|
|
|
|
// NewWalletClient returns an Exchange VM wallet client for interacting with
|
|
// exchangevm managed wallet
|
|
//
|
|
// Deprecated: Transactions should be issued using the
|
|
// `luxfi/node/wallet/chain/x.Wallet` utility.
|
|
func NewWalletClient(uri, chain string) *WalletClient {
|
|
path := fmt.Sprintf(
|
|
"%s/v1/%s/%s/wallet",
|
|
uri,
|
|
constants.ChainAliasPrefix,
|
|
chain,
|
|
)
|
|
return &WalletClient{
|
|
Requester: rpc.NewEndpointRequester(path),
|
|
}
|
|
}
|
|
|
|
// IssueTx issues a transaction to a node and returns the TxID
|
|
func (c *WalletClient) IssueTx(ctx context.Context, txBytes []byte, options ...rpc.Option) (ids.ID, error) {
|
|
txStr, err := formatting.Encode(formatting.Hex, txBytes)
|
|
if err != nil {
|
|
return ids.Empty, err
|
|
}
|
|
res := &apitypes.JSONTxID{}
|
|
err = c.Requester.SendRequest(ctx, "wallet.issueTx", &apitypes.FormattedTx{
|
|
Tx: txStr,
|
|
Encoding: formatting.Hex,
|
|
}, res, options...)
|
|
return res.TxID, err
|
|
}
|