tx

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateTransactionDataHash

func CalculateTransactionDataHash(txData *bcostars.TransactionData) (string, error)

func CreateSignedTransaction

func CreateSignedTransaction(privateKey string, groupId string, chainId string, to string, dataHex string, abiJson string, blockLimit int64, attribute int32) (txHash string, txHex string, err error)

func CreateTransaction

func CreateTransaction(from string, txData *bcostars.TransactionData, txDataHash string, signedTxDataHash string, attribute int32) (*bcostars.Transaction, error)
func Address(priKey *ecdsa2.PrivateKey) string {
	//priKeyHash := "796c823671b118258b53ef6056fd1f9fc96d125600f348f75f397b2000267fe8"
	// 创建私钥对象,上面私钥没有钱哦
	//priKey, err := crypto.HexToECDSA(priKeyHash)
	//if err != nil {
	//	panic(err)
	//}
	//priKeyBytes := crypto.FromECDSA(priKey)
	//fmt.Printf("私钥为: %s\n", hex.EncodeToString(priKeyBytes))

	pubKey := priKey.Public().(*ecdsa2.PublicKey)
	//// 获取公钥并去除头部0x04
	pubKeyBytes := crypto.FromECDSAPub(pubKey)[1:]
	fmt.Printf("公钥为: %s\n", hex.EncodeToString(pubKeyBytes))
	//
	//// 获取地址
	addr := crypto.PubkeyToAddress(*pubKey)
	fmt.Printf("地址为: %s\n", addr.Hex())

	return addr.Hex()
}

func CreateTransactionData

func CreateTransactionData(groupId string, chainId string, to string, dataHex string, abiJson string, blockLimit int64) (*bcostars.TransactionData, error)

1

func DecodeTransactionDataFromHex

func DecodeTransactionDataFromHex(txDataHex string) (*bcostars.TransactionData, error)

func EncodeTransaction

func EncodeTransaction(tx *bcostars.Transaction) (string, error)

func EncodeTransactionDataToHex

func EncodeTransactionDataToHex(tx *bcostars.TransactionData) (string, error)

func GetBlockLimit

func GetBlockLimit(groupId string) (int64, error)

@todo

func HexByte2Int8

func HexByte2Int8(dataHex []byte) []int8

func Nonce

func Nonce() string

func ParseKeyPairFromPrivateKey

func ParseKeyPairFromPrivateKey(privateKey string) (*secp256k1.PrivateKey, error)

func PrivateKeyToAddress

func PrivateKeyToAddress(privateKey string) (string, error)

func SignTransactionDataHash

func SignTransactionDataHash(privateKey string, txDataHash string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL