ubiquitytx

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrivateKeyECDSA added in v1.10.0

func GetPrivateKeyECDSA(e EVMTransaction) (*ecdsa.PrivateKey, error)

GetPrivateKeyEDCSA retrieves the private key from EVMTransaction

func SignAvalancheTransaction added in v1.10.0

func SignAvalancheTransaction(unsignedHexTx string, network string, privKey *ecdsa.PrivateKey) (txHash string, signedTx []byte, err error)

SignAvalancheTransaction signs an unsigned hex encoded transaction for the desired 'network'. This function signs a post London hard fork transaction, als referred to as an EIP1559 transaction.

func SignEVMTransactionWithSigner added in v1.7.0

func SignEVMTransactionWithSigner(unsignedHexTx string, privKey *ecdsa.PrivateKey, signer types.Signer) (txHash string, signedTx []byte, err error)

SignEVMTransactionWithSigner signs an unsigned hex transaction using the provided private key and signer This will work for all Ethereum Virtual Machine (EVM) compliant blockchains, including Ethereum and Polygon This function allows more control. For higher level functions use 'SignEthereumTransaction' and 'SignPolygonTransaction'

func SignEthereumLegacyTransaction added in v1.7.0

func SignEthereumLegacyTransaction(unsignedHexTx string, network string, privKey *ecdsa.PrivateKey) (txHash string, signedTx []byte, err error)

SignEthereumLegacyTransaction signs an unsigned hex encoded transaction for the desired 'network'. This function signs a legacy transaction, these are transactions commonly used before the London hard fork

func SignEthereumTransaction added in v1.7.0

func SignEthereumTransaction(unsignedHexTx string, network string, privKey *ecdsa.PrivateKey) (txHash string, signedTx []byte, err error)

SignEthereumTransaction signs an unsigned hex encoded transaction for the desired 'network'. This function signs a post London hard fork transaction, als referred to as an EIP1559 transaction.

func SignFantomTransaction added in v1.10.0

func SignFantomTransaction(unsignedHexTx string, network string, privKey *ecdsa.PrivateKey) (txHash string, signedTx []byte, err error)

SignFantomTransaction signs an unsigned hex encoded transaction for the desired 'network'. This function signs a post London hard fork transaction, als referred to as an EIP1559 transaction.

func SignPolkadotTransaction added in v1.3.0

func SignPolkadotTransaction(seedPhrase, rawTx, rawSigningPayload string, network PolkadotNetwork) (string, error)

func SignPolygonTransaction added in v1.7.0

func SignPolygonTransaction(unsignedHexTx string, network string, privKey *ecdsa.PrivateKey) (txHash string, signedTx []byte, err error)

SignPolygonTransaction signs an unsigned hex encoded transaction for the desired 'network'. This function signs a post London hard fork transaction, als referred to as an EIP1559 transaction.

func SignSolanaTransaction added in v1.4.0

func SignSolanaTransaction(unsignedRawTx string, privateKey solana.PrivateKey) (signedRawTx string, err error)

func ValidateEVMTransaction added in v1.10.0

func ValidateEVMTransaction(e EVMTransaction) error

Types

type AvalancheTransaction added in v1.10.0

type AvalancheTransaction struct {
	Network              string
	PrivateKey           string
	To                   string
	Amount               *big.Float // In Avax
	Nonce                *int64     // Current transaction count
	MaxPriorityFeePerGas *big.Int
	MaxFeePerGas         *big.Int
	Gas                  *big.Int

	// FeeEstimation can be used to indicate whether the Ubiquity
	// /tx/estimate_fee API should be used.
	// When MaxPriorityFeePerGas or MaxFeePerGas is set or when
	// this is set to UbiquityFeeEstimationNone (the default)
	// the fee estimation API is not used.
	FeeEstimation FeeEstimationType
}

Represents an Avalanche Transaction and implements the EVMTransaction interface

func (AvalancheTransaction) GetAmount added in v1.10.0

func (f AvalancheTransaction) GetAmount() *big.Float

func (AvalancheTransaction) GetFeeEstimationType added in v1.10.0

func (f AvalancheTransaction) GetFeeEstimationType() FeeEstimationType

