Documentation ¶
Index ¶
- Constants
- Variables
- func AddTransactionChainingKeyCache(txhash string, txIns *[]UtxoKey)
- func CalcMinFee(rawTransaction *RawTransaction) (string, error)
- func CalcTxId(txPath string) (string, error)
- func ClearTransactionChainingKeyCache(txhash string)
- func CreateRawTx(rawTransaction *RawTransaction, mpcAddr string) error
- func ExecCmd(cmdStr, space string) (string, error)
- func GetLatestBlockNumber() (uint64, error)
- func GetStubChainID(network string) *big.Int
- func GetUtxosByAddress(url, address string) (*[]Output, error)
- func StringToPrivateKey(priv string) (*ed25519.PrivateKey, error)
- func SupportsChainID(chainID *big.Int) bool
- func VerifyMPCPubKey(mpcAddress, mpcPubkey string) error
- type Asset
- type AssetsMap
- type Block
- type Bridge
- func (b *Bridge) AggregateTx() (txHash string, err error)
- func (b *Bridge) BuildAggregateTx(swapId string, utxos map[UtxoKey]AssetsMap) (*RawTransaction, error)
- func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
- func (b *Bridge) BuildTx(swapId, receiver, assetId string, amount *big.Int, utxos map[UtxoKey]AssetsMap) (*RawTransaction, error)
- func (b *Bridge) CreateWitness(witnessPath, mpcPublicKey string, sig []byte) error
- func (b *Bridge) GetLatestBlockNumber() (num uint64, err error)
- func (b *Bridge) GetLatestBlockNumberOf(url string) (num uint64, err error)
- func (b *Bridge) GetPoolNonce(address, _height string) (uint64, error)
- func (b *Bridge) GetSeq(args *tokens.BuildTxArgs) (nonceptr *uint64, err error)
- func (b *Bridge) GetTransaction(txHash string) (tx interface{}, err error)
- func (b *Bridge) GetTransactionByHash(txHash string) (*Transaction, error)
- func (b *Bridge) GetTransactionChainingMap(assetName string, amount *big.Int) (map[UtxoKey]AssetsMap, error)
- func (b *Bridge) GetTransactionStatus(txHash string) (status *tokens.TxStatus, err error)
- func (b *Bridge) GetUtxosByAddress(address string) (*[]Output, error)
- func (b *Bridge) InitRouterInfo(routerContract, routerVersion string) (err error)
- func (b *Bridge) IsValidAddress(addr string) bool
- func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signTx interface{}, txHash string, err error)
- func (b *Bridge) PublicKeyToAddress(pubKeyHex string) (string, error)
- func (b *Bridge) QueryUtxo(address, assetName string, amount *big.Int) (map[UtxoKey]AssetsMap, error)
- func (b *Bridge) QueryUtxoOnChain(address string) (map[UtxoKey]AssetsMap, error)
- func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
- func (b *Bridge) SendTransaction(signedTx interface{}) (string, error)
- func (b *Bridge) SetTokenConfig(tokenAddr string, tokenCfg *tokens.TokenConfig)
- func (b *Bridge) SignAggregateTx(swapId string, rawTx interface{}) (string, error)
- func (b *Bridge) SignTransactionWithPrivateKey(txInputs []UtxoKey, txIndex uint64, assetsMap AssetsMap, ...) (*SignedTransaction, string, error)
- func (b *Bridge) SignTx(rawTxPath, witnessPath, signedPath string) error
- func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHashes []string) (err error)
- func (b *Bridge) VerifyRawTransaction(raw *RawTransaction, args *tokens.BuildTxArgs) error
- func (b *Bridge) VerifyTokenConfig(tokenCfg *tokens.TokenConfig) error
- func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
- type BridgeInterface
- type Input
- type Metadata
- type MetadataValue
- type Output
- type OutputsResult
- type RawTransaction
- type SignedTransaction
- type Tip
- type Token
- type Transaction
- type TransactionChainingKey
- type TransactionChainingMap
- type TransactionResult
- type UtxoKey
Constants ¶
const ( NetWork = "--mainnet" // for testnet, use "--testnet-magic 1" MPCPolicyId = "f73d0275b986a17537f0dfa94060313f922ac1d7a81aec677fa3bdbe" RawPath = "txDb/raw/" AdaAsset = "lovelace" RawSuffix = ".raw" WitnessPath = "txDb/witness/" WitnessSuffix = ".witness" WitnessType = "TxWitness AlonzoEra" SignedPath = "txDb/signed/" SignedSuffix = ".signed" )
const (
MetadataKey = "123"
)
Variables ¶
var ( FixAdaAmount = big.NewInt(1500000) DefaultAdaAmount = big.NewInt(2000000) AddressInfoCmd = "cardano-cli address info --address %s" AssembleCmd = "cardano-cli transaction assemble --tx-body-file %s --witness-file %s --out-file %s" SubmitCmd = "cardano-cli transaction submit --tx-file %s " + NetWork BuildRawTxWithoutMintCmd = "cardano-cli transaction build-raw --fee %s%s%s --out-file %s" BuildRawTxWithMintCmd = "cardano-cli transaction build-raw --fee %s%s%s%s --out-file %s --mint-script-file txDb/policy/policy.script" CalcMinFeeCmd = "cardano-cli transaction calculate-min-fee --tx-body-file %s --tx-in-count %d --tx-out-count %d --witness-count 1 --protocol-params-file txDb/config/protocol.json " + NetWork CalcTxIdCmd = "cardano-cli transaction txid --tx-body-file %s" QueryTipCmd = "cardano-cli query tip " + NetWork QueryTransaction = "" /* 259-byte string literal not displayed */ QueryOutputs = "{utxos(where: { address: { _eq: \"%s\"}}) {txHash index tokens {asset {policyId assetName} quantity} value}}" TransactionChaining = &TransactionChainingMap{InputKey: UtxoKey{}, AssetsMap: make(map[string]string)} TransactionChainingKeyCache = &TransactionChainingKey{SpentUtxoMap: make(map[UtxoKey]bool), SpentUtxoListGropByTxHash: make(map[string]*[]UtxoKey)} )
Functions ¶
func CalcMinFee ¶
func CalcMinFee(rawTransaction *RawTransaction) (string, error)
func ClearTransactionChainingKeyCache ¶
func ClearTransactionChainingKeyCache(txhash string)
func CreateRawTx ¶
func CreateRawTx(rawTransaction *RawTransaction, mpcAddr string) error
func GetLatestBlockNumber ¶
func GetUtxosByAddress ¶
func StringToPrivateKey ¶
func StringToPrivateKey(priv string) (*ed25519.PrivateKey, error)
func VerifyMPCPubKey ¶
VerifyMPCPubKey verify mpc address and public key is matching
Types ¶
type Bridge ¶
type Bridge struct { *base.NonceSetterBase RPCClientTimeout int }
Bridge block bridge inherit from btc bridge
func (*Bridge) AggregateTx ¶
func (*Bridge) BuildAggregateTx ¶
func (*Bridge) BuildRawTransaction ¶
func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
BuildRawTransaction build raw tx
func (*Bridge) CreateWitness ¶
func (*Bridge) GetLatestBlockNumber ¶
GetLatestBlockNumber gets latest block number
func (*Bridge) GetLatestBlockNumberOf ¶
GetLatestBlockNumberOf gets latest block number from single api
func (*Bridge) GetPoolNonce ¶
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 ¶
GetTransaction impl
func (*Bridge) GetTransactionByHash ¶
func (b *Bridge) GetTransactionByHash(txHash string) (*Transaction, error)
GetTransactionByHash call eth_getTransactionByHash
func (*Bridge) GetTransactionChainingMap ¶
func (*Bridge) GetTransactionStatus ¶
GetTransactionStatus impl
func (*Bridge) GetUtxosByAddress ¶
GetTransactionByHash call eth_getTransactionByHash
func (*Bridge) InitRouterInfo ¶
InitRouterInfo init router info
func (*Bridge) IsValidAddress ¶
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 ¶
PublicKeyToAddress impl
func (*Bridge) QueryUtxoOnChain ¶
func (*Bridge) RegisterSwap ¶
func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
RegisterSwap api
func (*Bridge) SendTransaction ¶
SendTransaction send signed tx
func (*Bridge) SetTokenConfig ¶
func (b *Bridge) SetTokenConfig(tokenAddr string, tokenCfg *tokens.TokenConfig)
SetTokenConfig set token config
func (*Bridge) SignAggregateTx ¶
func (*Bridge) SignTransactionWithPrivateKey ¶
func (b *Bridge) SignTransactionWithPrivateKey(txInputs []UtxoKey, txIndex uint64, assetsMap AssetsMap, txPath, witnessPath, signedPath, txHash, mpcPubkey, privKey string) (*SignedTransaction, string, error)
SignTransactionWithPrivateKey sign tx with ECDSA private key
func (*Bridge) VerifyMsgHash ¶
VerifyMsgHash verify msg hash
func (*Bridge) VerifyRawTransaction ¶
func (b *Bridge) VerifyRawTransaction(raw *RawTransaction, args *tokens.BuildTxArgs) error
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 BridgeInterface ¶
type BridgeInterface interface { tokens.IBridge QueryUtxoOnChain(address string) (map[UtxoKey]AssetsMap, error) BuildAggregateTx(swapId string, utxos map[UtxoKey]AssetsMap) (*RawTransaction, error) AggregateTx() (string, error) }
BridgeInterface btc bridge interface
var BridgeInstance BridgeInterface
BridgeInstance btc bridge instance
type Metadata ¶
type Metadata struct { Key string `json:"key"` Value MetadataValue `json:"value"` }
type MetadataValue ¶
type OutputsResult ¶
type OutputsResult struct {
Outputs []Output `json:"utxos"`
}
type RawTransaction ¶
type RawTransaction struct { Fee string `json:"fee"` TxIns []UtxoKey `json:"txIns"` TxOuts map[string]AssetsMap `json:"txOuts"` Mint AssetsMap `json:"mint"` TxIndex uint64 `json:"txIndex"` OutFile string `json:"outFile"` }
func (*RawTransaction) ProtoMessage ¶
func (*RawTransaction) ProtoMessage()
type SignedTransaction ¶
type Transaction ¶
type Transaction struct { Block Block `json:"block"` Hash string `json:"hash"` Metadata []Metadata `json:"metadata"` Inputs []Input `json:"inputs"` Outputs []Output `json:"outputs"` ValidContract bool `json:"validContract"` }
func GetTransactionByHash ¶
func GetTransactionByHash(url, txHash string) (*Transaction, error)
type TransactionChainingKey ¶
type TransactionChainingMap ¶
type TransactionResult ¶
type TransactionResult struct {
Transactions []Transaction `json:"transactions"`
}