xrp

package
v3.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 42 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// FeeUpdatePeriodBlocks is the block interval at which we report fee changes.
	FeeUpdatePeriodBlocks = 20

	// FeeCacheTransactions is the number of transactions over which we compute an average
	// (mean) fee price to use for outbound transactions. Note that only transactions
	// using the chain fee asset will be considered.
	FeeCacheTransactions = 200
)

Variables

View Source
var (
	ErrInvalidScanStorage = errors.New("scan storage is empty or nil")
	ErrInvalidMetrics     = errors.New("metrics is empty or nil")
	ErrEmptyTx            = errors.New("empty tx")
)
View Source
var XrpAssetMappings = []XrpAssetMapping{
	{
		XrpKind:        txtypes.XRP,
		XrpCurrency:    "",
		XrpIssuer:      "",
		XrpDecimals:    6,
		THORChainAsset: common.XRPAsset,
	},
}

XrpAssetMappings maps an xrp denom to a THORChain symbol and provides the asset decimals CHANGEME: define assets that should be observed by THORChain here. This also acts a whitelist.

Functions

This section is empty.

Types

type Client

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

Client is a structure to sign and broadcast tx to XRP chain used by signer mostly

func NewClient

func NewClient(
	thorKeys *thorclient.Keys,
	cfg config.BifrostChainConfiguration,
	server *tssp.TssServer,
	thorchainBridge thorclient.ThorchainBridge,
	m *metrics.Metrics,
) (*Client, error)

NewClient creates a new instance of an XRP-based chain client

func (*Client) BroadcastTx

func (c *Client) BroadcastTx(tx stypes.TxOutItem, txBytes []byte) (string, error)

BroadcastTx is to broadcast the tx to cosmos chain

func (*Client) ConfirmationCountReady

func (c *Client) ConfirmationCountReady(txIn stypes.TxIn) bool

ConfirmationCountReady xrp chain has almost instant finality, so doesn't need to wait for confirmation

func (*Client) GetAccount

func (c *Client) GetAccount(pkey common.PubKey, height *big.Int) (common.Account, error)

func (*Client) GetAccountByAddress

func (c *Client) GetAccountByAddress(address string, height *big.Int) (common.Account, error)

func (*Client) GetAddress

func (c *Client) GetAddress(poolPubKey common.PubKey) string

GetAddress return current signer address, it will be bech32 encoded address

func (*Client) GetBlockScannerHeight

func (c *Client) GetBlockScannerHeight() (int64, error)

GetBlockScannerHeight returns blockscanner height

func (*Client) GetChain

func (c *Client) GetChain() common.Chain

func (*Client) GetConfig

func (c *Client) GetConfig() config.BifrostChainConfiguration

GetConfig return the configuration used by Xrp chain client

func (*Client) GetConfirmationCount

func (c *Client) GetConfirmationCount(txIn stypes.TxIn) int64

GetConfirmationCount determine how many confirmations are required NOTE: Xrp chains are instant finality, so confirmations are not needed. If the transaction was successful, we know it is included in a block and thus immutable.

func (*Client) GetHeight

func (c *Client) GetHeight() (int64, error)

func (*Client) GetLatestTxForVault

func (c *Client) GetLatestTxForVault(vault string) (string, string, error)

func (*Client) IsBlockScannerHealthy

func (c *Client) IsBlockScannerHealthy() bool

func (*Client) OnObservedTxIn

func (c *Client) OnObservedTxIn(txIn stypes.TxInItem, blockHeight int64)

OnObservedTxIn update the signer cache (in case we haven't already)

func (*Client) ReportSolvency

func (c *Client) ReportSolvency(blockHeight int64) error

func (*Client) RollbackBlockScanner added in v3.6.1

func (c *Client) RollbackBlockScanner() error

RollbackBlockScanner rolls back the block scanner to the last observed block

func (*Client) ShouldReportSolvency

func (c *Client) ShouldReportSolvency(height int64) bool

func (*Client) SignTx

func (c *Client) SignTx(tx stypes.TxOutItem, thorchainHeight int64) (signedTx, checkpoint []byte, _ *stypes.TxInItem, err error)

SignTx sign the the given TxArrayItem

func (*Client) Start

func (c *Client) Start(globalTxsQueue chan stypes.TxIn, globalErrataQueue chan stypes.ErrataBlock, globalSolvencyQueue chan stypes.Solvency, globalNetworkFeeQueue chan common.NetworkFee)

Start Xrp chain client

func (*Client) Stop

func (c *Client) Stop()

Stop Xrp chain client

type LedgerResponseWithTxHashes

type LedgerResponseWithTxHashes struct {
	Ledger struct {
		Transactions []string `json:"transactions,omitempty"`
	} `json:"ledger"`
	LedgerHash  string                 `json:"ledger_hash"`
	LedgerIndex xrplcommon.LedgerIndex `json:"ledger_index"`
	Validated   bool                   `json:"validated,omitempty"`
}

The expected response from the ledger method.

type SolvencyReporter

type SolvencyReporter func(int64) error

SolvencyReporter is to report solvency info to THORNode

type XrpAssetMapping

type XrpAssetMapping struct {
	XrpKind        txtypes.CurrencyKind
	XrpCurrency    string
	XrpIssuer      string
	XrpDecimals    int64
	THORChainAsset common.Asset
}

func GetAssetByThorchainAsset

func GetAssetByThorchainAsset(asset common.Asset) (XrpAssetMapping, bool)

func GetAssetByXrpCurrency

func GetAssetByXrpCurrency(coin txtypes.CurrencyAmount) (XrpAssetMapping, bool)

type XrpBlockScanner

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

XrpBlockScanner is to scan the blocks

func NewXrpBlockScanner

func NewXrpBlockScanner(rpcHost string,
	cfg config.BifrostBlockScannerConfiguration,
	scanStorage blockscanner.ScannerStorage,
	bridge thorclient.ThorchainBridge,
	m *metrics.Metrics,
	solvencyReporter SolvencyReporter,
) (*XrpBlockScanner, error)

NewXrpBlockScanner create a new instance of BlockScan

func (*XrpBlockScanner) FetchMemPool

func (c *XrpBlockScanner) FetchMemPool(height int64) (types.TxIn, error)

FetchMemPool returns nothing since we are only concerned about finalized transactions in Xrp

func (*XrpBlockScanner) FetchTxs

func (c *XrpBlockScanner) FetchTxs(height, chainHeight int64) (types.TxIn, error)

func (*XrpBlockScanner) GetHeight

func (c *XrpBlockScanner) GetHeight() (int64, error)

GetHeight returns the index of the most recently validated ledger.

func (*XrpBlockScanner) GetNetworkFee

func (c *XrpBlockScanner) GetNetworkFee() (transactionSize, transactionFeeRate uint64)

GetNetworkFee returns current chain network fee according to Bifrost.

type XrpMetaDataStore

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

func NewXrpMetaDataStore

func NewXrpMetaDataStore() *XrpMetaDataStore

func (*XrpMetaDataStore) Get

func (*XrpMetaDataStore) SeqInc

func (b *XrpMetaDataStore) SeqInc(pk common.PubKey)

func (*XrpMetaDataStore) Set

func (b *XrpMetaDataStore) Set(pk common.PubKey, meta XrpMetadata)

type XrpMetadata

type XrpMetadata struct {
	SeqNumber   int64
	BlockHeight int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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