func (AvalancheTransaction) GetGas added in v1.10.0

func (f AvalancheTransaction) GetGas() *big.Int

func (AvalancheTransaction) GetMaxFeePerGas added in v1.10.0

func (f AvalancheTransaction) GetMaxFeePerGas() *big.Int

func (AvalancheTransaction) GetMaxPriorityFeePerGas added in v1.10.0

func (f AvalancheTransaction) GetMaxPriorityFeePerGas() *big.Int

func (AvalancheTransaction) GetNetwork added in v1.10.0

func (f AvalancheTransaction) GetNetwork() string

func (AvalancheTransaction) GetNonce added in v1.10.0

func (f AvalancheTransaction) GetNonce() *int64

func (AvalancheTransaction) GetPrivateKey added in v1.10.0

func (f AvalancheTransaction) GetPrivateKey() string

func (AvalancheTransaction) GetProtocol added in v1.10.0

func (f AvalancheTransaction) GetProtocol() string

func (AvalancheTransaction) GetRecipient added in v1.10.0

func (f AvalancheTransaction) GetRecipient() string

func (AvalancheTransaction) SetTxProtocolParams added in v1.10.0

type BitcoinTransaction

type BitcoinTransaction struct {
	Network string
	From    []TxInput
	To      []TxOutput
	// Fee        int64
	// ChangeAddr string
	PrivateKey string
}

BitcoinTransaction *Important* make sure to properly calculate the difference between INs and OUTs since it will be automatically payed as a Fee. In the future we may include UTXO and Fee calculation into the service.

type EVMTransaction added in v1.10.0

type EVMTransaction interface {
	GetProtocol() string
	GetNetwork() string
	GetPrivateKey() string
	GetRecipient() string
	GetAmount() *big.Float
	GetNonce() *int64
	GetMaxPriorityFeePerGas() *big.Int
	GetMaxFeePerGas() *big.Int
	GetGas() *big.Int
	GetFeeEstimationType() FeeEstimationType

	SetTxProtocolParams(i *ubiquity.TxCreateEvm) *ubiquity.TxCreateProtocol
}

EVMTransaction is a generic interface to reflect a Ethereum Virtual Machine compatbile transaction. All specific transaction types for EVM based chains implement this interface.

type EthereumTransaction

type EthereumTransaction struct {
	Network              string
	PrivateKey           string
	To                   string
	Amount               *big.Float // In Eth
	Nonce                *int64     // Current transaction count
	Gas                  *big.Int
	MaxPriorityFeePerGas *big.Int
	MaxFeePerGas         *big.Int

	// FeeEstimation can be used to indicate whether the Ubiquity
	// /tx/estimate_fee API should be used. Be default uses the
	// medium category.
	// When MaxPriorityFeePerGas or MaxFeePerGas is set
	// the fee estimation API is not used.
	FeeEstimation *FeeEstimationType
}

func (EthereumTransaction) GetAmount added in v1.10.0

func (f EthereumTransaction) GetAmount() *big.Float

func (EthereumTransaction) GetFeeEstimationType added in v1.10.0

func (f EthereumTransaction) GetFeeEstimationType() FeeEstimationType

func (EthereumTransaction) GetGas added in v1.10.0

func (f EthereumTransaction) GetGas() *big.Int

func (EthereumTransaction) GetMaxFeePerGas added in v1.10.0

func (f EthereumTransaction) GetMaxFeePerGas() *big.Int

func (EthereumTransaction) GetMaxPriorityFeePerGas added in v1.10.0

func (f EthereumTransaction) GetMaxPriorityFeePerGas() *big.Int

func (EthereumTransaction) GetNetwork added in v1.10.0

func (f EthereumTransaction) GetNetwork() string

func (EthereumTransaction) GetNonce added in v1.10.0

func (f EthereumTransaction) GetNonce() *int64

func (EthereumTransaction) GetPrivateKey added in v1.10.0

func (f EthereumTransaction) GetPrivateKey() string

func (EthereumTransaction) GetProtocol added in v1.10.0

func (f EthereumTransaction) GetProtocol() string

