Documentation ¶
Index ¶
- Variables
- func ByteToHex(data []byte) string
- func DecodeAddressToPublicKey(address string) (string, error)
- func EncodePublicKeyToAddress(publicKey string, network int) (string, error)
- func HexToByte(hex string) ([]byte, error)
- func IsValidAddress(address string) bool
- type Account
- func (a *Account) Address() string
- func (a *Account) DecodeAddressToPublicKey(address string) (string, error)
- func (a *Account) DeriveAccountAt(network int) (*Account, error)
- func (a *Account) EncodePublicKeyToAddress(publicKey string) (string, error)
- func (a *Account) IsValidAddress(address string) bool
- func (a *Account) PrivateKey() ([]byte, error)
- func (a *Account) PrivateKeyHex() (string, error)
- func (a *Account) PublicKey() []byte
- func (a *Account) PublicKeyHex() string
- func (a *Account) Sign(message []byte, password string) (data []byte, err error)
- func (a *Account) SignHex(messageHex string, password string) (*base.OptionalString, error)
- type Chain
- func (c *Chain) BalanceOfAccount(account base.Account) (*base.Balance, error)
- func (c *Chain) BalanceOfAddress(address string) (*base.Balance, error)
- func (c *Chain) BalanceOfPublicKey(publicKey string) (*base.Balance, error)
- func (c *Chain) BatchFetchTransactionStatus(hashListString string) string
- func (c *Chain) EstimateTransactionFee(transaction base.Transaction) (fee *base.OptionalString, err error)
- func (c *Chain) EstimateTransactionFeeUsePublicKey(transaction base.Transaction, pubkey string) (fee *base.OptionalString, err error)
- func (c *Chain) FetchScriptHashForMiniX(transferTo, amount string) (sh *MiniXScriptHash, err error)
- func (c *Chain) FetchTransactionDetail(hashString string) (*base.TransactionDetail, error)
- func (c *Chain) FetchTransactionStatus(hashString string) base.TransactionStatus
- func (c *Chain) GetMetadataString() (string, error)
- func (c *Chain) GetSignData(t *Transaction, walletAddress string) (data []byte, err error)
- func (c *Chain) GetTx() (*Tx, error)
- func (c *Chain) LoadCachedMetadataString(metadataString string) error
- func (c *Chain) MainToken() base.Token
- func (c *Chain) ReloadMetadata() (string, error)
- func (c *Chain) RpcCall(result interface{}, method string, params ...any) error
- func (c *Chain) SendRawTransaction(signedTx string) (s string, err error)
- func (c *Chain) SendSignedTransaction(signedTxn base.SignedTransaction) (hash *base.OptionalString, err error)
- type MiniXScriptHash
- type Token
- func (t *Token) BalanceOfAccount(account base.Account) (*base.Balance, error)
- func (t *Token) BalanceOfAddress(address string) (*base.Balance, error)
- func (t *Token) BalanceOfPublicKey(publicKey string) (*base.Balance, error)
- func (t *Token) BuildTransfer(sender, receiver, amount string) (txn base.Transaction, err error)
- func (t *Token) BuildTransferAll(sender, receiver string) (txn base.Transaction, err error)
- func (t *Token) CanTransferAll() bool
- func (t *Token) Chain() base.Chain
- func (t *Token) TokenInfo() (*base.TokenInfo, error)
- type Transaction
- func (t *Transaction) GetSignData(genesisHashString string, nonce int64, specVersion, transVersion int32) ([]byte, error)
- func (t *Transaction) GetTx(signerPublicKey []byte, signatureData []byte) (string, error)
- func (t *Transaction) GetTxFromHex(signerPublicKeyHex string, signatureDataHex string) (string, error)
- func (t *Transaction) GetUnSignTx() (string, error)
- func (t *Transaction) SignWithAccount(account base.Account) (signedTx *base.OptionalString, err error)
- func (t *Transaction) SignedTransactionWithAccount(account base.Account) (signedTx base.SignedTransaction, err error)
- type Tx
- func (t *Tx) NewBalanceTransferTx(dest, amount string) (*Transaction, error)
- func (t *Tx) NewComingNftTransferTx(dest string, cid int64) (*Transaction, error)
- func (t *Tx) NewExtrinsics(call string, args ...interface{}) (*Transaction, error)
- func (t *Tx) NewThreshold(...) (*Transaction, error)
- func (t *Tx) NewTransactionFromHex(txHex string) (*Transaction, error)
- func (t *Tx) NewXAssetsTransferTx(dest, amount string) (*Transaction, error)
- func (t *Tx) NewXGatewayBitcoinCreateTaprootWithdrawTx(ids, transactionHex string) (*Transaction, error)
- type Util
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilKey = errors.New("no mnemonic or private key") ErrNilWallet = errors.New("no mnemonic or private key or keystore") ErrNilKeystore = errors.New("no keystore") ErrNilMetadata = errors.New("no metadata") ErrNotSigned = errors.New("transaction not signed") ErrNoPublicKey = errors.New("transaction no public key") ErrNilExtrinsic = errors.New("nil extrinsic") ErrAddress = errors.New("err address") ErrPublicKey = errors.New("err publicKey") ErrSeedOrPhrase = errors.New("invalid seed length") ErrInvalidMnemonic = errors.New("invalid mnemonic") ErrWrongMetadata = errors.New("wrong metadata") ErrNoEncrypted = errors.New("no encrypted data to decode") ErrEncryptedLength = errors.New("encrypted length is less than 24") ErrInvalidParams = errors.New("invalid injected scrypt params found") ErrSecretLength = errors.New("secret length is not 32") ErrEncoded = errors.New("encoded is nil") ErrPkcs8Header = errors.New("invalid Pkcs8 header found in body") ErrPkcs8Divider = errors.New("invalid Pkcs8 divider found in body") ErrNonPkcs8 = errors.New("unable to decode non-pkcs8 type") ErrNilPassword = errors.New("password required to decode encrypted data") ErrNoEncryptedData = errors.New("no encrypted data available to decode") ErrKeystore = errors.New("decoded public keys are not equal") ErrPassword = errors.New("password err") ErrNumber = errors.New("illegal number") ErrSign = errors.New("sign panic error") )
Functions ¶
func DecodeAddressToPublicKey ¶
@return publicKey that will start with 0x.
func EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.
Types ¶
type Account ¶
type Account struct { Network int // contains filtered or unexported fields }
func AccountWithPrivateKey ¶
func AsPolkaAccount ¶
func NewAccountWithKeystore ¶
func NewAccountWithMnemonic ¶
func (*Account) DecodeAddressToPublicKey ¶
@return publicKey that will start with 0x.
func (*Account) EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.
func (*Account) IsValidAddress ¶
func (*Account) PrivateKeyHex ¶
@return privateKey string that will start with 0x.
func (*Account) PublicKeyHex ¶
@return publicKey string that will start with 0x.
type Chain ¶
func NewChainWithRpc ¶
@param rpcUrl will be used to get metadata, query balance, estimate fee, send signed tx. @param scanUrl will be used to query transaction details
func (*Chain) BalanceOfAccount ¶
func (*Chain) BalanceOfAddress ¶
func (*Chain) BalanceOfPublicKey ¶
func (*Chain) BatchFetchTransactionStatus ¶
func (*Chain) EstimateTransactionFee ¶
func (c *Chain) EstimateTransactionFee(transaction base.Transaction) (fee *base.OptionalString, err error)
func (*Chain) EstimateTransactionFeeUsePublicKey ¶
func (c *Chain) EstimateTransactionFeeUsePublicKey(transaction base.Transaction, pubkey string) (fee *base.OptionalString, err error)
func (*Chain) FetchScriptHashForMiniX ¶
func (c *Chain) FetchScriptHashForMiniX(transferTo, amount string) (sh *MiniXScriptHash, err error)
获取 mini 多签转账时需要的 scriptHash @param transferTo 转账目标地址 @param amount 要转出的金额
func (*Chain) FetchTransactionDetail ¶
func (c *Chain) FetchTransactionDetail(hashString string) (*base.TransactionDetail, error)
func (*Chain) FetchTransactionStatus ¶
func (c *Chain) FetchTransactionStatus(hashString string) base.TransactionStatus
func (*Chain) GetMetadataString ¶
Get the metadata string of the chain (if not, it will be downloaded automatically)
func (*Chain) GetSignData ¶
func (c *Chain) GetSignData(t *Transaction, walletAddress string) (data []byte, err error)
功能和 GetSignData 相同,不需要提供 nonce, version 等参数,但需要提供 chain 对象和地址
func (*Chain) LoadCachedMetadataString ¶
Load cached metadata string. This will save a lot of network traffic to download metadata from rpcUrl.
func (*Chain) ReloadMetadata ¶
Reload the latest metadata of this chain. @return the latest metadata string
func (*Chain) SendRawTransaction ¶
func (*Chain) SendSignedTransaction ¶
func (c *Chain) SendSignedTransaction(signedTxn base.SignedTransaction) (hash *base.OptionalString, err error)
type MiniXScriptHash ¶
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func (*Token) BalanceOfAccount ¶
func (*Token) BalanceOfAddress ¶
func (*Token) BalanceOfPublicKey ¶
func (*Token) BuildTransfer ¶
func (t *Token) BuildTransfer(sender, receiver, amount string) (txn base.Transaction, err error)
func (*Token) BuildTransferAll ¶
func (t *Token) BuildTransferAll(sender, receiver string) (txn base.Transaction, err error)
func (*Token) CanTransferAll ¶
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func (*Transaction) GetSignData ¶
func (*Transaction) GetTx ¶
func (t *Transaction) GetTx(signerPublicKey []byte, signatureData []byte) (string, error)
func (*Transaction) GetTxFromHex ¶
func (t *Transaction) GetTxFromHex(signerPublicKeyHex string, signatureDataHex string) (string, error)
func (*Transaction) GetUnSignTx ¶
func (t *Transaction) GetUnSignTx() (string, error)
func (*Transaction) SignWithAccount ¶
func (t *Transaction) SignWithAccount(account base.Account) (signedTx *base.OptionalString, err error)
func (*Transaction) SignedTransactionWithAccount ¶
func (t *Transaction) SignedTransactionWithAccount(account base.Account) (signedTx base.SignedTransaction, err error)
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) NewBalanceTransferTx ¶
func (t *Tx) NewBalanceTransferTx(dest, amount string) (*Transaction, error)
func (*Tx) NewComingNftTransferTx ¶
func (t *Tx) NewComingNftTransferTx(dest string, cid int64) (*Transaction, error)
func (*Tx) NewExtrinsics ¶
func (t *Tx) NewExtrinsics(call string, args ...interface{}) (*Transaction, error)
func (*Tx) NewThreshold ¶
func (t *Tx) NewThreshold(thresholdPublicKey, destAddress, aggSignature, aggPublicKey, controlBlock, message, scriptHash, transferAmount string, blockNumber int32) (*Transaction, error)
func (*Tx) NewTransactionFromHex ¶
func (t *Tx) NewTransactionFromHex(txHex string) (*Transaction, error)
func (*Tx) NewXAssetsTransferTx ¶
func (t *Tx) NewXAssetsTransferTx(dest, amount string) (*Transaction, error)
func (*Tx) NewXGatewayBitcoinCreateTaprootWithdrawTx ¶
func (t *Tx) NewXGatewayBitcoinCreateTaprootWithdrawTx(ids, transactionHex string) (*Transaction, error)
type Util ¶
type Util struct {
Network int
}
func NewUtilWithNetwork ¶
func (*Util) DecodeAddressToPublicKey ¶
@return publicKey that will start with 0x.
func (*Util) EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.