(self, test_node, *, mode=MiniWalletMode.ADDRESS_OP_TRUE, hrp="ert")
| 75 | |
| 76 | class MiniWallet: |
| 77 | def __init__(self, test_node, *, mode=MiniWalletMode.ADDRESS_OP_TRUE, hrp="ert"): |
| 78 | self._test_node = test_node |
| 79 | self._utxos = [] |
| 80 | self._priv_key = None |
| 81 | self._address = None |
| 82 | |
| 83 | assert isinstance(mode, MiniWalletMode) |
| 84 | if mode == MiniWalletMode.RAW_OP_TRUE: |
| 85 | self._scriptPubKey = bytes(CScript([OP_TRUE])) |
| 86 | elif mode == MiniWalletMode.RAW_P2PK: |
| 87 | # use simple deterministic private key (k=1) |
| 88 | self._priv_key = ECKey() |
| 89 | self._priv_key.set((1).to_bytes(32, 'big'), True) |
| 90 | pub_key = self._priv_key.get_pubkey() |
| 91 | self._scriptPubKey = key_to_p2pk_script(pub_key.get_bytes()) |
| 92 | elif mode == MiniWalletMode.ADDRESS_OP_TRUE: |
| 93 | self._address, self._internal_key = create_deterministic_address_bcrt1_p2tr_op_true(hrp=hrp) |
| 94 | self._scriptPubKey = bytes.fromhex(self._test_node.validateaddress(self._address)['scriptPubKey']) |
| 95 | |
| 96 | def rescan_utxos(self): |
| 97 | """Drop all utxos and rescan the utxo set""" |
nothing calls this directly
no test coverage detected