iota

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

README

params

testnet: https://api.lb-0.h.chrysalis-devnet.iota.cafe
mainnet: https://chrysalis-nodes.iota.cafe
chainId: 
    mainnet: 1001229935681
    testnet: 1001229935682
faucet: https://faucet.chrysalis-devnet.iota.cafe/
api: https://editor.swagger.io/?url=https://raw.githubusercontent.com/iotaledger/tips/main/tips/TIP-0013/rest-api.yaml
explorer: https://explorer.iota.org/devnet

tools

1) getStubChainID
go run ./tokens/iota/tools/getStubChainID/main.go -p testnet

testnet: 1001229935682
2) publicKeyToAddress
go run ./tokens/iota/tools/publicKeyToAddress/main.go -p https://api.lb-0.h.chrysalis-devnet.iota.cafe -publicKey eaf07201ddba01c9537fea8cbdcf3bda7726b0155808f2442c62d48797dc55d4

edAddr: 9fb648524b9747608791dbd76bacbebc2f7ac0e3ace10e896739a0a44190102f
iotaAddr: atoi1qz0mvjzjfwt5wcy8j8daw6avh67z77kquwkwzr5fvuu6pfzpjqgz7cptqex
3) sendTransaction
go run ./tokens/iota/tools/sendTransaction/main.go -n https://api.lb-0.h.chrysalis-devnet.iota.cafe -publicKey ae67243f1d58f57188335adc29a98e856e46c0cc38bd63558d6636fcd0eccc03 -privKey 4023b0cc68bff18b8ae595b3a1f315f925d187b083ffcdee5051a70086bbec0cae67243f1d58f57188335adc29a98e856e46c0cc38bd63558d6636fcd0eccc03 -to atoi1qz0mvjzjfwt5wcy8j8daw6avh67z77kquwkwzr5fvuu6pfzpjqgz7cptqex -index swapOut -data 0x1739648E7C1B23D6Da74177292B36aF7f286f643:4 -value 1000000
4) keygen
go run ./tokens/iota/tools/keygen/main.go

deploy step

1) get mpc publicKey(ed25519)
2) get mpc iota address
go run ./tokens/iota/tools/publicKeyToAddress/main.go -p https://api.lb-0.h.chrysalis-devnet.iota.cafe -publicKey eaf07201ddba01c9537fea8cbdcf3bda7726b0155808f2442c62d48797dc55d4

edAddr: 9fb648524b9747608791dbd76bacbebc2f7ac0e3ace10e896739a0a44190102f
iotaAddr: atoi1qz0mvjzjfwt5wcy8j8daw6avh67z77kquwkwzr5fvuu6pfzpjqgz7cptqex
3) set config 
chainConfig: routerContract is mpc address(edAddr)
tokenConfig: routerContract is mpc address(edAddr) tokenAddr is "iota" decimal:6
mpcPublicKey: addr is edAddr
4) swapin
iotaAddr:chainID
5) swapOut
go run ./tokens/iota/tools/sendTransaction/main.go -n https://api.lb-0.h.chrysalis-devnet.iota.cafe -publicKey ae67243f1d58f57188335adc29a98e856e46c0cc38bd63558d6636fcd0eccc03 -privKey 4023b0cc68bff18b8ae595b3a1f315f925d187b083ffcdee5051a70086bbec0cae67243f1d58f57188335adc29a98e856e46c0cc38bd63558d6636fcd0eccc03 -to [mpcIotaAddr] -index swapOut -data 0x1739648E7C1B23D6Da74177292B36aF7f286f643:4 -value 1000000

Documentation

Index

Constants

View Source
const (
	KeepAlive uint64 = 1000000
)
View Source
const (
	SWAPOUT = "swapOut"
)

Variables

This section is empty.

Functions

func Bech32ToEdAddr

func Bech32ToEdAddr(bech32 string) (*iotago.Address, error)

func CheckBalance

func CheckBalance(url string, edAddr *iotago.Ed25519Address, amount uint64) (uint64, error)

func CommitMessage

func CommitMessage(url string, message *iotago.Message) (string, error)

func ConvertMessageID

func ConvertMessageID(txHash string) ([32]byte, error)

func ConvertPubKeyToAddr

