Documentation
¶
Overview ¶
Package adapter 多主链适配器基础框架,提供交易构建、广播与区块扫描等核心能力。
子包划分:
- types — 数据类型与错误码(含 BlockHeader、TxExtractData、Balance 等扫块类型)
- wallet — 钱包数据访问:Wallet、WalletDAI、WalletDAIBase(供 flow/decoder 回调查询钱包/账户/地址等)
- decoder — 解码器:TransactionDecoder(transaction.go)、AddressDecoder(address.go)、SmartContractDecoder(contract.go,可选),各带 Base 基类;签名由外部 MPC 提供
- config — 链配置通用接口 Configer、MapConfig 与 JSON 解析(KVFromJSONFile、KVFromJSONContent),供 AssetsConfig.LoadAssetsConfig 复用
- chain — 链适配器 ChainAdapter 与注册表 RegAdapter/GetAdapter/GetTransactionDecoder/GetBlockScanner/GetAddressDecoder/GetSmartContractDecoder;AssetsConfig、SmartContractDecoder 可选
- flow — 构建与广播流程 BuildTransaction、BuildSummaryTransaction、SendTransaction(可传入 WalletDAI 回调查询)
- scanner — 区块扫描器 BlockScanner 与 Base(按高度扫块、持续循环、插队扫描、地址余额查询)
本包对上述子包做统一导出,便于调用方 import "github.com/godaddy-x/wallet-adapter" 使用。
使用示例:
decoder, _ := adapter.GetTransactionDecoder("BTC")
rawTx := &adapter.RawTransaction{ Coin: adapter.Coin{Symbol: "BTC"}, Account: account, To: map[string]string{toAddr: amount}, Required: 1 }
pendingTx, _ := adapter.BuildTransaction(decoder, wrapper, rawTx) // 入口为 flow,返回 PendingSignTx;wrapper 不可为 nil
tx, _ := adapter.SendTransaction(decoder, wrapper, pendingTx)
统一导出:types/wallet/decoder/config/chain/flow/scanner 的类型与函数,便于 import "github.com/godaddy-x/wallet-adapter" 一站式使用。 config 包(Configer、JSON 解析)需单独 import "github.com/godaddy-x/wallet-adapter/config" 使用,供 LoadAssetsConfig 等复用。
Index ¶
- Constants
- Variables
- func GetRandomSecure(l int) ([]byte, error)
- func ListSymbols() []string
- func RegAdapter(symbol string, a ChainAdapter)
- type ABIDAI
- type ABIInfo
- type AdapterError
- type Address
- type AddressDecoder
- type AddressDecoderBase
- type AssetsAccount
- type AssetsConfig
- type AssetsConfigBase
- type Balance
- type BalanceModelType
- type BalanceQueryFunc
- type BlockHeader
- type BlockScanTargetFunc
- type BlockScanner
- type BlockScannerBase
- type BlockchainSyncStatus
- type ChainAdapter
- type ChainAdapterBase
- type Coin
- type ContractReceiptItem
- type ExtractDataItem
- type FeesSupportAccount
- type KeySignature
- type PendingSignTx
- type RawTransaction
- type RawTransactionWithError
- type Recharge
- type ScanTarget
- type ScanTargetParam
- type ScanTargetResult
- type SmartContract
- type SmartContractCallResult
- type SmartContractDecoder
- type SmartContractDecoderBase
- type SmartContractEvent
- type SmartContractRawTransaction
- type SmartContractReceipt
- type SummaryRawTransaction
- type SymbolInfo
- type SymbolInfoBase
- type TokenBalance
- type Transaction
- type TransactionDecoder
- type TransactionDecoderBase
- type TxExtractData
- type TxInput
- type TxOutPut
- type UnscanRecord
- type WalletDAI
- type WalletDAIBase
Constants ¶
const ( TxStatusSuccess = types.TxStatusSuccess TxStatusFail = types.TxStatusFail BalanceModelTypeAddress = types.BalanceModelTypeAddress BalanceModelTypeAccount = types.BalanceModelTypeAccount ScanTargetTypeAccountAddress = types.ScanTargetTypeAccountAddress ScanTargetTypeAccountAlias = types.ScanTargetTypeAccountAlias ScanTargetTypeContractAddress = types.ScanTargetTypeContractAddress ScanTargetTypeContractAlias = types.ScanTargetTypeContractAlias ScanTargetTypeAddressPubKey = types.ScanTargetTypeAddressPubKey ScanTargetTypeAddressMemo = types.ScanTargetTypeAddressMemo // 智能合约 Raw 类型 TxRawTypeHex = types.TxRawTypeHex TxRawTypeJSON = types.TxRawTypeJSON TxRawTypeBase64 = types.TxRawTypeBase64 SmartContractCallResultStatusFail = types.SmartContractCallResultStatusFail SmartContractCallResultStatusSuccess = types.SmartContractCallResultStatusSuccess )
const ( ErrInsufficientBalanceOfAccount = types.ErrInsufficientBalanceOfAccount ErrInsufficientBalanceOfAddress = types.ErrInsufficientBalanceOfAddress ErrInsufficientFees = types.ErrInsufficientFees ErrDustLimit = types.ErrDustLimit ErrCreateRawTransactionFailed = types.ErrCreateRawTransactionFailed ErrSignRawTransactionFailed = types.ErrSignRawTransactionFailed ErrVerifyRawTransactionFailed = types.ErrVerifyRawTransactionFailed ErrSubmitRawTransactionFailed = types.ErrSubmitRawTransactionFailed ErrInsufficientTokenBalanceOfAddress = types.ErrInsufficientTokenBalanceOfAddress ErrAccountNotFound = types.ErrAccountNotFound ErrAddressNotFound = types.ErrAddressNotFound ErrContractNotFound = types.ErrContractNotFound ErrAddressEncodeFailed = types.ErrAddressEncodeFailed ErrAddressDecodeFailed = types.ErrAddressDecodeFailed ErrNonceInvalid = types.ErrNonceInvalid ErrCallFullNodeAPIFailed = types.ErrCallFullNodeAPIFailed ErrNetworkRequestFailed = types.ErrNetworkRequestFailed ErrUnknownException = types.ErrUnknownException ErrSystemException = types.ErrSystemException )
错误码
Variables ¶
var NewBlockScannerBase = scanner.NewBlockScannerBase
Functions ¶
func GetRandomSecure ¶
func ListSymbols ¶
func ListSymbols() []string
func RegAdapter ¶
func RegAdapter(symbol string, a ChainAdapter)
Types ¶
type AdapterError ¶
type AdapterError = types.AdapterError
----- types 导出 -----
func ConvertError ¶
func ConvertError(err error) *AdapterError
func Errorf ¶
func Errorf(code uint64, format string, a ...interface{}) *AdapterError
func NewError ¶
func NewError(code uint64, text string) *AdapterError
type AddressDecoder ¶
type AddressDecoder = decoder.AddressDecoder
func GetAddressDecoder ¶
func GetAddressDecoder(symbol string) (AddressDecoder, error)
type AddressDecoderBase ¶
type AddressDecoderBase = decoder.AddressDecoderBase
type AssetsConfig ¶
type AssetsConfig = chain.AssetsConfig
type AssetsConfigBase ¶
type AssetsConfigBase = chain.AssetsConfigBase
type BalanceQueryFunc ¶
type BalanceQueryFunc = scanner.BalanceQueryFunc
type BlockScanTargetFunc ¶
type BlockScanTargetFunc = scanner.BlockScanTargetFunc
type BlockScanner ¶
type BlockScanner = scanner.BlockScanner
----- scanner 导出 -----
func GetBlockScanner ¶
func GetBlockScanner(symbol string) (BlockScanner, error)
type BlockScannerBase ¶
type BlockchainSyncStatus ¶
type BlockchainSyncStatus = types.BlockchainSyncStatus
----- types 导出 -----
type ChainAdapter ¶
type ChainAdapter = chain.ChainAdapter
----- chain 导出 -----
func GetAdapter ¶
func GetAdapter(symbol string) (ChainAdapter, error)
type ChainAdapterBase ¶
type ChainAdapterBase = chain.ChainAdapterBase
type ContractReceiptItem ¶
type ContractReceiptItem = types.ContractReceiptItem
----- types 导出 -----
type PendingSignTx ¶
type PendingSignTx = types.PendingSignTx
----- types 导出 -----
func BuildSummaryTransaction ¶
func BuildSummaryTransaction(d TransactionDecoder, wrapper WalletDAI, sumRawTx *SummaryRawTransaction) ([]*PendingSignTx, error)
func BuildTransaction ¶
func BuildTransaction(d TransactionDecoder, wrapper WalletDAI, rawTx *RawTransaction) (*PendingSignTx, error)
----- flow 导出 -----
type RawTransactionWithError ¶
type RawTransactionWithError = types.RawTransactionWithError
----- types 导出 -----
type ScanTargetParam ¶
type ScanTargetParam = types.ScanTargetParam
----- types 导出 -----
func NewScanTargetParamForAddress ¶
func NewScanTargetParamForAddress(symbol, address string) ScanTargetParam
func NewScanTargetParamForAlias ¶
func NewScanTargetParamForAlias(symbol, alias string) ScanTargetParam
type SmartContractCallResult ¶
type SmartContractCallResult = types.SmartContractCallResult
----- types 导出 -----
type SmartContractDecoder ¶
type SmartContractDecoder = decoder.SmartContractDecoder
func GetSmartContractDecoder ¶
func GetSmartContractDecoder(symbol string) (SmartContractDecoder, error)
type SmartContractDecoderBase ¶
type SmartContractDecoderBase = decoder.SmartContractDecoderBase
type SmartContractRawTransaction ¶
type SmartContractRawTransaction = types.SmartContractRawTransaction
----- types 导出 -----
type SmartContractReceipt ¶
type SmartContractReceipt = types.SmartContractReceipt
----- types 导出 -----
type SummaryRawTransaction ¶
type SummaryRawTransaction = types.SummaryRawTransaction
----- types 导出 -----
type Transaction ¶
type Transaction = types.Transaction
----- types 导出 -----
func SendTransaction ¶
func SendTransaction(d TransactionDecoder, wrapper WalletDAI, pendingTx *PendingSignTx) (*Transaction, error)
type TransactionDecoder ¶
type TransactionDecoder = decoder.TransactionDecoder
----- decoder 导出 -----
func GetTransactionDecoder ¶
func GetTransactionDecoder(symbol string) (TransactionDecoder, error)
type TransactionDecoderBase ¶
type TransactionDecoderBase = decoder.TransactionDecoderBase
type TxExtractData ¶
type TxExtractData = types.TxExtractData
----- types 导出 -----
func NewTxExtractData ¶
func NewTxExtractData() *TxExtractData
type UnscanRecord ¶
type UnscanRecord = types.UnscanRecord
----- types 导出 -----
func NewUnscanRecord ¶
func NewUnscanRecord(height uint64, txID, reason, symbol string) *UnscanRecord
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chain 链适配器接口与注册表,提供 ChainAdapter 及按 symbol 的 RegAdapter/GetAdapter/GetTransactionDecoder/GetBlockScanner/GetAddressDecoder/GetSmartContractDecoder/ListSymbols。
|
Package chain 链适配器接口与注册表,提供 ChainAdapter 及按 symbol 的 RegAdapter/GetAdapter/GetTransactionDecoder/GetBlockScanner/GetAddressDecoder/GetSmartContractDecoder/ListSymbols。 |
|
Package config 提供链配置的通用接口与 JSON 解析,供各子类适配器(如 github.com/godaddy-x/wallet-adapter-eth)复用。
|
Package config 提供链配置的通用接口与 JSON 解析,供各子类适配器(如 github.com/godaddy-x/wallet-adapter-eth)复用。 |
|
地址解析器:编解码、校验、WIF、多签、自定义创建地址。
|
地址解析器:编解码、校验、WIF、多签、自定义创建地址。 |
|
Package flow 交易构建与广播流程;签名由外部 MPC 提供,本包负责构建待签交易单与提交广播。
|
Package flow 交易构建与广播流程;签名由外部 MPC 提供,本包负责构建待签交易单与提交广播。 |
|
Package scanner 区块扫描器接口与基类,负责按高度扫描区块、提取交易/回执并返回结果。
|
Package scanner 区块扫描器接口与基类,负责按高度扫描区块、提取交易/回执并返回结果。 |
|
Package types 区块扫描相关数据类型
|
Package types 区块扫描相关数据类型 |
|
Package wallet 钱包数据访问接口(WalletDAI),供 TransactionDecoder 在构建/验证时回调查询,与 types 解耦。
|
Package wallet 钱包数据访问接口(WalletDAI),供 TransactionDecoder 在构建/验证时回调查询,与 types 解耦。 |