core

package
v0.0.1-gowrapper-test Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BitcoinSigHashTypeAll          = C.TWBitcoinSigHashTypeAll
	BitcoinSigHashTypeNone         = C.TWBitcoinSigHashTypeNone
	BitcoinSigHashTypeSingle       = C.TWBitcoinSigHashTypeSingle
	BitcoinSigHashTypeFork         = C.TWBitcoinSigHashTypeFork
	BitcoinSigHashTypeForkBTG      = C.TWBitcoinSigHashTypeForkBTG
	BitcoinSigHashTypeAnyoneCanPay = C.TWBitcoinSigHashTypeAnyoneCanPay
)
View Source
const (
	CurveSECP256k1              = Curve(C.TWCurveSECP256k1)
	CurveED25519                = Curve(C.TWCurveED25519)
	CurveED25519Blake2bNano     = Curve(C.TWCurveED25519Blake2bNano)
	CurveED25519ExtendedCardano = Curve(C.TWCurveED25519ExtendedCardano)
	CurveCurve25519             = Curve(C.TWCurveCurve25519)
	CurveNIST256p1              = Curve(C.TWCurveNIST256p1)
	CurveStarkex                = Curve(C.TWCurveStarkex)
)

Curve constants

Variables

This section is empty.

Functions

func AnySigner

func AnySigner(inputData []byte, ct CoinType) ([]byte, error)

AnySigner - Direct access to TWAnySignerSign

func AnySignerJSON

func AnySignerJSON(jsonInput string, privateKey []byte, ct CoinType) (string, error)

AnySignerJSON - Sign using JSON input

func BitcoinScriptBuildPayToPublicKeyHash

func BitcoinScriptBuildPayToPublicKeyHash(hash []byte) []byte

func BitcoinScriptLockScriptForAddress

func BitcoinScriptLockScriptForAddress(addr string, ct CoinType) []byte

func BitcoinScriptMatchPayToWitnessPublicKeyHash

func BitcoinScriptMatchPayToWitnessPublicKeyHash(script []byte) []byte

func CompileTransaction

func CompileTransaction(inputData proto.Message, ct CoinType, signatures [][]byte, publicKeys [][]byte) ([]byte, error)

Step 3: Compile - Compile transaction with signatures

func CompileWithSignatures

func CompileWithSignatures(c CoinType, txInputData []byte, signatures [][]byte, publicKeyHashes [][]byte) []byte

func CreateSignedTx

func CreateSignedTx(inputData proto.Message, ct CoinType, outputData proto.Message) error

CreateSignedTx - Complete signing in one step (legacy function)

func GetTransactionHash

func GetTransactionHash(encodedTx []byte, ct CoinType) (string, error)

GetTransactionHash - Calculate the transaction hash for a given coin type

func IsMnemonicValid

func IsMnemonicValid(mn string) bool

func IsValidAddress

func IsValidAddress(address string, coinType CoinType) bool

IsValidAddress validates an address for the given coin type

func MessageSigner

func MessageSigner(inputData []byte, ct CoinType) ([]byte, error)

MessageSigner - Sign a message (for off-chain services)

func MessageSignerPreImageHashes

func MessageSignerPreImageHashes(inputData []byte, ct CoinType) ([]byte, error)

MessageSignerPreImageHashes - Get preimage hashes for message signing

func MessageSignerVerify

func MessageSignerVerify(inputData []byte, ct CoinType) (bool, error)

MessageSignerVerify - Verify a message signature

func PreHashTransaction

func PreHashTransaction(inputData proto.Message, ct CoinType) ([]byte, error)

Step 2: PreHash - Get pre-signing hashes

func PreImageHashes

func PreImageHashes(c CoinType, txInputData []byte) []byte

func PrepareTransaction

func PrepareTransaction(inputData proto.Message, ct CoinType) ([]byte, error)

Step 1: Prepare - Plan transaction (for UTXO chains) or prepare input data

func PublicKeyVerify

func PublicKeyVerify(key []byte, keyType PublicKeyType, signature []byte, message []byte) bool

func PublicKeyVerifyAsDER

func PublicKeyVerifyAsDER(key []byte, keyType PublicKeyType, signature []byte, message []byte) bool

func SupportsJSON

func SupportsJSON(ct CoinType) bool

SupportsJSON - Check if coin supports JSON signing

func TWDataVectorGoBytes

func TWDataVectorGoBytes(d *C.struct_TWDataVector) [][]byte

C.TWDataVector -> Go [][]byte

Types

type CoinType

