btc.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:joinmarket-clientserver 作者: JoinMarket-Org 项目源码 文件源码
def verify_tx_input(tx, i, script, sig, pub):
        pub, sig, script = (binascii.unhexlify(x) for x in [pub, sig, script])
        t = etr.Transaction(tx)
        t.deserialize()
        #to prepare for verification (to do the txhash for modtx)
        #we need to have the "address" field set in the input.
        typ, addr = etr.get_address_from_output_script(script)
        if not typ == ebt.TYPE_ADDRESS:
            #Don't support non-p2sh, non-p2pkh for now
            log.debug("Invalid script")
            return False
        t.inputs()[i]["address"] = addr
        t.inputs()[i]["type"] = 'p2pkh'
        txforsig = etr.Hash(t.serialize_preimage(i).decode('hex'))
        ecdsa_pub = get_ecdsa_verifying_key(pub)
        if not ecdsa_pub:
            return False
        try:
            verified = ecdsa_pub.verify_digest(sig, txforsig,
                                       sigdecode = sigdecode_der)
        except BadSignatureError, BadDigestError:
            return False
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号