func ConvertPubKeyToAddr(addrPubKey string) *iotago.Ed25519Address

func ConvertStringToAddress

func ConvertStringToAddress(edAddr string) *iotago.Ed25519Address

func GetLatestBlockNumber

func GetLatestBlockNumber(url string) (uint64, error)

func GetOutPutByID

func GetOutPutByID(url string, outputID iotago.UTXOInputID, needValue uint64, finish bool) (*iotago.UTXOInput, uint64, uint64, error)

func GetOutPutIDs

func GetOutPutIDs(url string, edAddr *iotago.Ed25519Address) ([]iotago.OutputIDHex, error)

func GetStubChainID

func GetStubChainID(network string) *big.Int

GetStubChainID get stub chainID

func GetTransactionByHash

func GetTransactionByHash(url string, msgID [32]byte) (*iotago.Message, error)

func GetTransactionMetadata

func GetTransactionMetadata(url string, msgID [32]byte) (*iotago.MessageMetadataResponse, error)

func ParseIndexPayload

func ParseIndexPayload(payload Payload) (string, string, error)

func ProofOfWork

func ProofOfWork(url string, message *iotago.MessageBuilder) (*iotago.Message, error)

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 Address

type Address struct {
	Type    uint64 `json:"type"`
	Address string `json:"address"`
}

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

func (b *Bridge) CheckBalance(edAddr *iotago.Ed25519Address, amount uint64) (uint64, error)

GetTransactionStatus impl

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

func (b *Bridge) GetOutPutByID(id iotago.OutputIDHex, needValue uint64, finish bool) (*iotago.UTXOInput, uint64, uint64, error)

func (*Bridge) GetOutPutIDs

func (b *Bridge) GetOutPutIDs(addr *iotago.Ed25519Address) ([]iotago.OutputIDHex, error)

GetTxBlockInfo impl NonceSetter interface

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 *iotago.Message, err error)

GetTransactionByHash call eth_getTransactionByHash

func (*Bridge) GetTransactionMetadata

func (b *Bridge) GetTransactionMetadata(txHash string) (txRes *iotago.MessageMetadataResponse, err error)

GetTransactionByHash call eth_getTransactionByHash

func (*Bridge) GetTransactionStatus

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

GetTransactionStatus impl

func (*Bridge) InitRouterInfo

func (b *Bridge) InitRouterInfo(routerContract string, 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) ParseMessagePayload

func (b *Bridge) ParseMessagePayload(swapInfo *tokens.SwapTxInfo, payload []byte) error

func (*Bridge) ProofOfWork

func (b *Bridge) ProofOfWork(messageBuilder *iotago.MessageBuilder) (*iotago.Message, error)

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

type Essence struct {
	Type    uint64   `json:"type"`
	Inputs  []Input  `json:"inputs"`
	Outputs []Output `json:"outputs"`
	Payload Payload  `json:"payload"`
}

type Input

type Input struct {
	Type                   uint64 `json:"type"`
	TransactionId          string `json:"transactionId"`
	TransactionOutputIndex uint64 `json:"transactionOutputIndex"`
}

type MessageBuilder

type MessageBuilder struct {
	TransactionBuilder *iotago.TransactionBuilder `json:"transactionBuilder"`
	Essence            *iotago.TransactionEssence `json:"essence"`
}

func BuildMessage

func BuildMessage(inputs []*iotago.ToBeSignedUTXOInput, outputs []*iotago.SigLockedSingleOutput, indexationPayload *iotago.Indexation) *MessageBuilder

func NewMessageBuilder

func NewMessageBuilder() *MessageBuilder

type MessagePayload

type MessagePayload struct {
	Type    uint64  `json:"type"`
	Essence Essence `json:"essence"`
}

type Output

type Output struct {
	Type    uint64  `json:"type"`
	Address Address `json:"address"`
	Amount  uint64  `json:"amount"`
}

type Payload

type Payload struct {
	Type  uint64 `json:"type"`
	Index string `json:"index"`
	Data  string `json:"data"`
}

type RawType

type RawType struct {
	Type    uint64  `json:"type"`
	Address Address `json:"address"`
	Amount  uint64  `json:"amount"`
}

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

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