ripple

package
v3.0.0-...-e8b7a4c Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

README

ripple router specials

ripple token config ContractAddress item

ContractAddress is XRP or format of Currency/Issuser

XRP stands for native

ripple chain and token config RouterContract item

RouterContract is the mpc address

ripple public key to ripple address

go run tokens/ripple/tools/publicKeyToAddress/main.go 04b4904f8a2ea01891678fec45c63fb1f221666e7d19cfeeb28f08a6d99cac91cbc12731f4c144aef501e34a6eaa0b5418ed5d138b192964bc5ccf4cde67246ca3
# output
address: rDsvn6aJG4YMQdHnuJtP9NLrFp18JYTJUf

router mechanism

  1. Swapout from ripple to other chain

user send asset to mpc address with memo of the following format

bindAddress:toChainID

example:

0x1111111111111111111111111111111111111111:4

to specify route asset to which address (bindAddress) and to which destination blockchain (toChainID)

  1. Swapin from other chain to ripple
function anySwapOut(address token, string memory to, uint amount, uint toChainID)

to is the destination on ripple, it can be an ripple address, or ripple_address:destinationTag for some address that require destination tag.

ripple tools

use -h option to get help info for each tool

example:

go run tokens/ripple/tools/publicKeyToAddress/main.go -h

for transaction flags, please refer tokens/ripple/rubblelabs/ripple/data/flags.go

publicKeyToAddress
	convert ripple public key to ripple address

sendPaymentTx
	send mpc signed Payment tx

sendAccountSetTx
	send mpc signed AccountSet tx

sendTrustSetTx
	send mpc signed TrustSet tx

Documentation

Index

Constants

View Source
const (
	// PubKeyBytesLenCompressed is compressed pubkey byte length
	PubKeyBytesLenCompressed = 33
	// PubKeyBytesLenUncompressed is uncompressed pubkey byte length
	PubKeyBytesLenUncompressed = 65
)

Variables

This section is empty.

Functions

func GetAddress

func GetAddress(k crypto.Key, sequence *uint32) string

GetAddress gets address from ripple key

func GetAddressAndTag

func GetAddressAndTag(s string) (addr string, tag *uint32, err error)

GetAddressAndTag get address and tag

func GetStubChainID

func GetStubChainID(network string) *big.Int

GetStubChainID get stub chainID

func ImportKeyFromSeed

func ImportKeyFromSeed(seed, cryptoType string) (crypto.Key, error)

ImportKeyFromSeed converts seed to ripple key

func ImportPublicKey

func ImportPublicKey(pubkey []byte) crypto.Key

ImportPublicKey converts pubkey to ripple pubkey

func MakeSignedTransaction

func MakeSignedTransaction(pubkey []byte, rsv string, transaction interface{}) (signedTx data.Transaction, err error)

MakeSignedTransaction make signed transaction

func NewUnsignedPaymentTransaction

func NewUnsignedPaymentTransaction(
	key crypto.Key, keyseq *uint32, txseq uint32,
	dest string, destinationTag *uint32,
	amt, fee, memo, path string, flags uint32,
) (data.Transaction, error)

NewUnsignedPaymentTransaction build ripple payment tx

func ParsePaths

func ParsePaths(s string) (*data.PathSet, error)

ParsePaths parse paths

func PublicKeyHexToAddress

func PublicKeyHexToAddress(pubKeyHex string) (string, error)

PublicKeyHexToAddress convert public key hex to ripple address

func PublicKeyToAddress

func PublicKeyToAddress(pubkey []byte) string

PublicKeyToAddress converts pubkey to ripple address

func SetRPCRetryTimes

func SetRPCRetryTimes(times int)

SetRPCRetryTimes set rpc retry times (used in cmd tools)

func SupportsChainID

func SupportsChainID(chainID *big.Int) bool

SupportsChainID supports chainID

func VerifyMPCPubKey

func VerifyMPCPubKey(mpcAddress, mpcPubkey string) error

VerifyMPCPubKey verify mpc address and public key is matching

Types

type Bridge

type Bridge struct {
	*base.NonceSetterBase
}

Bridge block bridge inherit from btc bridge

func NewCrossChainBridge

func NewCrossChainBridge() *Bridge

NewCrossChainBridge new bridge

func (*Bridge) BuildRawTransaction

func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)

BuildRawTransaction build raw tx

func (*Bridge) GetAccount

func (b *Bridge) GetAccount(address string) (acctRes *websockets.AccountInfoResult, err error)

GetAccount returns account

func (*Bridge) GetAccountLine

func (b *Bridge) GetAccountLine(currency, issuer, accountAddress string) (line *data.AccountLine, err error)

GetAccountLine get account line

func (*Bridge) GetBalance

