def deserialize(cls, data): out = int.from_bytes(data[:8], "big") script_len = int.from_bytes(data[8:10], "big") locking_script = Script.deserialize(data[10:10 + script_len]) return TxOut(out, locking_script)
def get_utxo(self, id): self.cursor.execute("SELECT * FROM utxo WHERE id = ?", (id, )) utxo = self.cursor.fetchall() return TxOut(utxo[0][1], Script.deserialize( utxo[0][2])) if utxo else None
def deserialize(cls, data): prevout = OutPoint.deserialize(data) script_len = int.from_bytes(data[34:36], "big") unlocking_script = Script.deserialize(data[36:36 + script_len]) return TxIn(prevout, unlocking_script)