本文整理汇总了Python中bitcoin.core.CTransaction.copy方法的典型用法代码示例。如果您正苦于以下问题:Python CTransaction.copy方法的具体用法?Python CTransaction.copy怎么用?Python CTransaction.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitcoin.core.CTransaction
的用法示例。
在下文中一共展示了CTransaction.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SignatureHash
# 需要导入模块: from bitcoin.core import CTransaction [as 别名]
# 或者: from bitcoin.core.CTransaction import copy [as 别名]
def SignatureHash(script, txTo, inIdx, hashtype):
if inIdx >= len(txTo.vin):
return (0, "inIdx %d out of range (%d)" % (inIdx, len(txTo.vin)))
txtmp = CTransaction()
txtmp.copy(txTo)
for txin in txtmp.vin:
txin.scriptSig = b''
txtmp.vin[inIdx].scriptSig = script.vch
if (hashtype & 0x1f) == SIGHASH_NONE:
txtmp.vout = []
for i in range(len(txtmp.vin)):
if i != inIdx:
txtmp.vin[i].nSequence = 0
elif (hashtype & 0x1f) == SIGHASH_SINGLE:
outIdx = inIdx
if outIdx >= len(txtmp.vout):
return (0, "outIdx %d out of range (%d)" % (outIdx, len(txtmp.vout)))
tmp = txtmp.vout[outIdx]
txtmp.vout = []
for i in range(outIdx):
txtmp.vout.append(CTxOut())
txtmp.vout.append(tmp)
for i in range(len(txtmp.vin)):
if i != inIdx:
txtmp.vin[i].nSequence = 0
if hashtype & SIGHASH_ANYONECANPAY:
tmp = txtmp.vin[inIdx]
txtmp.vin = []
txtmp.vin.append(tmp)
s = txtmp.serialize()
s += struct.pack(b"<I", hashtype)
hash = Hash(s)
return (hash,)