Example #1
0
    def from_dict(cls: Type["PsbtOut"],
                  dict_: Mapping[str, Any],
                  check_validity: bool = True) -> "PsbtOut":

        return cls(
            dict_["redeem_script"],
            dict_["witness_script"],
            # FIXME
            decode_from_bip32_derivs(dict_["bip32_derivs"]),  # type: ignore
            dict_["unknown"],
            check_validity,
        )
Example #2
0
    def from_dict(cls: Type["Psbt"],
                  dict_: Mapping[str, Any],
                  check_validity: bool = True) -> "Psbt":

        return cls(
            Tx.from_dict(dict_["tx"]),
            [PsbtIn.from_dict(psbt_in, False) for psbt_in in dict_["inputs"]],
            [
                PsbtOut.from_dict(psbt_out, False)
                for psbt_out in dict_["outputs"]
            ],
            dict_["version"],
            # FIXME
            decode_from_bip32_derivs(dict_["bip32_derivs"]),  # type: ignore
            dict_["unknown"],
            check_validity,
        )
def test_bip32_derivs() -> None:
    # the basic type dict representation
    bip32_derivs = [
        {
            "pub_key": "029583bf39ae0a609747ad199addd634fa6108559d6c5cd39b4c2183f1ab96e07f",
            "master_fingerprint": "d90c6a4f",
            "path": "m/0" + _HARDENING + "/0/0",
        },
        {
            "pub_key": "02dab61ff49a14db6a7d02b0cd1fbb78fc4b18312b5b4e54dae4dba2fbfef536d7",
            "master_fingerprint": "d90c6a4f",
            "path": "m/0" + _HARDENING + "/0/1",
        },
    ]
    hd_key_paths = decode_from_bip32_derivs(bip32_derivs)
    assert bip32_derivs == encode_to_bip32_derivs(hd_key_paths)

    assert_valid_hd_key_paths(hd_key_paths)
Example #4
0
    def from_dict(cls: Type["PsbtIn"],
                  dict_: Mapping[str, Any],
                  check_validity: bool = True) -> "PsbtIn":

        return cls(
            Tx.from_dict(dict_["non_witness_utxo"], False)
            if dict_["non_witness_utxo"] else None,
            TxOut.from_dict(dict_["witness_utxo"], False)
            if dict_["witness_utxo"] else None,
            dict_["partial_signatures"],
            dict_["sig_hash"],
            dict_["redeem_script"],
            dict_["witness_script"],
            # FIXME
            decode_from_bip32_derivs(dict_["bip32_derivs"]),  # type: ignore
            dict_["final_script_sig"],
            Witness.from_dict(dict_["final_script_witness"], False),
            dict_["ripemd160_preimages"],
            dict_["sha256_preimages"],
            dict_["hash160_preimages"],
            dict_["hash256_preimages"],
            dict_["unknown"],
            check_validity,
        )