本文整理汇总了Golang中github.com/piotrnar/gocoin/lib/btc.Tx.WitnessSigHash方法的典型用法代码示例。如果您正苦于以下问题:Golang Tx.WitnessSigHash方法的具体用法?Golang Tx.WitnessSigHash怎么用?Golang Tx.WitnessSigHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/piotrnar/gocoin/lib/btc.Tx
的用法示例。
在下文中一共展示了Tx.WitnessSigHash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: evalScript
//.........这里部分代码省略.........
}
return false
}
h := btc.Sha2Sum(stack.pop())
stack.push(h[:])
case opcode == 0xab: // OP_CODESEPARATOR
sta = idx
case opcode == 0xac || opcode == 0xad: // OP_CHECKSIG || OP_CHECKSIGVERIFY
if stack.size() < 2 {
if DBG_ERR {
fmt.Println("Stack too short for opcode", opcode)
}
return false
}
var fSuccess bool
vchSig := stack.top(-2)
vchPubKey := stack.top(-1)
// BIP-0066
if !CheckSignatureEncoding(vchSig, ver_flags) || !CheckPubKeyEncoding(vchPubKey, ver_flags, sigversion) {
if DBG_ERR {
fmt.Println("Invalid Signature Encoding A")
}
return false
}
if len(vchSig) > 0 {
var sh []byte
if sigversion == SIGVERSION_WITNESS_V0 {
if DBG_SCR {
fmt.Println("getting WitnessSigHash for inp", inp, "and htype", int32(vchSig[len(vchSig)-1]))
}
sh = tx.WitnessSigHash(p[sta:], amount, inp, int32(vchSig[len(vchSig)-1]))
} else {
sh = tx.SignatureHash(delSig(p[sta:], vchSig), inp, int32(vchSig[len(vchSig)-1]))
}
if DBG_SCR {
fmt.Println("EcdsaVerify", hex.EncodeToString(sh))
fmt.Println(" key:", hex.EncodeToString(vchPubKey))
fmt.Println(" sig:", hex.EncodeToString(vchSig))
}
fSuccess = btc.EcdsaVerify(vchPubKey, vchSig, sh)
if DBG_SCR {
fmt.Println(" ->", fSuccess)
}
}
if !fSuccess && DBG_SCR {
fmt.Println("EcdsaVerify fail 1", tx.Hash.String())
}
if !fSuccess && (ver_flags&VER_NULLFAIL) != 0 && len(vchSig) > 0 {
if DBG_ERR {
fmt.Println("SCRIPT_ERR_SIG_NULLFAIL-1")
}
return false
}
stack.pop()
stack.pop()
if DBG_SCR {
fmt.Println("ver:", fSuccess)
}