Versions in this module Expand all Collapse all v0 v0.3.10 Nov 26, 2021 Changes in this version + const AggregateMemo + const LockMemoPrefix + const MaxPlusGasPricePercentage + const UnlockMemoPrefix + var AggregateIdentifier = "aggregate" + var DstBridge CrossChainBridge + var DstForkChecker ForkChecker + var DstLatestBlockHeight uint64 + var DstNonceSetter NonceSetter + var DstStableConfirmations uint64 + var ErrAddressIsInBlacklist = errors.New("address is in black list") + var ErrBindAddrIsContract = errors.New("bind address is contract") + var ErrBindAddressMismatch = errors.New("bind address mismatch") + var ErrBridgeDestinationNotSupported = errors.New("bridge destination not supported") + var ErrBridgeSourceNotSupported = errors.New("bridge source not supported") + var ErrBuildSwapTxInWrongEndpoint = errors.New("build swap in/out tx in wrong endpoint") + var ErrDepositLogNotFound = errors.New("deposit log not found or removed") + var ErrEstimateGasFailed = errors.New("estimate gas failed") + var ErrMissTokenPrice = errors.New("miss token price") + var ErrMsgHashMismatch = errors.New("message hash mismatch") + var ErrNoBtcBridge = errors.New("no btc bridge exist") + var ErrRPCQueryError = errors.New("rpc query error") + var ErrSwapIsClosed = errors.New("swap is closed") + var ErrSwapTypeNotSupported = errors.New("swap type not supported in this endpoint") + var ErrSwapoutLogNotFound = errors.New("swapout log not found or removed") + var ErrTodo = errors.New("developing: TODO") + var ErrTxBeforeInitialHeight = errors.New("transaction before initial block height") + var ErrTxFuncHashMismatch = errors.New("tx func hash mismatch") + var ErrTxIncompatible = errors.New("tx incompatible") + var ErrTxIsAggregateTx = errors.New("tx is aggregate tx") + var ErrTxNotFound = errors.New("tx not found") + var ErrTxNotStable = errors.New("tx not stable") + var ErrTxSenderNotRegistered = errors.New("tx sender not registered") + var ErrTxWithWrongContract = errors.New("tx with wrong contract") + var ErrTxWithWrongInput = errors.New("tx with wrong input data") + var ErrTxWithWrongLogData = errors.New("tx with wrong log data") + var ErrTxWithWrongMemo = errors.New("tx with wrong memo") + var ErrTxWithWrongReceipt = errors.New("tx with wrong receipt") + var ErrTxWithWrongReceiver = errors.New("tx with wrong receiver") + var ErrTxWithWrongSender = errors.New("tx with wrong sender") + var ErrTxWithWrongValue = errors.New("tx with wrong value") + var ErrUnknownPairID = errors.New("unknown pair ID") + var ErrUnknownSwapType = errors.New("unknown swap type") + var ErrWrongCountOfMsgHashes = errors.New("wrong count of msg hashed") + var ErrWrongExtraArgs = errors.New("wrong extra args") + var ErrWrongP2shBindAddress = errors.New("wrong p2sh bind address") + var ErrWrongRawTx = errors.New("wrong raw tx") + var ErrWrongSwapValue = errors.New("wrong swap value") + var ErrWrongSwapinTxType = errors.New("wrong swapin tx type") + var IsDcrmDisabled bool + var SrcBridge CrossChainBridge + var SrcForkChecker ForkChecker + var SrcLatestBlockHeight uint64 + var SrcNonceSetter NonceSetter + var SrcStableConfirmations uint64 + var TokenPriceCfg *TokenPriceConfig + func CalcSwappedValue(pairID string, value *big.Int, isSrc bool, from, txto string) *big.Int + func CheckSwapValue(inf *TxSwapInfo, isSrc bool) bool + func CmpAndSetLatestBlockHeight(latest uint64, isSrc bool) + func FromBits(value *big.Int, decimals uint8) float64 + func GetAllPairIDs() []string + func GetBigValueThreshold(pairID string, isSrc bool) *big.Int + func GetStableConfirmations(isSrc bool) uint64 + func GetTokenPairsConfig() map[string]*TokenPairConfig + func GetTokenPairsDir() string + func IsTokenPairExist(pairID string) bool + func LoadTokenPairsConfig(check bool) + func LoadTokenPairsConfigInDir(dir string, check bool) (map[string]*TokenPairConfig, error) + func SetLatestBlockHeight(latest uint64, isSrc bool) + func SetTokenPairsConfig(pairsConfig map[string]*TokenPairConfig, check bool) + func SetTokenPairsDir(dir string) + func ShouldRegisterSwapForError(err error) bool + func ToBits(value float64, decimals uint8) *big.Int + type AllExtras struct + BtcExtra *BtcExtraArgs + EthExtra *EthExtraArgs + ReplaceNum uint64 + type BlockExtraArgs struct + CoreAPIs []BlocknetCoreAPIArgs + UTXOAPIAddresses []string + type BlocknetCoreAPIArgs struct + APIAddress string + DisableTLS bool + RPCPassword string + RPCUser string + type BtcExtraArgs struct + ChangeAddress *string + PreviousOutPoints []*BtcOutPoint + RelayFeePerKb *int64 + type BtcExtraConfig struct + EstimateFeeBlocks int + MaxRelayFeePerKb int64 + MinRelayFee int64 + MinRelayFeePerKb int64 + PlusFeePercentage uint64 + UtxoAggregateMinCount int + UtxoAggregateMinValue uint64 + UtxoAggregateToAddress string + type BtcOutPoint struct + Hash string + Index uint32 + type BuildTxArgs struct + Extra *AllExtras + From string + Input *[]byte + Memo string + OriginFrom string + OriginTxTo string + OriginValue *big.Int + SwapValue *big.Int + To string + Value *big.Int + func (args *BuildTxArgs) GetExtraArgs() *BuildTxArgs + func (args *BuildTxArgs) GetReplaceNum() uint64 + func (args *BuildTxArgs) GetTxGasPrice() *big.Int + func (args *BuildTxArgs) GetTxNonce() uint64 + func (args *BuildTxArgs) SetTxNonce(nonce uint64) + type ChainConfig struct + BaseFeePercent int64 + BaseGasPrice string + BlockChain string + BlockCountFeeHistory int + CallByContractWhitelist []string + Confirmations *uint64 + EnableCheckTxBlockHash bool + EnableCheckTxBlockIndex bool + EnableDynamicFeeTx bool + EnablePassBigValue bool + EnableReplaceSwap bool + EnableScan bool + EnableScanPool bool + FixedGasPrice string + InitialHeight *uint64 + MaxGasFeeCap string + MaxGasPrice string + MaxGasPriceFluctPercent uint64 + MaxGasTipCap string + MaxReplaceCount int + MinGasPrice string + MinReserveFee string + NetID string + PlusGasFeeCapPercent uint64 + PlusGasTipCapPercent uint64 + ReplacePlusGasPricePercent uint64 + WaitTimeToReplace int64 + func (c *ChainConfig) CheckConfig(isServer bool) error + func (c *ChainConfig) GetChainID() *big.Int + func (c *ChainConfig) GetFixedGasPrice() *big.Int + func (c *ChainConfig) GetMaxGasFeeCap() *big.Int + func (c *ChainConfig) GetMaxGasPrice() *big.Int + func (c *ChainConfig) GetMaxGasTipCap() *big.Int + func (c *ChainConfig) GetMinGasPrice() *big.Int + func (c *ChainConfig) GetMinReserveFee() *big.Int + func (c *ChainConfig) IsFixedGasPrice() bool + func (c *ChainConfig) IsInCallByContractWhitelist(caller string) bool + func (c *ChainConfig) SetChainID(chainID *big.Int) + type CrossChainBridge interface + BuildRawTransaction func(args *BuildTxArgs) (rawTx interface{}, err error) + DcrmSignTransaction func(rawTx interface{}, args *BuildTxArgs) (signedTx interface{}, txHash string, err error) + GetBalance func(accountAddress string) (*big.Int, error) + GetChainConfig func() *ChainConfig + GetGatewayConfig func() *GatewayConfig + GetLatestBlockNumber func() (uint64, error) + GetLatestBlockNumberOf func(apiAddress string) (uint64, error) + GetTokenBalance func(tokenType, tokenAddress, accountAddress string) (*big.Int, error) + GetTokenConfig func(pairID string) *TokenConfig + GetTokenSupply func(tokenType, tokenAddress string) (*big.Int, error) + GetTransaction func(txHash string) (interface{}, error) + GetTransactionStatus func(txHash string) (*TxStatus, error) + IsSrcEndpoint func() bool + IsValidAddress func(address string) bool + SendTransaction func(signedTx interface{}) (txHash string, err error) + SetChainAndGateway func(*ChainConfig, *GatewayConfig) + SignTransaction func(rawTx interface{}, pairID string) (signedTx interface{}, txHash string, err error) + VerifyMsgHash func(rawTx interface{}, msgHash []string) error + VerifyTokenConfig func(*TokenConfig) error + VerifyTransaction func(pairID, txHash string, allowUnstable bool) (*TxSwapInfo, error) + func GetCrossChainBridge(isSrc bool) CrossChainBridge + type CrossChainBridgeBase struct + ChainConfig *ChainConfig + GatewayConfig *GatewayConfig + IsSrc bool + func NewCrossChainBridgeBase(isSrc bool) *CrossChainBridgeBase + func (b *CrossChainBridgeBase) GetChainConfig() *ChainConfig + func (b *CrossChainBridgeBase) GetDcrmPublicKey(pairID string) string + func (b *CrossChainBridgeBase) GetGatewayConfig() *GatewayConfig + func (b *CrossChainBridgeBase) GetTokenConfig(pairID string) *TokenConfig + func (b *CrossChainBridgeBase) IsSrcEndpoint() bool + func (b *CrossChainBridgeBase) SetChainAndGateway(chainCfg *ChainConfig, gatewayCfg *GatewayConfig) + type EthExtraArgs struct + Gas *uint64 + GasFeeCap *big.Int + GasPrice *big.Int + GasTipCap *big.Int + Nonce *uint64 + type ForkChecker interface + GetBlockHashOf func(urls []string, height uint64) (hash string, err error) + func GetForkChecker(isSrc bool) ForkChecker + type GatewayConfig struct + APIAddress []string + APIAddressExt []string + Extras *GatewayExtras + type GatewayExtras struct + BlockExtra *BlockExtraArgs + type NonceSetter interface + AdjustNonce func(pairID string, value uint64) (nonce uint64) + GetPoolNonce func(address, height string) (uint64, error) + GetTxBlockInfo func(txHash string) (blockHeight, blockTime uint64) + InitNonces func(nonces map[string]uint64) + SetNonce func(pairID string, value uint64) + func GetNonceSetter(isSrc bool) NonceSetter + type P2shAddressInfo struct + BindAddress string + P2shAddress string + RedeemScript string + RedeemScriptDisasm string + type SwapInfo struct + Bind string + Identifier string + PairID string + Reswapping bool + SwapID string + SwapType SwapType + TxType SwapTxType + func (s *SwapInfo) IsSwapin() bool + type SwapTxType uint32 + const P2shSwapinTx + const SwapinTx + const SwapoutTx + func (s SwapTxType) String() string + type SwapType uint32 + const NoSwapType + const SwapinType + const SwapoutType + func (s SwapType) String() string + type TokenConfig struct + AllowSwapinFromContract bool + AllowSwapoutFromContract bool + BigValueThreshold *float64 + BigValueWhitelist []string + ContractAddress string + ContractCodeHash string + DcrmAddress string + DcrmAddressKeyFile string + DcrmAddressKeyStore string + DcrmAddressPassword string + DcrmPubkey string + Decimals *uint8 + DefaultGasLimit uint64 + DelegateToken string + DepositAddress string + Description string + DisableSwap bool + ID string + IsAnyswapAdapter bool + IsDelegateContract bool + IsMappingTokenProxy bool + MaximumSwap *float64 + MaximumSwapFee *float64 + MinimumSwap *float64 + MinimumSwapFee *float64 + Name string + PlusGasPricePercentage uint64 + SwapFeeRate *float64 + Symbol string + TokenPrice float64 + func FindTokenConfig(address string, isSrc bool) (configs []*TokenConfig, pairIDs []string) + func GetTokenConfig(pairID string, isSrc bool) *TokenConfig + func GetTokenConfigsByDirection(pairID string, isSwapin bool) (fromTokenConfig, toTokenConfig *TokenConfig) + func (c *TokenConfig) CalcAndStoreValue() + func (c *TokenConfig) CheckConfig(isSrc bool) (err error) + func (c *TokenConfig) GetDcrmAddressPrivateKey() *ecdsa.PrivateKey + func (c *TokenConfig) IsErc20() bool + func (c *TokenConfig) IsInBigValueWhitelist(caller string) bool + func (c *TokenConfig) IsProxyErc20() bool + func (c *TokenConfig) LoadDcrmAddressPrivateKey() error + func (c *TokenConfig) VerifyDcrmPublicKey() error + type TokenPairConfig struct + DestToken *TokenConfig + PairID string + SrcToken *TokenConfig + func AddPairConfig(configFile string) (pairConfig *TokenPairConfig, err error) + func GetTokenPairConfig(pairID string) *TokenPairConfig + func (c *TokenPairConfig) CheckConfig() (err error) + type TokenPriceConfig struct + APIAddress []string + Contract string + type TxStatus struct + BlockHash string + BlockHeight uint64 + BlockTime uint64 + Confirmations uint64 + Receipt interface{} + func (s *TxStatus) IsSwapTxOnChainAndFailed(token *TokenConfig) bool + type TxSwapInfo struct + Bind string + From string + Hash string + Height uint64 + PairID string + Timestamp uint64 + To string + TxTo string + Value *big.Int v0.3.9-1 Nov 26, 2021