Documentation
¶
Index ¶
- Constants
- func AnySigner(inputData []byte, ct CoinType) ([]byte, error)
- func AnySignerJSON(jsonInput string, privateKey []byte, ct CoinType) (string, error)
- func BitcoinScriptBuildPayToPublicKeyHash(hash []byte) []byte
- func BitcoinScriptLockScriptForAddress(addr string, ct CoinType) []byte
- func BitcoinScriptMatchPayToWitnessPublicKeyHash(script []byte) []byte
- func CompileTransaction(inputData proto.Message, ct CoinType, signatures [][]byte, publicKeys [][]byte) ([]byte, error)
- func CompileWithSignatures(c CoinType, txInputData []byte, signatures [][]byte, publicKeyHashes [][]byte) []byte
- func CreateSignedTx(inputData proto.Message, ct CoinType, outputData proto.Message) error
- func GetTransactionHash(encodedTx []byte, ct CoinType) (string, error)
- func IsMnemonicValid(mn string) bool
- func IsValidAddress(address string, coinType CoinType) bool
- func MessageSigner(inputData []byte, ct CoinType) ([]byte, error)
- func MessageSignerPreImageHashes(inputData []byte, ct CoinType) ([]byte, error)
- func MessageSignerVerify(inputData []byte, ct CoinType) (bool, error)
- func PreHashTransaction(inputData proto.Message, ct CoinType) ([]byte, error)
- func PreImageHashes(c CoinType, txInputData []byte) []byte
- func PrepareTransaction(inputData proto.Message, ct CoinType) ([]byte, error)
- func PublicKeyVerify(key []byte, keyType PublicKeyType, signature []byte, message []byte) bool
- func PublicKeyVerifyAsDER(key []byte, keyType PublicKeyType, signature []byte, message []byte) bool
- func SupportsJSON(ct CoinType) bool
- func TWDataVectorGoBytes(d *C.struct_TWDataVector) [][]byte
- type CoinType
- type Curve
- type PrivateKey
- func (pk *PrivateKey) Delete()
- func (pk *PrivateKey) DeriveAddress(coinType CoinType) (string, error)
- func (pk *PrivateKey) GetPublicKeyBytes(coinType CoinType) []byte
- func (pk *PrivateKey) GetRawData() []byte
- func (pk *PrivateKey) Sign(hash []byte, curve Curve) []byte
- func (pk *PrivateKey) SignAsDER(hash []byte) []byte
- func (pk *PrivateKey) SignED25519(hash []byte) []byte
- func (pk *PrivateKey) SignED25519Extended(hash []byte) []byte
- func (pk *PrivateKey) SignNIST256p1(hash []byte) []byte
- func (pk *PrivateKey) SignSECP256k1(hash []byte) []byte
- type PublicKeyType
- type TWDataVector
- type Wallet
Constants ¶
const ( BitcoinSigHashTypeAll = C.TWBitcoinSigHashTypeAll BitcoinSigHashTypeNone = C.TWBitcoinSigHashTypeNone BitcoinSigHashTypeSingle = C.TWBitcoinSigHashTypeSingle BitcoinSigHashTypeFork = C.TWBitcoinSigHashTypeFork BitcoinSigHashTypeForkBTG = C.TWBitcoinSigHashTypeForkBTG BitcoinSigHashTypeAnyoneCanPay = C.TWBitcoinSigHashTypeAnyoneCanPay )
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 AnySignerJSON ¶
AnySignerJSON - Sign using JSON input
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 CreateSignedTx ¶
CreateSignedTx - Complete signing in one step (legacy function)
func GetTransactionHash ¶
GetTransactionHash - Calculate the transaction hash for a given coin type
func IsMnemonicValid ¶
func IsValidAddress ¶
IsValidAddress validates an address for the given coin type
func MessageSigner ¶
MessageSigner - Sign a message (for off-chain services)
func MessageSignerPreImageHashes ¶
MessageSignerPreImageHashes - Get preimage hashes for message signing
func MessageSignerVerify ¶
MessageSignerVerify - Verify a message signature
func PreHashTransaction ¶
Step 2: PreHash - Get pre-signing hashes
func PreImageHashes ¶
func PrepareTransaction ¶
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 ¶
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 )
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) 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