stellar

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: 27 Imported by: 0

README

stellar router specials

stellar token config ContractAddress item

ContractAddress is native(XLM) or format of Code/Issuser

XLM stands for native

stellar chain and token config RouterContract item

RouterContract is the mpc address

stellar public key to stellar address

go run ./tokens/stellar/tools/publicKeyToAddress/main.go -p 0xED146f71db711bc259176f9bcba1756308d2a7af0f1c0b90deece65997a84c8f56
# output
address: GAKG64O3OEN4EWIXN6N4XILVMMENFJ5PB4OAXEG65TTFTF5IJSHVMBIC

router mechanism

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

len(hexBytesArray(bindAddress)) hexBytesArray(bindAddress) zeroPadding(hexBytesArray(toChainID))

example:

bindAddress: 0xC5107334A3Ae117E3DaD3570b419618C905Aa5eC  toChainID:5777

[20 197 16 115 52 163 174 17 126 61 173 53 112 180 25 97 140 144 90 165 236 0 0 0 0 0 0 0 0 0 87 119]

output:
14c5107334a3ae117e3dad3570b419618c905aa5ec0000000000000000001691

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

stellar tools

use -h option to get help info for each tool

example:

go run tokens/stellar/tools/publicKeyToAddress/main.go -h
addressToPublickey
	convert stellar address to stellar public key(ed25519)
publicKeyToAddress
	convert stellar public key to stellar address
buildSwapMemo
	format swapout memo by toAddress and toChainID
sendPaymentTx
	send mpc signed Payment tx
sendTrustLineTx
	send mpc signed TrustLine tx
getStubChainID
	get stellar chainID

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMemos

func DecodeMemos(memoStr string) (string, *big.Int)

func EncodeMemo

func EncodeMemo(chainId *big.Int, bindAddr string) (*txnbuild.MemoHash, error)

func FormatPublicKeyToPureHex

func FormatPublicKeyToPureHex(pubKeyHex string) (string, error)

FormatPublicKeyToPureHex format public key, get rid of hex prefix and ED prefix

func GetStubChainID

func GetStubChainID(networkid string) *big.Int

GetStubChainID get stub chainID

func MakeSignedTransaction

func MakeSignedTransaction(pubkey *keypair.FromAddress, sig []byte, tx *txnbuild.Transaction) (signedTx *txnbuild.Transaction, err error)

MakeSignedTransaction make signed transaction

func NewUnsignedPaymentTransaction

func NewUnsignedPaymentTransaction(args *tokens.BuildTxArgs,
	from txnbuild.Account, network,
	dest, amt string, memo txnbuild.Memo, asset txnbuild.Asset,
) (*txnbuild.Transaction, error)

NewUnsignedPaymentTransaction build stellar payment tx

func PublicKeyHexToAddress

func PublicKeyHexToAddress(pubKeyHex string) (string, error)

PublicKeyHexToAddress convert public key hex to stellar address

func PublicKeyToAddress

func PublicKeyToAddress(pubkey []byte) (string, error)

PublicKeyToAddress public key to 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 {
	*tokens.CrossChainBridgeBase
	NetworkStr string
	Remotes    map[string]*horizonclient.Client
}

Bridge block bridge inherit from btc bridge

func NewCrossChainBridge

func NewCrossChainBridge(chainID string) *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) (acct *hProtocol.Account, err error)

GetAccount returns account

func (*Bridge) GetAsset

func (b *Bridge) GetAsset(code, address string) (acct *hProtocol.AssetStat, err error)

GetAsset returns asset stat

func (*Bridge) GetBalance

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

GetBalance gets balance

func (*Bridge) GetBlockHash

func (b *Bridge) GetBlockHash(num uint64) (hash string, err error)

GetBlockHash gets block hash

func (*Bridge) GetBlockTxids

func (b *Bridge) GetBlockTxids(num uint64) (txs []string, err error)

GetBlockTxids gets block txids

func (*Bridge) GetFee

func (b *Bridge) GetFee() int

GetFee get fee

func (*Bridge) GetLatestBlockNumber

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

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

func (*Bridge) GetLatestBlockNumberOf

func (b *Bridge) GetLatestBlockNumberOf(apiAddress string) (uint64, error)

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

func (*Bridge) GetOperations

func (b *Bridge) GetOperations(txHash string) (opts []interface{}, err error)

GetOperations get operations

func (*Bridge) GetTransaction

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

GetTransaction impl

func (*Bridge) GetTransactionStatus

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

GetTransactionStatus impl

func (*Bridge) InitRemotes

func (b *Bridge) InitRemotes()

InitRemotes set stellar remotes

func (*Bridge) InitRouterInfo

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

InitRouterInfo init router info (in stellar 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(pubKey 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) SetGatewayConfig

func (b *Bridge) SetGatewayConfig(gatewayCfg *tokens.GatewayConfig)

SetGatewayConfig set gateway config

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) SignTransactionWithStellarKey

func (b *Bridge) SignTransactionWithStellarKey(rawTx interface{}, key *keypair.Full) (signTx interface{}, txHash string, err error)

SignTransactionWithStellarKey sign tx with stellar 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

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

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