From 39c37c9549c0808d7f9105adeb2ef4e6b61fcbd4 Mon Sep 17 00:00:00 2001 From: Cryp Toon Date: Wed, 10 Jul 2024 20:23:33 +0200 Subject: [PATCH 1/2] Fix using correct database in anti fee sniping unittest --- tests/test_wallets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_wallets.py b/tests/test_wallets.py index d2f3a014..26f3d7e3 100644 --- a/tests/test_wallets.py +++ b/tests/test_wallets.py @@ -2374,12 +2374,14 @@ def test_wallet_anti_fee_sniping(self): block_height = Service(network='testnet', cache_uri='').blockcount() self.assertAlmostEqual(t.locktime, block_height+1, delta=3) - w2 = wallet_create_or_open('antifeesnipingtestwallet2', network='testnet', anti_fee_sniping=True) + w2 = wallet_create_or_open('antifeesnipingtestwallet2', network='testnet', anti_fee_sniping=True, + db_uri=self.database_uri) w2.utxo_add(w2.get_key().address, 1234567, os.urandom(32).hex(), 1) t = w2.send_to('tb1qrjtz22q59e76mhumy0p586cqukatw5vcd0xvvz', 123456, locktime=1901070183) self.assertEqual(t.locktime, 1901070183) - w3 = wallet_create_or_open('antifeesnipingtestwallet3', network='testnet', anti_fee_sniping=False) + w3 = wallet_create_or_open('antifeesnipingtestwallet3', network='testnet', anti_fee_sniping=False, + db_uri=self.database_uri) w3.utxo_add(w3.get_key().address, 1234567, os.urandom(32).hex(), 1) t = w3.send_to('tb1qrjtz22q59e76mhumy0p586cqukatw5vcd0xvvz', 123456) self.assertEqual(t.locktime, 0) From d41f0a51547ed20acb2ecec72ba95fcfb02b31f2 Mon Sep 17 00:00:00 2001 From: Cryp Toon Date: Wed, 10 Jul 2024 23:47:53 +0200 Subject: [PATCH 2/2] Determine witness type at input level --- bitcoinlib/services/services.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bitcoinlib/services/services.py b/bitcoinlib/services/services.py index 785c4bb4..48b6cc79 100644 --- a/bitcoinlib/services/services.py +++ b/bitcoinlib/services/services.py @@ -732,8 +732,7 @@ def _parse_db_transaction(db_tx): if n.ref_txid == b'\00' * 32: t.coinbase = True t.add_input(n.ref_txid.hex(), n.ref_index_n, unlocking_script=n.script, address=n.address, - sequence=n.sequence, value=n.value, index_n=n.index_n, witnesses=n.witnesses, strict=False, - witness_type=db_tx.witness_type.value) + sequence=n.sequence, value=n.value, index_n=n.index_n, witnesses=n.witnesses, strict=False) else: t.add_output(n.value, n.address, lock_script=n.script, spent=n.spent, output_n=n.index_n, spending_txid=None if not n.ref_txid else n.ref_txid.hex(),