func (EthereumTransaction) GetRecipient added in v1.10.0

func (f EthereumTransaction) GetRecipient() string

func (EthereumTransaction) SetTxProtocolParams added in v1.10.0

type FantomTransaction added in v1.10.0

type FantomTransaction struct {
	Network              string
	PrivateKey           string
	To                   string
	Amount               *big.Float // In FTM
	Nonce                *int64     // Current transaction count
	MaxPriorityFeePerGas *big.Int
	MaxFeePerGas         *big.Int
	Gas                  *big.Int

	// FeeEstimation can be used to indicate whether the Ubiquity
	// /tx/estimate_fee API should be used.
	// When MaxPriorityFeePerGas or MaxFeePerGas is set or when
	// this is set to UbiquityFeeEstimationNone (the default)
	// the fee estimation API is not used.
	FeeEstimation FeeEstimationType
}

func (FantomTransaction) GetAmount added in v1.10.0

func (f FantomTransaction) GetAmount() *big.Float

func (FantomTransaction) GetFeeEstimationType added in v1.10.0

func (f FantomTransaction) GetFeeEstimationType() FeeEstimationType

func (FantomTransaction) GetGas added in v1.10.0

func (f FantomTransaction) GetGas() *big.Int

func (FantomTransaction) GetMaxFeePerGas added in v1.10.0

func (f FantomTransaction) GetMaxFeePerGas() *big.Int

func (FantomTransaction) GetMaxPriorityFeePerGas added in v1.10.0

func (f FantomTransaction) GetMaxPriorityFeePerGas() *big.Int

func (FantomTransaction) GetNetwork added in v1.10.0

func (f FantomTransaction) GetNetwork() string

func (FantomTransaction) GetNonce added in v1.10.0

func (f FantomTransaction) GetNonce() *int64

func (FantomTransaction) GetPrivateKey added in v1.10.0

func (f FantomTransaction) GetPrivateKey() string

func (FantomTransaction) GetProtocol added in v1.10.0

func (f FantomTransaction) GetProtocol() string

func (FantomTransaction) GetRecipient added in v1.10.0

func (f FantomTransaction) GetRecipient() string

func (FantomTransaction) SetTxProtocolParams added in v1.10.0

func (f FantomTransaction) SetTxProtocolParams(i *ubiquity.TxCreateEvm) *ubiquity.TxCreateProtocol

type FeeEstimationType added in v1.10.0

type FeeEstimationType uint8
const (
	UbiquityFeeEstimationNone FeeEstimationType = iota
	UbiquityFeeEstimationSlow
	UbiquityFeeEstimationMedium
	UbiquityFeeEstimationFast
)

type PolkadotNetwork added in v1.3.0

type PolkadotNetwork uint8
const (
	PolkadotMainnet PolkadotNetwork = 0
	PolkadotWestend PolkadotNetwork = 42
)

type PolkadotTransaction added in v1.3.0

type PolkadotTransaction struct {
	Network    string
	To         string
	Amount     *big.Int
	Tip        uint64
	SeedPhrase string
}

type PolygonTransaction added in v1.7.0

type PolygonTransaction struct {
	Network              string
	PrivateKey           string
	To                   string
	Amount               *big.Float // In Matic
	Nonce                *int64     // Current transaction count
	MaxPriorityFeePerGas *big.Int
	MaxFeePerGas         *big.Int
	Gas                  *big.Int

	// FeeEstimation can be used to indicate whether the Ubiquity
	// /tx/estimate_fee API should be used.
	// When MaxPriorityFeePerGas or MaxFeePerGas is set or when
	// this is set to UbiquityFeeEstimationNone (the default)
	// the fee estimation API is not used.
	FeeEstimation FeeEstimationType
}

func (PolygonTransaction) GetAmount added in v1.10.0

func (f PolygonTransaction) GetAmount() *big.Float

func (PolygonTransaction) GetFeeEstimationType added in v1.10.0

func (f PolygonTransaction) GetFeeEstimationType() FeeEstimationType

func (PolygonTransaction) GetGas added in v1.10.0

func (f PolygonTransaction) GetGas() *big.Int

func (PolygonTransaction) GetMaxFeePerGas added in v1.10.0

