Documentation
¶
Index ¶
- Constants
- func CalcSignatureHash(tx *modules.Transaction, hashType uint32, msgIdx, inputIdx int, ...) ([]byte, error)
- func DisasmString(script []byte) (string, error)
- func GenerateLockScript(address common.Address) []byte
- func GenerateP2CHLockScript(contractId common.Address) []byte
- func GenerateP2CHUnlockScript(signs [][]byte, redeemScript []byte) []byte
- func GenerateP2PKHLockScript(pubKeyHash []byte) []byte
- func GenerateP2PKHUnlockScript(sign []byte, pubKey []byte) []byte
- func GenerateP2SHLockScript(redeemScriptHash []byte) []byte
- func GenerateP2SHUnlockScript(signs [][]byte, redeemScript []byte) []byte
- func GenerateRedeemScript(needed byte, pubKeys [][]byte) []byte
- func GetAddressFromScript(lockScript []byte) (common.Address, error)
- func GetScriptSigners(tx *modules.Transaction, msgIdx, inputIndex int) ([]common.Address, error)
- func IsUnspendable(script []byte) bool
- func MergeContractUnlockScript(signs [][]byte, redeemScript []byte) []byte
- func MultiSignOnePaymentInput(tx *modules.Transaction, hashType uint32, msgIdx, id int, ...) ([]byte, error)
- func ScriptValidate(utxoLockScript []byte, pickupJuryRedeemScript txscript.PickupJuryRedeemScript, ...) error
- func ScriptValidate1Msg(utxoLockScripts map[string][]byte, ...) error
- func SignTxAllPaymentInput(tx *modules.Transaction, hashType uint32, ...) ([]common.SignatureError, error)
- type AddressGetPubKey
- type AddressGetSign
- type PubKey4Sort
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func CalcSignatureHash ¶
func CalcSignatureHash(tx *modules.Transaction, hashType uint32, msgIdx, inputIdx int, lockOrRedeemScript []byte) ([]byte, error)
为钱包计算要签名某个Input对应的Hash
func GenerateP2CHLockScript ¶
func GenerateP2CHUnlockScript ¶
根据收集到的签名和脚本生成解锁合约上的Token的脚本
func GenerateP2PKHLockScript ¶
Generate a P2PKH lock script, just only need input 20bytes public key hash. You can use Address.Bytes() to get address hash.
func GenerateP2PKHUnlockScript ¶
根据签名和公钥信息生成解锁脚本 Use signature and public key to generate a P2PKH unlock script
func GenerateP2SHLockScript ¶
Give redeem script hash 160 result, generate a P2SH lock script. If you have built your redeem script, please use crypto.Hash160() to gnerate hash
func GenerateP2SHUnlockScript ¶
根据收集到的签名和脚本生成解锁脚本 Use collection signatures and redeem script to unlock
func GenerateRedeemScript ¶
生成多签用的赎回脚本 Generate redeem script
func GetAddressFromScript ¶
根据锁定脚本获得对应的地址
func GetScriptSigners ¶
对于一个多签或者合约解锁脚本,获得到底哪些用户参与了签名
func IsUnspendable ¶
func MultiSignOnePaymentInput ¶
func MultiSignOnePaymentInput(tx *modules.Transaction, hashType uint32, msgIdx, id int, utxoLockScript []byte, redeemScript []byte, pubKeyFn AddressGetPubKey, hashFn AddressGetSign, previousScript []byte) ([]byte, error)
对交易中的Payment类型中的某个Input生成解锁脚本
func SignOnePaymentInput(tx *modules.Transaction, msgIdx, id int, utxoLockScript []byte, privKey *ecdsa.PrivateKey, juryVersion int) ([]byte, error) { lookupKey := func(a common.Address) (*ecdsa.PrivateKey, bool, error) { return privKey, true, nil } sigScript, err := txscript.SignTxOutput(tx, msgIdx, id, utxoLockScript, txscript.SigHashAll, txscript.KeyClosure(lookupKey), nil, nil, juryVersion) if err != nil { return []byte{}, err } return sigScript, nil }
func ScriptValidate ¶
func ScriptValidate(utxoLockScript []byte, pickupJuryRedeemScript txscript.PickupJuryRedeemScript, tx *modules.Transaction, msgIdx, inputIndex int) error
validate this transaction and input index script can unlock the utxo.
func ScriptValidate1Msg ¶ added in v1.0.1
func ScriptValidate1Msg(utxoLockScripts map[string][]byte, pickupJuryRedeemScript txscript.PickupJuryRedeemScript, tx *modules.Transaction, msgIdx int) error
验证一个PaymentMessage的所有Input解锁脚本是否正确
func SignTxAllPaymentInput ¶
func SignTxAllPaymentInput(tx *modules.Transaction, hashType uint32, utxoLockScripts map[modules.OutPoint][]byte, redeemScript []byte, pubKeyFn AddressGetPubKey, hashFn AddressGetSign) ([]common.SignatureError, error)
Sign a full transaction
Types ¶
type PubKey4Sort ¶
type PubKey4Sort [][]byte
func (PubKey4Sort) Len ¶
func (c PubKey4Sort) Len() int
func (PubKey4Sort) Less ¶
func (c PubKey4Sort) Less(i, j int) bool
func (PubKey4Sort) Swap ¶
func (c PubKey4Sort) Swap(i, j int)