type CoinType uint32
const (
	CoinTypeBitcoin          CoinType = C.TWCoinTypeBitcoin
	CoinTypeBinance          CoinType = C.TWCoinTypeBinance
	CoinTypeEthereum         CoinType = C.TWCoinTypeEthereum
	CoinTypeTron             CoinType = C.TWCoinTypeTron
	CoinTypeAlgorand         CoinType = C.TWCoinTypeAlgorand
	CoinTypeSolana           CoinType = C.TWCoinTypeSolana
	CoinTypeAvalancheCChain  CoinType = C.TWCoinTypeAvalancheCChain
	CoinTypeFantom           CoinType = C.TWCoinTypeFantom
	CoinTypePolygon          CoinType = C.TWCoinTypePolygon
	CoinTypeSmartChain       CoinType = C.TWCoinTypeSmartChain
	CoinTypeBase             CoinType = C.TWCoinTypeBase
	CoinTypeOptimism         CoinType = C.TWCoinTypeOptimism
	CoinTypeArbitrum         CoinType = C.TWCoinTypeArbitrum
	CoinTypeHedera           CoinType = C.TWCoinTypeHedera
	CoinTypeVeChain          CoinType = C.TWCoinTypeVeChain
	CoinTypeXRP              CoinType = C.TWCoinTypeXRP
	CoinTypeDogecoin         CoinType = C.TWCoinTypeDogecoin
	CoinTypeLitecoin         CoinType = C.TWCoinTypeLitecoin
	CoinTypeBitcoinCash      CoinType = C.TWCoinTypeBitcoinCash
	CoinTypeZcash            CoinType = C.TWCoinTypeZcash
	CoinTypeDash             CoinType = C.TWCoinTypeDash
	CoinTypeEOS              CoinType = C.TWCoinTypeEOS
	CoinTypeInternetComputer CoinType = C.TWCoinTypeInternetComputer
	CoinTypeCardano          CoinType = C.TWCoinTypeCardano
	CoinTypeCosmos           CoinType = C.TWCoinTypeCosmos
	CoinTypeAptos            CoinType = C.TWCoinTypeAptos
	CoinTypeStellar          CoinType = C.TWCoinTypeStellar
	CoinTypeNear             CoinType = C.TWCoinTypeNEAR
	CoinTypeTON              CoinType = C.TWCoinTypeTON
	CoinTypeSui              CoinType = C.TWCoinTypeSui
)

func (CoinType) Decimals

func (c CoinType) Decimals() int

func (CoinType) GetID

func (c CoinType) GetID() string

func (CoinType) GetName

func (c CoinType) GetName() string

func (CoinType) GetSymbol

func (c CoinType) GetSymbol() string

type Curve

type Curve C.enum_TWCurve

Curve represents the elliptic curve used for signing

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

PrivateKey represents a private key for signing

func NewPrivateKey

func NewPrivateKey(data []byte) *PrivateKey

NewPrivateKey creates a new private key from bytes

func (*PrivateKey) Delete

func (pk *PrivateKey) Delete()

Delete frees the private key

func (*PrivateKey) DeriveAddress

func (pk *PrivateKey) DeriveAddress(coinType CoinType) (string, error)

DeriveAddress derives an address from the private key for the specified coin type

func (*PrivateKey) GetPublicKeyBytes

func (pk *PrivateKey) GetPublicKeyBytes(coinType CoinType) []byte

GetPublicKeyBytes gets the public key bytes for the specified coin type

func (*PrivateKey) GetRawData

func (pk *PrivateKey) GetRawData() []byte

GetRawData gets the raw private key bytes (useful for specialized key handling)

func (*PrivateKey) Sign

func (pk *PrivateKey) Sign(hash []byte, curve Curve) []byte

Sign signs a message hash with the private key using the specified curve This is the direct signing function that takes private key and hash as separate parameters

func (*PrivateKey) SignAsDER

func (pk *PrivateKey) SignAsDER(hash []byte) []byte

SignAsDER signs a message hash and returns DER-encoded signature (SECP256k1 only) Temporarily using a fallback implementation until C binding is fixed

func (*PrivateKey) SignED25519

func (pk *PrivateKey) SignED25519(hash []byte) []byte

SignED25519 signs a message hash using ED25519 curve

func (*PrivateKey) SignED25519Extended

func (pk *PrivateKey) SignED25519Extended(hash []byte) []byte

SignED25519Extended signs a message hash using ED25519Extended curve

func (*PrivateKey) SignNIST256p1

func (pk *PrivateKey) SignNIST256p1(hash []byte) []byte

SignNIST256p1 signs a message hash using NIST256p1 curve

func (*PrivateKey) SignSECP256k1

func (pk *PrivateKey) SignSECP256k1(hash []byte) []byte

SignSECP256k1 signs a message hash using SECP256k1 curve

type PublicKeyType

type PublicKeyType uint32
const (
	PublicKeyTypeSECP256k1         PublicKeyType = C.TWPublicKeyTypeSECP256k1
	PublicKeyTypeSECP256k1Extended PublicKeyType = C.TWPublicKeyTypeSECP256k1Extended
	PublicKeyTypeNIST256p1         PublicKeyType = C.TWPublicKeyTypeNIST256p1
	PublicKeyTypeNIST256p1Extended PublicKeyType = C.TWPublicKeyTypeNIST256p1Extended
	PublicKeyTypeED25519           PublicKeyType = C.TWPublicKeyTypeED25519
	PublicKeyTypeED25519Blake2b    PublicKeyType = C.TWPublicKeyTypeED25519Blake2b
	PublicKeyTypeCURVE25519        PublicKeyType = C.TWPublicKeyTypeCURVE25519
	PublicKeyTypeED25519Cardano    PublicKeyType = C.TWPublicKeyTypeED25519Cardano
	PublicKeyTypeStarkex           PublicKeyType = C.TWPublicKeyTypeStarkex
)

type TWDataVector

type TWDataVector *C.struct_TWDataVector

func TWDataVectorCreateWithGoBytes

func TWDataVectorCreateWithGoBytes(d [][]byte) TWDataVector

Go [][]byte -> C.TWDataVector

type Wallet

type Wallet struct {
	Address string
	PriKey  string
	PubKey  string
	CoinType
}

func CreateWalletWithMnemonic

func CreateWalletWithMnemonic(mn string, ct CoinType) (*Wallet, error)

func CreateWalletWithPrivateKey

func CreateWalletWithPrivateKey(privateKey string, ct CoinType) (*Wallet, error)

CreateWalletWithPrivateKey creates a wallet from a private key hex string

Jump to

Keyboard shortcuts

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