Documentation ¶
Index ¶
- Constants
- Variables
- func CheckBtcScript(msg []byte, sig *Signature) error
- func GetBtcLockScript(scriptTy int32, pkScript []byte) (btcutil.Address, []byte, error)
- func GetBtcUnlockScript(signMsg, lockScript, prevScript []byte, kdb txscript.KeyDB, ...) ([]byte, error)
- func GetWalletRecoverySignature(isRetrieve bool, signMsg, privKey, walletRecoverScript []byte, ...) (sig []byte, pubKey []byte, err error)
- func MakeKeyDB(keyAddr ...*BtcAddr2Key) txscript.KeyDB
- func MakeScriptDB(scriptArr ...*BtcAddr2Script) txscript.ScriptDB
- func NewBtcKeyFromBytes(priv []byte) (*btcec.PrivateKey, *btcec.PublicKey)
- func NewBtcScriptSig(lockScript, unlockScript []byte) ([]byte, error)
- func NewBtcScriptSigWithDelay(lockScript, unlockScript []byte, lockTime, utxoSeq int64) ([]byte, error)
- func NewMultiSigScript(pubKeys [][]byte, required int) (script []byte, err error)
- func NewWalletRecoveryScript(controlPubKey, recoverPubKey []byte, relativeDelayTime int64) (script []byte, err error)
- func Script2PubKey(lockScript []byte) []byte
- type BtcAddr2Key
- type BtcAddr2Script
- type Signature
- func (*Signature) Descriptor() ([]byte, []int)deprecated
- func (x *Signature) GetLockScript() []byte
- func (x *Signature) GetLockTime() int64
- func (x *Signature) GetUnlockScript() []byte
- func (x *Signature) GetUtxoSequence() int64
- func (*Signature) ProtoMessage()
- func (x *Signature) ProtoReflect() protoreflect.Message
- func (x *Signature) Reset()
- func (x *Signature) String() string
Constants ¶
const ( // TyPay2PubKey Pay to pub key TyPay2PubKey = iota // TyPay2PubKeyHash Pay to pub key Hash TyPay2PubKeyHash // TyPay2ScriptHash Pay to Script Hash TyPay2ScriptHash )
Variables ¶
var ( // ErrInvalidMultiSigRequiredNum error required multi sig pub key num ErrInvalidMultiSigRequiredNum = errors.New("ErrInvalidMultiSigRequiredNum") // ErrInvalidBtcPubKey invalid bitcoin pubkey ErrInvalidBtcPubKey = errors.New("ErrInvalidBtcPubKey") // ErrBuildBtcScript build btc script error ErrBuildBtcScript = errors.New("ErrBuildBtcScript") // ErrNewBtcAddress new btc address pub key error ErrNewBtcAddress = errors.New("ErrNewBtcAddress") // ErrGetBtcTxInSig get btc tx input signature error ErrGetBtcTxInSig = errors.New("ErrGetBtcTxInSig") // ErrNewBtcScriptSig new btc script sig error ErrNewBtcScriptSig = errors.New("ErrNewBtcScriptSig") // ErrBtcKeyNotExist btc key not exist when sign ErrBtcKeyNotExist = errors.New("ErrBtcKeyNotExist") // ErrBtcScriptNotExist btc script not exist when sign ErrBtcScriptNotExist = errors.New("ErrBtcScriptNotExist") )
var Chain33BtcParams = &chaincfg.Params{
Name: "chain33-btc-Script",
PubKeyHashAddrID: 0x00,
ScriptHashAddrID: 0x05,
PrivateKeyID: 0x80,
WitnessPubKeyHashAddrID: 0x06,
WitnessScriptHashAddrID: 0x0A,
}
Chain33BtcParams 比特币相关区块链参数
var File_sign_proto protoreflect.FileDescriptor
Functions ¶
func CheckBtcScript ¶
CheckBtcScript check btc Script signature
func GetBtcLockScript ¶
GetBtcLockScript 根据地址类型,生成锁定脚本
func GetBtcUnlockScript ¶
func GetBtcUnlockScript(signMsg, lockScript, prevScript []byte, kdb txscript.KeyDB, sdb txscript.ScriptDB) ([]byte, error)
GetBtcUnlockScript 生成比特币解锁脚本
func GetWalletRecoverySignature ¶
func GetWalletRecoverySignature(isRetrieve bool, signMsg, privKey, walletRecoverScript []byte, utxoSequence int64) (sig []byte, pubKey []byte, err error)
GetWalletRecoverySignature get wallet asset recover signature isRetrieve set false when input control address private key, set true for wallet recovery signMsg msg for sign privKey private key of control address or recover address walletRecoverScript result of NewWalletRecoveryScript utxoSequence utxo sequence, set relative delay time for wallet recovery
func MakeKeyDB ¶
func MakeKeyDB(keyAddr ...*BtcAddr2Key) txscript.KeyDB
MakeKeyDB make btc script key db
func MakeScriptDB ¶
func MakeScriptDB(scriptArr ...*BtcAddr2Script) txscript.ScriptDB
MakeScriptDB make btc script db
func NewBtcKeyFromBytes ¶
func NewBtcKeyFromBytes(priv []byte) (*btcec.PrivateKey, *btcec.PublicKey)
NewBtcKeyFromBytes 获取比特币公私钥
func NewBtcScriptSig ¶
NewBtcScriptSig new btc script signature
func NewBtcScriptSigWithDelay ¶
func NewBtcScriptSigWithDelay(lockScript, unlockScript []byte, lockTime, utxoSeq int64) ([]byte, error)
NewBtcScriptSigWithDelay new btc script signature with lockTime or sequence
func NewMultiSigScript ¶
NewMultiSigScript multi-sig pubKey script
func NewWalletRecoveryScript ¶
func NewWalletRecoveryScript(controlPubKey, recoverPubKey []byte, relativeDelayTime int64) (script []byte, err error)
NewWalletRecoveryScript wallet assets recovery pubKey script controlPubKey secp256k1 pub key recoverPubKey secp256k1 pub key relativeDelayTime relative time of second or block height IF <A's Pubkey> CHECKSIG ELSE <sequence> CHECKSEQUENCEVERIFY DROP <B's Pubkey> CHECKSIGVERIFY ENDIF
func Script2PubKey ¶
Script2PubKey transform script to fixed length public key
Types ¶
type BtcAddr2Key ¶
type BtcAddr2Key struct { Addr string Key *btcec.PrivateKey }
BtcAddr2Key 比特币编码地址及对应的私钥,用于签名KeyDB
type BtcAddr2Script ¶
BtcAddr2Script 比特币编码地址及对应的脚本,用于签名ScriptDB
type Signature ¶
type Signature struct { LockScript []byte `protobuf:"bytes,1,opt,name=lockScript,proto3" json:"lockScript,omitempty"` UnlockScript []byte `protobuf:"bytes,2,opt,name=unlockScript,proto3" json:"unlockScript,omitempty"` LockTime int64 `protobuf:"varint,3,opt,name=lockTime,proto3" json:"lockTime,omitempty"` UtxoSequence int64 `protobuf:"varint,4,opt,name=utxoSequence,proto3" json:"utxoSequence,omitempty"` // contains filtered or unexported fields }
func (*Signature) Descriptor
deprecated
func (*Signature) GetLockScript ¶
func (*Signature) GetLockTime ¶
func (*Signature) GetUnlockScript ¶
func (*Signature) GetUtxoSequence ¶
func (*Signature) ProtoMessage ¶
func (*Signature) ProtoMessage()
func (*Signature) ProtoReflect ¶
func (x *Signature) ProtoReflect() protoreflect.Message