Exemplo n.º 1
0
 def make_wrapped_segwit_address(cls, address_pubkey) -> CCoinAddress:
     redeem_script = cls.make_wrapped_segwit_redeem_script(address_pubkey)
     redeem_script_hash = Hash160(redeem_script)
     script_pubkey = CScript([OP_HASH160, redeem_script_hash, OP_EQUAL])
     return P2SHAddress.from_scriptPubKey(script_pubkey)
Exemplo n.º 2
0
        # classes. mypy does cannot know about dynamic class dispatch.
        input_tx = CElementsTransaction.deserialize(x(f.readline().rstrip()))

    # Read in the key, expected to be in WIF format.
    with open(sys.argv[2]) as f:
        key = CCoinKey(f.readline().rstrip())

    # Read in the unblinding key, expected to be in HEX format.
    with open(sys.argv[3]) as f:
        bkey = CCoinKey.from_secret_bytes(x(f.readline().rstrip()))

    dst_addr = CElementsAddress(sys.argv[4])

    # Construct P2SH_P2WPKH address from the loaded key
    spk = CScript([0, Hash160(key.pub)]).to_p2sh_scriptPubKey()
    src_addr = P2SHCoinAddress.from_scriptPubKey(spk)

    sys.stderr.write(
        '\nSearching for ouptut with address {}\n'.format(src_addr))

    utxo = None
    fee_asset = None
    # Search for output in the transaction that spends to the address that
    # we have. We are going to spend the first output that we find.
    for in_n, in_vout in enumerate(input_tx.vout):
        if utxo is None and in_vout.scriptPubKey == src_addr.to_scriptPubKey():
            utxo = in_vout
            utxo_n = in_n
        if in_vout.is_fee():
            assert fee_asset is None or fee_asset == in_vout.nAsset,\
                "expecting only one fee asset"