func (b *Bridge) GetBalance(accountAddress string) (*big.Int, error)

GetBalance gets balance

func (*Bridge) GetFee

func (b *Bridge) GetFee() (feeRes *websockets.FeeResult, err error)

GetFee get fee

func (*Bridge) GetLatestBlockNumber

func (b *Bridge) GetLatestBlockNumber() (num uint64, err error)

GetLatestBlockNumber gets latest block number For ripple, GetLatestBlockNumber returns current ledger version

func (*Bridge) GetLatestBlockNumberOf

func (b *Bridge) GetLatestBlockNumberOf(url string) (num uint64, err error)

GetLatestBlockNumberOf gets latest block number from single api For ripple, GetLatestBlockNumberOf returns current ledger version

func (*Bridge) GetPoolNonce

func (b *Bridge) GetPoolNonce(address, _height string) (uint64, error)

GetPoolNonce impl NonceSetter interface

func (*Bridge) GetSeq

func (b *Bridge) GetSeq(args *tokens.BuildTxArgs) (nonceptr *uint64, err error)

GetSeq returns account tx sequence

func (*Bridge) GetTransaction

func (b *Bridge) GetTransaction(txHash string) (tx interface{}, err error)

GetTransaction impl

func (*Bridge) GetTransactionByHash

func (b *Bridge) GetTransactionByHash(txHash string) (txRes *websockets.TxResult, err error)

GetTransactionByHash call eth_getTransactionByHash

func (*Bridge) GetTransactionStatus

func (b *Bridge) GetTransactionStatus(txHash string) (status *tokens.TxStatus, err error)

GetTransactionStatus impl

func (*Bridge) GetTxBlockInfo

func (b *Bridge) GetTxBlockInfo(txHash string) (blockHeight, blockTime uint64)

GetTxBlockInfo impl NonceSetter interface

func (*Bridge) InitRouterInfo

func (b *Bridge) InitRouterInfo(routerContract, routerVersion string) (err error)

InitRouterInfo init router info (in ripple routerContract is routerMPC)

func (*Bridge) IsValidAddress

func (b *Bridge) IsValidAddress(addr string) bool

IsValidAddress check address

func (*Bridge) MPCSignTransaction

func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signTx interface{}, txHash string, err error)

MPCSignTransaction mpc sign raw tx

func (*Bridge) PublicKeyToAddress

func (b *Bridge) PublicKeyToAddress(pubKeyHex string) (string, error)

PublicKeyToAddress impl

func (*Bridge) RegisterSwap

func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)

RegisterSwap api

func (*Bridge) SendTransaction

func (b *Bridge) SendTransaction(signedTx interface{}) (txHash string, err error)

SendTransaction send signed tx

func (*Bridge) SetTokenConfig

func (b *Bridge) SetTokenConfig(tokenAddr string, tokenCfg *tokens.TokenConfig)

SetTokenConfig set token config

func (*Bridge) SignTransactionWithPrivateKey

func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, privKey string) (signTx interface{}, txHash string, err error)

SignTransactionWithPrivateKey sign tx with ECDSA private key

func (*Bridge) SignTransactionWithRippleKey

func (b *Bridge) SignTransactionWithRippleKey(rawTx interface{}, key rcrypto.Key, keyseq *uint32) (signTx interface{}, txHash string, err error)

SignTransactionWithRippleKey sign tx with ripple key

func (*Bridge) VerifyMsgHash

func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHashes []string) (err error)

VerifyMsgHash verify msg hash

func (*Bridge) VerifyTokenConfig

func (b *Bridge) VerifyTokenConfig(tokenCfg *tokens.TokenConfig) error

VerifyTokenConfig verify token config

func (*Bridge) VerifyTransaction

func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)

VerifyTransaction impl

type EcdsaPublic

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

EcdsaPublic struct ripple ecdsa pubkey key

func (*EcdsaPublic) Id

func (k *EcdsaPublic) Id(sequence *uint32) []byte

Id returns pubkey bytes from ripple key

func (*EcdsaPublic) Private

func (k *EcdsaPublic) Private(sequence *uint32) []byte

Private not used

func (*EcdsaPublic) Public

func (k *EcdsaPublic) Public(sequence *uint32) []byte

Public returns pubkey bytes

Directories

Path Synopsis
rubblelabs
ripple/config
Package config provides a simple way of signing submitting groups of transactions for the same account.
Package config provides a simple way of signing submitting groups of transactions for the same account.
ripple/data
Package data aims to provides all the data types that are needed to build tools, clients and servers for use on the Ripple network.
Package data aims to provides all the data types that are needed to build tools, clients and servers for use on the Ripple network.
tools

Jump to

Keyboard shortcuts

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