func (f PolygonTransaction) GetMaxFeePerGas() *big.Int

func (PolygonTransaction) GetMaxPriorityFeePerGas added in v1.10.0

func (f PolygonTransaction) GetMaxPriorityFeePerGas() *big.Int

func (PolygonTransaction) GetNetwork added in v1.10.0

func (f PolygonTransaction) GetNetwork() string

func (PolygonTransaction) GetNonce added in v1.10.0

func (f PolygonTransaction) GetNonce() *int64

func (PolygonTransaction) GetPrivateKey added in v1.10.0

func (f PolygonTransaction) GetPrivateKey() string

func (PolygonTransaction) GetProtocol added in v1.10.0

func (f PolygonTransaction) GetProtocol() string

func (PolygonTransaction) GetRecipient added in v1.10.0

func (f PolygonTransaction) GetRecipient() string

func (PolygonTransaction) SetTxProtocolParams added in v1.10.0

type SendTxResult added in v1.3.0

type SendTxResult struct {
	TxHash string
	TxID   string
}

type SolanaTransaction added in v1.4.0

type SolanaTransaction struct {
	Network        string
	From           solana.PrivateKey
	To             string
	AmountLamports int64
}

type TxInput

type TxInput struct {
	Source string // UTXO, input transaction id
	Index  uint32 // UTXO, input index
}

type TxOutput

type TxOutput struct {
	Destination string // Destination address
	Amount      int64  // In sat.
}

type UbiquityTransactionService

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

UbiquityTransactionService provides API to send various protocol transactions. So far it supports BTC and ETH.

func (UbiquityTransactionService) CreateEVMTransaction added in v1.10.0

CreateEVMTransaction creates a new transaction using the Ubiquity /tx/create endpoint using the EVMTransaction interface This function returns an unsigned transaction.

func (UbiquityTransactionService) EstimateEVMTransactionFee added in v1.10.0

func (s UbiquityTransactionService) EstimateEVMTransactionFee(ctx context.Context, tx EVMTransaction) (*big.Int, *big.Int, error)

EstimateEVMTransactionFee uses the Ubiquity /tx/estimate_fee API to estimate the fee of an EVMTransaction. Uses the tx.GetFeeEstimationType() to select the category. Default is UbiquityFeeEstimationMedium.

func (UbiquityTransactionService) SendAvax added in v1.10.0

SendAvax creates, signs and sends AVAX transaction. Under the hood it uses Ubiquity TxCreate and TxSend API.

func (UbiquityTransactionService) SendBTC

SendBTC creates, signs and sends BTC transaction. Under the hood it uses Ubiquity TxSend API.

func (UbiquityTransactionService) SendDOT added in v1.3.0

SendDOT creates, signs and sends DOT transaction. Under the hood it uses Ubiquity TxCreate and TxSend API.

func (UbiquityTransactionService) SendETH

SendETH creates, signs and sends ETH transaction. Under the hood it uses Ubiquity TxSend API.

func (UbiquityTransactionService) SendFTM added in v1.10.0

SendFTM creates, signs and sends FTM transaction. Under the hood it uses Ubiquity TxCreate and TxSend API.

func (UbiquityTransactionService) SendMATIC added in v1.7.0

SendMATIC creates, signs and sends MATIC transaction. Under the hood it uses Ubiquity TxCreate and TxSend API.

func (UbiquityTransactionService) SendSOL added in v1.4.0

SendSOL creates, signs and sends SOL transaction. Under the hood it uses Ubiquity TxCreate and TxSend API.

func (UbiquityTransactionService) TxCreate added in v1.10.0

func (s UbiquityTransactionService) TxCreate(ctx context.Context, protocol, network string, tx ubiquity.TxCreate) (*ubiquity.UnsignedTx, error)

TxCreate creates a transaction using the Ubiquity /tx/create endpoint

func (UbiquityTransactionService) TxSend added in v1.10.0

func (s UbiquityTransactionService) TxSend(ctx context.Context, protocol, network string, signedTx string) (*ubiquity.TxReceipt, error)

TxSend sends a transaction using the Ubiquity /tx/send endpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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