Пример #1
0
 def _get_address(self, coin, address_n, multisig):
     if multisig:
         # check if we own the pubkey
         pubkey = BIP32(self.storage.get_node()).get_public_node(address_n).public_key
         try:
             pubkeys = [ public_ckd(n.node, list(n.address_n)).public_key for n in multisig.pubkeys ]
             sig_index = list(pubkeys).index(pubkey)
         except ValueError:
             return proto.Failure(code=proto_types.Failure_Other, message="Pubkey not found in multisig script")
         # convert script to P2SH address
         script = transaction.compile_script_multisig(multisig)
         h160 = tools.hash_160(script)
         address = tools.hash_160_to_bc_address(h160, coin.address_type_p2sh)
     else:
         address = BIP32(self.storage.get_node()).get_address(coin, address_n)
     self.layout.show_receiving_address(address)
     self.custom_message = True  # Yes button will redraw screen
     return proto.Address(address=address)
Пример #2
0
def compile_TxOutput(txout):
    ret = types.TxOutputBinType()
    ret.amount = txout.amount

    if len(list(txout.address_n)):
        raise Exception("address_n should be converted to address already")

    if txout.script_type == types.PAYTOADDRESS:
        script = '\x76\xa9'  # op_dup, op_hash_160
        script += '\x14'  # push 0x14 bytes
        script += tools.bc_address_to_hash_160(txout.address)
        script += '\x88\xac'  # op_equalverify, op_checksig
        ret.script_pubkey = script

    elif txout.script_type == types.PAYTOSCRIPTHASH:
        script = '\xa9'  # op_hash_160
        script += '\x14'  # push 0x14 bytes
        script += tools.bc_address_to_hash_160(txout.address)
        script += '\x87'  # op_equal
        ret.script_pubkey = script

    elif txout.script_type == types.PAYTOMULTISIG:
        s = compile_script_multisig(txout.multisig)
        h160 = tools.hash_160(s)
        script = '\xa9'  # op_hash_160
        script += '\x14'  # push 0x14 bytes
        script += h160
        script += '\x87'  # op_equal
        ret.script_pubkey = script

    elif txout.script_type == types.PAYTOOPRETURN:
        if txout.amount > 0:
            raise Exception("OP_RETURN output must not contain any satoshis")
        ret.script_pubkey = '\x6a' + op_push(len(txout.op_return_data)) + txout.op_return_data

    else:
        raise Exception("Unknown script type")

    return ret
Пример #3
0
def fingerprint(pubkey):
    return string_to_number(tools.hash_160(pubkey)[:4])
Пример #4
0
def fingerprint(pubkey):
    return string_to_number(tools.hash_160(pubkey)[:4])