Documentation ¶
Index ¶
- Constants
- Variables
- func CalTxHash(rawTx string) string
- func DecodeTx(rawTx string) (string, error)
- func EcRecover(signature, message string, addPrefix bool) (string, error)
- func EcRecoverPubKey(signature, message string, addPrefix bool) (*btcec.PublicKey, error)
- func GenerateRawTransactionWithSignature(txType int, chainId, unsignedRawTx, r, s, v string) (string, error)
- func GetAddress(pubkeyHex string) string
- func GetEthGroupAddress(prefix string, pubKey *btcec.PublicKey) string
- func GetEthGroupPubHash(pubKey *btcec.PublicKey) []byte
- func GetEthereumMessagePrefix(message string) string
- func GetNewAddress(pubKey *btcec.PublicKey) string
- func GetNewAddressBytes(pubKey *btcec.PublicKey) []byte
- func MessageHash(data string) string
- func NewEip1559Transaction(chainId *big.Int, nonce uint64, maxPriorityFeePerGas *big.Int, ...) *types.Transaction
- func OnlyRemovePrefix(s string) string
- func PubKeyToAddr(publicKey []byte) (string, error)
- func SignEthTypeMessage(message string, prvKey *btcec.PrivateKey, addPrefix bool) (string, error)
- func ValidateAddress(address string) bool
- func VerifySignMsg(signature, message, address string, addPrefix bool) error
- type EIP1559Transaction
- type Eip1559Token
- type Eip1559Transaction
- type EthTransaction
- func (tx *EthTransaction) GetSigningHash(chainId *big.Int) (string, string, error)
- func (tx *EthTransaction) SignTransaction(chainId *big.Int, prvKey *btcec.PrivateKey) (string, error)
- func (tx *EthTransaction) SignedTx(chainId *big.Int, sig *SignatureData) (string, error)
- func (tx *EthTransaction) UnSignedTx(chainId *big.Int) (string, error)
- type SignatureData
- type Transaction
- type UnsignedTx
Constants ¶
View Source
const AddressLength = 20
View Source
const MessagePrefixTmp = "\u0019Ethereum Signed Message:\n%d"
Variables ¶
View Source
var (
ErrInvalidParam = errors.New("invalid param")
)
View Source
var (
ErrInvalidSignature = errors.New("invalid signature")
)
Functions ¶
func EcRecoverPubKey ¶ added in v0.0.4
func GenerateRawTransactionWithSignature ¶
func GenerateRawTransactionWithSignature(txType int, chainId, unsignedRawTx, r, s, v string) (string, error)
GenerateRawTransactionWithSignature Generate the transaction to be broadcast based on the unsigned transaction and the signature result
func GetAddress ¶
func GetEthGroupAddress ¶ added in v0.0.4
func GetEthGroupPubHash ¶ added in v0.0.4
func GetEthGroupPubHash(pubKey *btcec.PublicKey) []byte
func GetNewAddress ¶
func GetNewAddress(pubKey *btcec.PublicKey) string
func GetNewAddressBytes ¶ added in v0.0.4
func GetNewAddressBytes(pubKey *btcec.PublicKey) []byte
func MessageHash ¶
func NewEip1559Transaction ¶
func OnlyRemovePrefix ¶ added in v0.0.4
func PubKeyToAddr ¶ added in v0.0.3
func SignEthTypeMessage ¶ added in v0.0.4
func ValidateAddress ¶
func VerifySignMsg ¶ added in v0.0.4
Types ¶
type EIP1559Transaction ¶
type EIP1559Transaction struct { Transaction TxType int `json:"txType"` MaxFeePerGas string `json:"maxFeePerGas"` MaxPriorityFeePerGas string `json:"maxPriorityFeePerGas"` }
type Eip1559Token ¶
type Eip1559Token struct { EIP1559Transaction ContractAddress string `json:"contract_address"` Amount string `json:"amount"` }
type Eip1559Transaction ¶
type Eip1559Transaction struct { ChainId *big.Int `json:"chainId"` Nonce uint64 `json:"nonce"` GasTipCap *big.Int `json:"gasTipCap"` GasFeeCap *big.Int `json:"gasFeeCap"` Gas uint64 `json:"gas"` To *common.Address `json:"to"` Value *big.Int `json:"value"` Data []byte `json:"data"` AccessList types.AccessList `json:"accessList"` }
type EthTransaction ¶
type EthTransaction struct { Nonce *big.Int `json:"nonce"` GasPrice *big.Int `json:"gasPrice"` GasLimit *big.Int `json:"gas"` To []byte `json:"to"` Value *big.Int `json:"value"` Data []byte `json:"data"` // Signature values V *big.Int `json:"v"` R *big.Int `json:"r"` S *big.Int `json:"s"` }
func NewEthTransaction ¶
func NewEthTransaction(nonce, gasLimit, gasPrice, value *big.Int, to, data string) *EthTransaction
func NewTransactionFromRaw ¶
func NewTransactionFromRaw(raw string) (*EthTransaction, error)
func (*EthTransaction) GetSigningHash ¶
func (*EthTransaction) SignTransaction ¶
func (tx *EthTransaction) SignTransaction(chainId *big.Int, prvKey *btcec.PrivateKey) (string, error)
func (*EthTransaction) SignedTx ¶
func (tx *EthTransaction) SignedTx(chainId *big.Int, sig *SignatureData) (string, error)
func (*EthTransaction) UnSignedTx ¶
func (tx *EthTransaction) UnSignedTx(chainId *big.Int) (string, error)
type SignatureData ¶
func NewSignatureData ¶
func SignAsRecoverable ¶
func SignAsRecoverable(value []byte, prvKey *btcec.PrivateKey) (*SignatureData, error)
func SignMessage ¶
func SignMessage(message []byte, prvKey *btcec.PrivateKey) (*SignatureData, error)
func (SignatureData) ToBytes ¶
func (sd SignatureData) ToBytes() []byte
func (*SignatureData) ToHex ¶
func (sd *SignatureData) ToHex() string
type Transaction ¶
type UnsignedTx ¶
func GenerateTxWithJSON ¶
generate tx with json param
func NewUnsignedTx ¶
func NewUnsignedTx(nonce, gasLimit, gasPrice, value, chainId *big.Int, to, data string) (*UnsignedTx, error)
Click to show internal directories.
Click to hide internal directories.