本文整理匯總了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)
}