server.py 文件源码

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

项目:two1-python 作者: 21dotco 项目源码 文件源码
def open(self, deposit_tx, redeem_script):
        # Deserialize deposit tx and redeem script
        deposit_tx = bitcoin.Transaction.from_hex(deposit_tx)
        try:
            redeem_script = PaymentChannelRedeemScript.from_bytes(codecs.decode(redeem_script, 'hex_codec'))
        except ValueError:
            raise AssertionError("Invalid payment channel redeem script.")

        # Validate deposit tx
        assert len(deposit_tx.outputs) > 1, "Invalid deposit tx outputs."
        output_index = deposit_tx.output_index_for_address(redeem_script.hash160())
        assert output_index is not None, "Missing deposit tx P2SH output."
        assert deposit_tx.outputs[output_index].script.is_p2sh(), "Invalid deposit tx output P2SH script."
        assert deposit_tx.outputs[output_index].script.get_hash160() == redeem_script.hash160(), "Invalid deposit tx output script P2SH address."  # nopep8

        # Store channel
        deposit_txid = str(deposit_tx.hash)
        self._store_channel(
            deposit_txid, {'deposit_tx': deposit_tx, 'redeem_script': redeem_script, 'payment_tx': None})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号