Documentation
¶
Index ¶
- Constants
- Variables
- func AddressPublic(address string, mnemonic string, passphrase string, sequence uint32) (string, error)
- func AddressSecret(address string, mnemonic string, passphrase string, sequence uint32) (string, error)
- func AddressWallet(mnemonic string, passphrase string, sequence uint32) (string, error)
- func CreateFakeCreateAccountTransaction(fromAddress, toAddress string) (*core.Transaction, error)
- func CreateFakeResourceTransaction(fromAddress, toAddress string, amount int64, resourceType core.ResourceCode, ...) (*core.Transaction, error)
- func PrepareStreamInterceptor(kv ...string) grpc.StreamClientInterceptor
- func PrepareUnaryInterceptor(kv ...string) grpc.UnaryClientInterceptor
- func ValidateAddress(address string) bool
- func WalletFromPrivateKeyBytes(privateKey []byte) (string, *ecdsa.PrivateKey, *ecdsa.PublicKey)
- func WalletPubKeyHash(mnemonic string, passphrase string, sequence uint32) (string, *ecdsa.PrivateKey, *ecdsa.PublicKey, error)
- type AccountResourceInfoData
- type ActivationResources
- type Bandwidth
- type ChainParams
- type Config
- type Energy
- type EstimateSystemActivationResourcesResult
- type EstimateTransferResourcesResult
- type EstimateTransferWithDelegateResourcesRequest
- type EstimateTransferWithDelegateResourcesResponse
- type EstimateTransferWithExternalDelegateResourcesRequest
- type EstimateTransferWithExternalDelegateResourcesResponse
- type MethodSignature
- type ReclaimResourceParams
- type Resources
- type SystemResources
- type TRX
- type Tron
- func (t *Tron) AccountResourceInfo(ctx context.Context, addr string) (*AccountResourceInfoData, error)
- func (t *Tron) AvailableBandwidth(res *api.AccountResourceMessage) decimal.Decimal
- func (t *Tron) AvailableBandwidthWithoutFree(res *api.AccountResourceMessage) decimal.Decimal
- func (t *Tron) AvailableEnergy(res *api.AccountResourceMessage) decimal.Decimal
- func (t *Tron) AvailableForDelegateResources(ctx context.Context, addr string) (*Resources, error)
- func (t *Tron) ChainParam(ctx context.Context, paramKey string) (*core.ChainParameters_ChainParameter, error)
- func (t *Tron) ChainParams(ctx context.Context) (*ChainParams, error)
- func (t *Tron) CheckIsWalletActivated(address string) (bool, error)
- func (t *Tron) ConvertBandwidthToStackedTRX(totalNetWeight, totalNetLimit int64, bandwidth decimal.Decimal) decimal.Decimal
- func (t *Tron) ConvertEnergyToStackedTRX(totalEnergyCurrentLimit, totalEnergyWeight int64, energy decimal.Decimal) decimal.Decimal
- func (t *Tron) ConvertStackedTRXToBandwidth(totalNetWeight, totalNetLimit, stackedTrx int64) decimal.Decimal
- func (t *Tron) ConvertStackedTRXToEnergy(totalEnergyCurrentLimit, totalEnergyWeight, stackedTrx int64) decimal.Decimal
- func (t *Tron) CreateUnsignedActivationTransaction(ctx context.Context, caller string, receiver string, constant bool) (*api.TransactionExtention, error)
- func (t *Tron) EstimateActivationFee(ctx context.Context, fromAddress, toAddress string) (*ActivationResources, error)
- func (t *Tron) EstimateBandwidth(tx *core.Transaction) (decimal.Decimal, error)
- func (t *Tron) EstimateExternalContractActivation(ctx context.Context, caller, receiver string) (*ActivationResources, error)
- func (t *Tron) EstimateSelfFundedTransferFee(ctx context.Context, fromAddress, toAddress, assetIdentifier string, ...) (decimal.Decimal, error)
- func (t *Tron) EstimateSystemContractActivation(ctx context.Context, caller string, receiver string) (*ActivationResources, error)
- func (t *Tron) EstimateTransferResources(ctx context.Context, fromAddress, toAddress, contractAddress string, ...) (*EstimateTransferResourcesResult, error)
- func (t *Tron) EstimateTransferWithDelegateResources(ctx context.Context, req EstimateTransferWithDelegateResourcesRequest) (*EstimateTransferWithDelegateResourcesResponse, error)
- func (t *Tron) EstimateTransferWithExternalDelegateResources(ctx context.Context, req EstimateTransferWithExternalDelegateResourcesRequest) (*EstimateTransferWithExternalDelegateResourcesResponse, error)
- func (t *Tron) GetMaxOperationsCount(availableEnergy, availableBandwidth int64) uint32
- func (t *Tron) Name() string
- func (t *Tron) Node() *client.GrpcClient
- func (t *Tron) ReclaimResource(ctx context.Context, params ReclaimResourceParams) (*api.TransactionExtention, error)
- func (t *Tron) SignTransaction(tx *core.Transaction, privateKey *ecdsa.PrivateKey) error
- func (t *Tron) StakedResources(ctx context.Context, addr string) (*api.AccountResourceMessage, []account.FrozenResource, error)
- func (t *Tron) Start(_ context.Context) error
- func (t *Tron) Stop(_ context.Context) error
- func (t *Tron) TotalAvailableResources(addr string) (*Resources, error)
- func (t *Tron) TotalBandwidthLimit(res *api.AccountResourceMessage) decimal.Decimal
- func (t *Tron) TotalEnergyLimit(res *api.AccountResourceMessage) decimal.Decimal
- type WalletSDK
Constants ¶
const (
BlackHoleAddress = "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb"
)
const TrxAssetIdentifier = "trx"
Variables ¶
var ResourceCoefficient = decimal.NewFromFloat(1.007)
Functions ¶
func AddressPublic ¶
func AddressSecret ¶
func AddressWallet ¶
func CreateFakeCreateAccountTransaction ¶
func CreateFakeCreateAccountTransaction(fromAddress, toAddress string) (*core.Transaction, error)
func CreateFakeResourceTransaction ¶
func CreateFakeResourceTransaction(fromAddress, toAddress string, amount int64, resourceType core.ResourceCode, reclaim bool) (*core.Transaction, error)
CreateFakeResourceTransaction creates a fake resource transaction.
func PrepareStreamInterceptor ¶
func PrepareStreamInterceptor(kv ...string) grpc.StreamClientInterceptor
func PrepareUnaryInterceptor ¶
func PrepareUnaryInterceptor(kv ...string) grpc.UnaryClientInterceptor
func ValidateAddress ¶
Types ¶
type AccountResourceInfoData ¶
type AccountResourceInfoData struct {
EnergyAvailableForUse decimal.Decimal `json:"energy_available_for_use"`
BandwidthAvailableForUse decimal.Decimal `json:"bandwidth_available_for_use"`
TotalEnergy decimal.Decimal `json:"total_energy"`
TotalBandwidth decimal.Decimal `json:"total_bandwidth"`
TotalStackedTRX decimal.Decimal `json:"total_stacked_trx"`
StackedEnergyTRX decimal.Decimal `json:"stacked_energy_trx"`
StackedBandwidthTRX decimal.Decimal `json:"stacked_bandwidth_trx"`
StackedEnergy decimal.Decimal `json:"stacked_energy"`
StackedBandwidth decimal.Decimal `json:"stacked_bandwidth"`
TotalUsedEnergy decimal.Decimal `json:"total_used_energy"`
TotalUsedBandwidth decimal.Decimal `json:"total_used_bandwidth"`
TotalAvailableEnergy decimal.Decimal `json:"total_available_energy"`
TotalAvailableBandwidth decimal.Decimal `json:"total_available_bandwidth"`
}
type ActivationResources ¶
type Bandwidth ¶
type Bandwidth struct {
// contains filtered or unexported fields
}
func NewBandwidth ¶
type ChainParams ¶
type Energy ¶
type Energy struct {
// contains filtered or unexported fields
}
type EstimateSystemActivationResourcesResult ¶
type EstimateSystemActivationResourcesResult struct {
Bandwidth decimal.Decimal `json:"bandwidth"`
TRX decimal.Decimal `json:"trx"`
}
EstimateSystemActivationResourcesResult
Bandwidth - amount of bandwidth required for activation contract call ¶
TRX - amount of TRX required for activation contract call (burning trx for bandwidth and fixed activation fee) ¶
type EstimateTransferWithDelegateResourcesRequest ¶
type EstimateTransferWithDelegateResourcesRequest struct {
ProcessingAddress string `json:"processing_address"`
HotWalletAddress string `json:"hot_wallet_address"`
ProcessingResources Resources `json:"processing_resources"`
HotResources Resources `json:"hot_resources"`
Estimate EstimateTransferResourcesResult `json:"estimate"`
}
EstimateTransferWithDelegateResourcesRequest is the request for EstimateTransferWithDelegateResources.
All fields are required.
type EstimateTransferWithExternalDelegateResourcesRequest ¶
type EstimateTransferWithExternalDelegateResourcesRequest struct {
HotWalletAddress string `json:"hot_wallet_address"`
HotResources Resources `json:"hot_resources"`
Estimate EstimateTransferResourcesResult `json:"estimate"`
}
func (*EstimateTransferWithExternalDelegateResourcesRequest) Validate ¶
func (o *EstimateTransferWithExternalDelegateResourcesRequest) Validate() error
type EstimateTransferWithExternalDelegateResourcesResponse ¶
type EstimateTransferWithExternalDelegateResourcesResponse struct {
NeedResourcesToTransfer Resources `json:"need_resources_to_transfer"`
NeedSystemResources SystemResources `json:"need_system_resources"`
NeedResourcesToActivate ActivationResources `json:"need_resources_to_activate"`
NeedToActivate bool `json:"need_to_activate"`
}
type MethodSignature ¶
type MethodSignature string
const (
ActivatorActivateMethodSignature MethodSignature = "1c5a9d9c"
)
func (MethodSignature) String ¶
func (o MethodSignature) String() string
type ReclaimResourceParams ¶
type SystemResources ¶
type SystemResources struct {
NeedForEnergyDelegation decimal.Decimal `json:"need_for_energy_delegation"`
NeedForEnergyReclaim decimal.Decimal `json:"need_for_energy_reclaim"`
NeedForBandwidthDelegation decimal.Decimal `json:"need_for_bandwidth_delegation"`
NeedForBandwidthReclaim decimal.Decimal `json:"need_for_bandwidth_reclaim"`
}
type TRX ¶
type TRX struct {
// contains filtered or unexported fields
}
func (TRX) ToBandwidth ¶
ToBandwidth converts TRX to Bandwidth.
type Tron ¶
type Tron struct {
// contains filtered or unexported fields
}
func (*Tron) AccountResourceInfo ¶
func (*Tron) AvailableBandwidth ¶
func (t *Tron) AvailableBandwidth(res *api.AccountResourceMessage) decimal.Decimal
AvailableBandwidth calculates the available bandwidth.
func (*Tron) AvailableBandwidthWithoutFree ¶
func (t *Tron) AvailableBandwidthWithoutFree(res *api.AccountResourceMessage) decimal.Decimal
func (*Tron) AvailableEnergy ¶
func (t *Tron) AvailableEnergy(res *api.AccountResourceMessage) decimal.Decimal
AvailableEnergy calculates the available energy.
func (*Tron) AvailableForDelegateResources ¶
AvailableForDelegateResources calculates the available energy and bandwidth for delegate to another account.
func (*Tron) ChainParam ¶
func (t *Tron) ChainParam(ctx context.Context, paramKey string) (*core.ChainParameters_ChainParameter, error)
ChainParam get chain parameters
func (*Tron) ChainParams ¶
func (t *Tron) ChainParams(ctx context.Context) (*ChainParams, error)
func (*Tron) CheckIsWalletActivated ¶
CheckIsWalletActivated checks if the wallet is activated
func (*Tron) ConvertBandwidthToStackedTRX ¶
func (t *Tron) ConvertBandwidthToStackedTRX(totalNetWeight, totalNetLimit int64, bandwidth decimal.Decimal) decimal.Decimal
ConvertBandwidthToStackedTRX converts bandwidth to stacked TRX. Returns value in SUN.
func (*Tron) ConvertEnergyToStackedTRX ¶
func (t *Tron) ConvertEnergyToStackedTRX(totalEnergyCurrentLimit, totalEnergyWeight int64, energy decimal.Decimal) decimal.Decimal
ConvertEnergyToStackedTRX converts energy to stacked TRX. Returns value in SUN.
func (*Tron) ConvertStackedTRXToBandwidth ¶
func (t *Tron) ConvertStackedTRXToBandwidth(totalNetWeight, totalNetLimit, stackedTrx int64) decimal.Decimal
ConvertStackedTRXToBandwidth converts stacked TRX to bandwidth.
func (*Tron) ConvertStackedTRXToEnergy ¶
func (t *Tron) ConvertStackedTRXToEnergy(totalEnergyCurrentLimit, totalEnergyWeight, stackedTrx int64) decimal.Decimal
ConvertStackedTRXToEnergy converts stacked TRX to energy.
func (*Tron) CreateUnsignedActivationTransaction ¶
func (*Tron) EstimateActivationFee ¶
func (t *Tron) EstimateActivationFee(ctx context.Context, fromAddress, toAddress string) (*ActivationResources, error)
EstimateActivationFee estimates the activation fee for a Tron address. It checks the available bandwidth and adds the activation fee accordingly. The fee is returned in TRX (1 TRX = 1_000_000 SUN). We assume that fromAddress is ALWAYS activated, being it processing address. Simple swap of arg to BlackHoleAddress on fakeTx creation will always return valid tx.
func (*Tron) EstimateBandwidth ¶
EstimateBandwidth calculates the estimated bandwidth.
func (*Tron) EstimateExternalContractActivation ¶
func (*Tron) EstimateSelfFundedTransferFee ¶ added in v0.9.13
func (t *Tron) EstimateSelfFundedTransferFee( ctx context.Context, fromAddress, toAddress, assetIdentifier string, estimate EstimateTransferResourcesResult, resources Resources, ) (decimal.Decimal, error)
EstimateSelfFundedTransferFee returns TRX burned by the sender when it pays the transfer by itself, without delegated resources or activation from another wallet.
For TRX it includes the activation of the recipient and the bandwidth if the sender lacks it. For TRC20 the whole estimated TRX is required if the sender lacks energy or bandwidth.
func (*Tron) EstimateSystemContractActivation ¶
func (*Tron) EstimateTransferResources ¶
func (t *Tron) EstimateTransferResources( ctx context.Context, fromAddress, toAddress, contractAddress string, amount decimal.Decimal, decimals int64, ) (*EstimateTransferResourcesResult, error)
EstimateTransferResources calculates the estimated transfer resources.
func (*Tron) EstimateTransferWithDelegateResources ¶
func (t *Tron) EstimateTransferWithDelegateResources(ctx context.Context, req EstimateTransferWithDelegateResourcesRequest) (*EstimateTransferWithDelegateResourcesResponse, error)
func (*Tron) EstimateTransferWithExternalDelegateResources ¶
func (t *Tron) EstimateTransferWithExternalDelegateResources(ctx context.Context, req EstimateTransferWithExternalDelegateResourcesRequest) (*EstimateTransferWithExternalDelegateResourcesResponse, error)
func (*Tron) GetMaxOperationsCount ¶
GetMaxOperationsCount calculates the maximum operations count based on the available energy and bandwidth.
func (*Tron) ReclaimResource ¶
func (t *Tron) ReclaimResource(ctx context.Context, params ReclaimResourceParams) (*api.TransactionExtention, error)
func (*Tron) SignTransaction ¶
func (t *Tron) SignTransaction(tx *core.Transaction, privateKey *ecdsa.PrivateKey) error
SignTransaction signs the transaction with the given private key
func (*Tron) StakedResources ¶
func (t *Tron) StakedResources(ctx context.Context, addr string) (*api.AccountResourceMessage, []account.FrozenResource, error)
func (*Tron) TotalAvailableResources ¶
TotalAvailableResources calculates the total available resources for the account.
func (*Tron) TotalBandwidthLimit ¶
func (t *Tron) TotalBandwidthLimit(res *api.AccountResourceMessage) decimal.Decimal
func (*Tron) TotalEnergyLimit ¶
func (t *Tron) TotalEnergyLimit(res *api.AccountResourceMessage) decimal.Decimal