Documentation ¶
Index ¶
- Constants
- Variables
- func AddTransactionChainingKeyCache(txhash string, txIns *[]UtxoKey)
- func ClearTransactionChainingKeyCache(txhash string)
- func GetStubChainID(network string) *big.Int
- func GetUtxosByAddress(url, address string) (*[]Output, error)
- func NewNode(network cardanosdk.Network, networkUrl string, projectID string) cardanosdk.Node
- func StringToPrivateKey(priv string) (*ed25519.PrivateKey, error)
- func SupportsChainID(chainID *big.Int) bool
- type Asset
- type AssetsMap
- type Block
- type BlockfrostNode
- func (b *BlockfrostNode) GetTransactionByHash(txHash string) (*blockfrost.TransactionContent, error)
- func (b *BlockfrostNode) GetTransactionMetadataByHash(txHash string) (*[]blockfrost.TransactionMetadata, error)
- func (b *BlockfrostNode) GetTransactionUtxoByHash(txHash string) (*blockfrost.TransactionUTXOs, error)
- func (b *BlockfrostNode) Network() cardanosdk.Network
- func (b *BlockfrostNode) ProtocolParams() (*cardanosdk.ProtocolParams, error)
- func (b *BlockfrostNode) SubmitTx(tx *cardanosdk.Tx) (*cardanosdk.Hash32, error)
- func (b *BlockfrostNode) Tip() (*cardanosdk.NodeTip, error)
- func (b *BlockfrostNode) UTxOs(addr cardanosdk.Address) ([]cardanosdk.UTxO, error)
- type Bridge
- func (b *Bridge) AggregateTx() (txHash string, err error)
- func (b *Bridge) AppendSignature(tx *cardanosdk.Tx, pubKey crypto.PubKey, signature []byte)
- 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) CreateRawTx(rawTransaction *RawTransaction, mpcAddr string) (*cardanosdk.Tx, error)
- func (b *Bridge) CreateSwapoutRawTx(rawTransaction *RawTransaction, mpcAddr, bind, toChainId string) (*cardanosdk.Tx, error)
- func (b *Bridge) GetAssetPolicy(name string) (crypto.XPrvKey, cardanosdk.NativeScript, cardanosdk.PolicyID)
- func (b *Bridge) GetCurrentThreshold() (*uint64, error)
- func (b *Bridge) GetLatestBlockNumber() (num uint64, err error)
- func (b *Bridge) GetLatestBlockNumberOf(url string) (num uint64, err error)
- func (b *Bridge) GetTip() (tip *cardanosdk.NodeTip, 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) InitAfterConfig()
- func (b *Bridge) InitRouterInfo(routerContract, routerVersion string) (err error)
- func (b *Bridge) IsValidAddress(addr string) bool
- func (b *Bridge) MPCSignSwapTransaction(rawTx interface{}, args *tokens.BuildTxArgs, bind, toChainId string) (signTx interface{}, txHash string, err error)
- 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) QueryUtxoByAPI(address string) (map[UtxoKey]AssetsMap, error)
- func (b *Bridge) QueryUtxoByGQL(address string) (map[UtxoKey]AssetsMap, error)
- func (b *Bridge) QueryUtxoOnChain(address string) (map[UtxoKey]AssetsMap, error)
- func (b *Bridge) QueryUtxoOnChainByAsset(address string, asset 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(tx *cardanosdk.Tx, rawTransaction *RawTransaction, args *tokens.BuildTxArgs, ...) (*SignedTransaction, string, error)
- func (b *Bridge) VerifyAggregate(msgHash []string, args *tokens.BuildTxArgs) error
- func (b *Bridge) VerifyMPCPubKey(mpcAddress, mpcPubkey 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 Epoch
- type Input
- type Metadata
- type MetadataValue
- type NodeTip
- type Output
- type OutputsResult
- type ProtocolParams
- type RawTransaction
- type SignedTransaction
- type Tip
- type TipInfo
- type TipResponse
- type Token
- type Transaction
- type TransactionChainingKey
- type TransactionChainingMap
- type TransactionResult
- type UtxoKey
Constants ¶
const ( CardanoMainNet = "https://cardano-mainnet.blockfrost.io/api/v0" CardanoTestNet = "https://cardano-testnet.blockfrost.io/api/v0" CardanoPreProd = "https://cardano-preprod.blockfrost.io/api/v0" CardanoPreview = "https://cardano-preview.blockfrost.io/api/v0" IPFSNet = "https://ipfs.blockfrost.io/api/v0" )
const ( MetadataKey = "123" SwapInMetadataKey = "223" )
const (
AdaAsset = "lovelace"
)
Variables ¶
var ( FixAdaAmount = big.NewInt(1500000) DefaultAdaAmount = big.NewInt(2000000) QueryTransaction = "" /* 259-byte string literal not displayed */ QueryOutputs = "{utxos(where: { address: { _eq: \"%s\"}}) {txHash index tokens {asset {policyId assetName} quantity} value}}" QueryTIPAndProtocolParams = "" /* 193-byte string literal not displayed */ TransactionChaining = &TransactionChainingMap{InputKey: UtxoKey{}, AssetsMap: make(map[string]string)} TransactionChainingKeyCache = &TransactionChainingKey{SpentUtxoMap: make(map[UtxoKey]bool), SpentUtxoListGropByTxHash: make(map[string]*[]UtxoKey)} )
Functions ¶
func ClearTransactionChainingKeyCache ¶
func ClearTransactionChainingKeyCache(txhash string)
func GetUtxosByAddress ¶
func NewNode ¶
func NewNode(network cardanosdk.Network, networkUrl string, projectID string) cardanosdk.Node
NewNode returns a new instance of BlockfrostNode.
func StringToPrivateKey ¶
func StringToPrivateKey(priv string) (*ed25519.PrivateKey, error)
Types ¶
type BlockfrostNode ¶
type BlockfrostNode struct {
// contains filtered or unexported fields
}
BlockfrostNode implements Node using the blockfrost API.
func (*BlockfrostNode) GetTransactionByHash ¶
func (b *BlockfrostNode) GetTransactionByHash(txHash string) (*blockfrost.TransactionContent, error)
func (*BlockfrostNode) GetTransactionMetadataByHash ¶
func (b *BlockfrostNode) GetTransactionMetadataByHash(txHash string) (*[]blockfrost.TransactionMetadata, error)
func (*BlockfrostNode) GetTransactionUtxoByHash ¶
func (b *BlockfrostNode) GetTransactionUtxoByHash(txHash string) (*blockfrost.TransactionUTXOs, error)
func (*BlockfrostNode) Network ¶
func (b *BlockfrostNode) Network() cardanosdk.Network
func (*BlockfrostNode) ProtocolParams ¶
func (b *BlockfrostNode) ProtocolParams() (*cardanosdk.ProtocolParams, error)
func (*BlockfrostNode) SubmitTx ¶
func (b *BlockfrostNode) SubmitTx(tx *cardanosdk.Tx) (*cardanosdk.Hash32, error)
func (*BlockfrostNode) Tip ¶
func (b *BlockfrostNode) Tip() (*cardanosdk.NodeTip, error)
func (*BlockfrostNode) UTxOs ¶
func (b *BlockfrostNode) UTxOs(addr cardanosdk.Address) ([]cardanosdk.UTxO, error)
type Bridge ¶
type Bridge struct { *tokens.CrossChainBridgeBase *base.ReSwapableBridgeBase RpcClient cardanosdk.Node FakePrikey crypto.PrvKey ProtocolParams *cardanosdk.ProtocolParams }
Bridge block bridge inherit from btc bridge
func (*Bridge) AggregateTx ¶
func (*Bridge) AppendSignature ¶
func (*Bridge) BuildAggregateTx ¶
func (*Bridge) BuildRawTransaction ¶
func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
BuildRawTransaction build raw tx
func (*Bridge) CreateRawTx ¶
func (b *Bridge) CreateRawTx(rawTransaction *RawTransaction, mpcAddr string) (*cardanosdk.Tx, error)
func (*Bridge) CreateSwapoutRawTx ¶
func (b *Bridge) CreateSwapoutRawTx(rawTransaction *RawTransaction, mpcAddr, bind, toChainId string) (*cardanosdk.Tx, error)
func (*Bridge) GetAssetPolicy ¶
func (b *Bridge) GetAssetPolicy(name string) (crypto.XPrvKey, cardanosdk.NativeScript, cardanosdk.PolicyID)
func (*Bridge) GetCurrentThreshold ¶
func (*Bridge) GetLatestBlockNumber ¶
GetLatestBlockNumber gets latest block number
func (*Bridge) GetLatestBlockNumberOf ¶
GetLatestBlockNumberOf gets latest block number from single api
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) InitAfterConfig ¶
func (b *Bridge) InitAfterConfig()
InitAfterConfig init variables (ie. extra members) after loading config
func (*Bridge) InitRouterInfo ¶
InitRouterInfo init router info
func (*Bridge) IsValidAddress ¶
IsValidAddress check address
func (*Bridge) MPCSignSwapTransaction ¶
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) QueryUtxoByAPI ¶
func (*Bridge) QueryUtxoByGQL ¶
func (*Bridge) QueryUtxoOnChain ¶
func (*Bridge) QueryUtxoOnChainByAsset ¶
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(tx *cardanosdk.Tx, rawTransaction *RawTransaction, args *tokens.BuildTxArgs, privKey string) (*SignedTransaction, string, error)
SignTransactionWithPrivateKey sign tx with ECDSA private key
func (*Bridge) VerifyAggregate ¶
func (b *Bridge) VerifyAggregate(msgHash []string, args *tokens.BuildTxArgs) error
func (*Bridge) VerifyMPCPubKey ¶
VerifyMPCPubKey verify mpc address and public key is matching
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) VerifyAggregate(msgHash []string, args *tokens.BuildTxArgs) error }
BridgeInterface btc bridge interface
var BridgeInstance BridgeInterface
BridgeInstance btc bridge instance
type Epoch ¶
type Epoch struct { Number uint64 `json:"number"` ProtocolParams ProtocolParams `json:"protocolParams"` }
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 ProtocolParams ¶
type ProtocolParams struct { CoinsPerUtxoByte uint64 `json:"coinsPerUtxoByte"` KeyDeposit uint64 `json:"keyDeposit"` MaxBlockBodySize uint64 `json:"maxBlockBodySize"` MaxBlockExMem string `json:"maxBlockExMem"` MaxTxSize uint64 `json:"maxTxSize"` MaxValSize string `json:"maxValSize"` MinFeeA uint64 `json:"minFeeA"` MinFeeB uint64 `json:"minFeeB"` MinPoolCost uint64 `json:"minPoolCost"` MinUTxOValue uint64 `json:"minUTxOValue"` }
type RawTransaction ¶
type RawTransaction struct { // Fee string `json:"fee"` TxIns []UtxoKey `json:"txIns"` TxInsAssets []AssetsMap `json:"txInsAssets"` TxOuts map[string]AssetsMap `json:"txOuts"` Mint AssetsMap `json:"mint"` TxIndex uint64 `json:"txIndex"` SwapId string `json:"swapId"` KeyDeposit uint64 `json:"keyDeposit"` CoinsPerUTXOWord uint64 `json:"coinsPerUTXOWord"` MinFeeA uint64 `json:"minFeeA"` MinFeeB uint64 `json:"minFeeB"` Slot uint64 `json:"slot"` }
func (*RawTransaction) ProtoMessage ¶
func (*RawTransaction) ProtoMessage()
type SignedTransaction ¶
type TipResponse ¶
type TipResponse struct {
Cardano NodeTip `json:"cardano"`
}
func GetCardanoTip ¶
func GetCardanoTip(url string) (*TipResponse, error)
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"`
}