Beispiel #1
0
def neo_get_address_from_scripthash(scripthash):
    """
    Core methods for manipulating keys
    NEP2 <=> WIF <=> Private => Public => ScriptHash <=> Address
    Keys are arranged in order of derivation.
    Arrows determine the direction.
    """
    scripthash_bytes = binascii.unhexlify(reverse_hex(scripthash))
    return scripthash_to_address(scripthash_bytes)
Beispiel #2
0
    def ToAddress(scripthash):
        """
        Transform a script hash to an address.

        Args:
            script_hash (UInt160): a bytearray (len 20) representing the public key.

        Returns:
            address (str): the base58check encoded address.
        """
        return scripthash_to_address(scripthash)
Beispiel #3
0
    def ToAddress(scripthash):
        """
        Transform a script hash to an address.

        Args:
            script_hash (UInt160): a bytearray (len 20) representing the public key.

        Returns:
            address (str): the base58check encoded address.
        """
        return scripthash_to_address(scripthash)
Beispiel #4
0
def gather_signatures(context, itx, owners):
    do_exit = False
    print("owners %s " % owners)
    print("\n\n*******************\n")
    print("Gather Signatures for Transaction:\n%s " %
          json.dumps(itx.ToJson(), indent=4))
    print("Please use a client to sign the following: %s " % itx.GetHashData())

    owner_index = 0
    while not context.Completed and not do_exit:

        next_script = owners[owner_index]
        next_addr = scripthash_to_address(next_script.Data)
        try:
            print("\n*******************\n")
            owner_input = prompt('Public Key and Signature for %s> ' %
                                 next_addr)
            items = owner_input.split(' ')
            pubkey = ECDSA.decode_secp256r1(items[0]).G
            sig = items[1]
            contract = Contract.CreateSignatureContract(pubkey)

            if contract.Address == next_addr:
                context.Add(contract, 0, sig)
                print("Adding signature %s " % sig)
                owner_index += 1
            else:
                print("Public Key does not match address %s " % next_addr)

        except EOFError:
            # Control-D pressed: quit
            do_exit = True
        except KeyboardInterrupt:
            # Control-C pressed: do nothing
            do_exit = True
        except Exception as e:
            print("Could not parse input %s " % e)

    if context.Completed:
        print("Signatures complete")
        itx.scripts = context.GetScripts()
        return True
    else:
        print("Could not finish signatures")
        return False