1
0

adb: (trivial) receive_tx_callback: make tx_height param kw-only

This commit is contained in:
SomberNight
2025-05-15 19:07:53 +00:00
parent 626264d24f
commit 61283fe18b
7 changed files with 132 additions and 132 deletions

View File

@@ -434,7 +434,7 @@ class AddressSynchronizer(Logger, EventListener):
children |= self.get_depending_transactions(other_hash)
return children
def receive_tx_callback(self, tx: Transaction, tx_height: int) -> None:
def receive_tx_callback(self, tx: Transaction, *, tx_height: int) -> None:
txid = tx.txid()
assert txid is not None
self.add_unverified_or_unconfirmed_tx(txid, tx_height)

View File

@@ -240,7 +240,7 @@ class Synchronizer(SynchronizerBase):
if tx_hash != tx.txid():
raise SynchronizerFailure(f"received tx does not match expected txid ({tx_hash} != {tx.txid()})")
tx_height = self.requested_tx.pop(tx_hash)
self.adb.receive_tx_callback(tx, tx_height)
self.adb.receive_tx_callback(tx, tx_height=tx_height)
self.logger.info(f"received tx {tx_hash} height: {tx_height} bytes: {len(raw_tx)}")
async def main(self):

View File

@@ -229,7 +229,7 @@ class TestCommandsTestnet(ElectrumTestCase):
funding_tx = Transaction('0200000000010165806607dd458280cb57bf64a16cf4be85d053145227b98c28932e953076b8e20000000000fdffffff02ac150700000000001600147e3ddfe6232e448a8390f3073c7a3b2044fd17eb102908000000000016001427fbe3707bc57e5bb63d6f15733ec88626d8188a02473044022049ce9efbab88808720aa563e2d9bc40226389ab459c4390ea3e89465665d593502206c1c7c30a2f640af1e463e5107ee4cfc0ee22664cfae3f2606a95303b54cdef80121026269e54d06f7070c1f967eb2874ba60de550dfc327a945c98eb773672d9411fd77181e00')
funding_txid = funding_tx.txid()
self.assertEqual('ede61d39e501d65ccf34e6300da439419c43393f793bb9a8a4b06b2d0d80a8a0', funding_txid)
wallet.adb.receive_tx_callback(funding_tx, TX_HEIGHT_UNCONFIRMED)
wallet.adb.receive_tx_callback(funding_tx, tx_height=TX_HEIGHT_UNCONFIRMED)
cmds = Commands(config=self.config)
tx_str = await cmds.payto(
@@ -257,7 +257,7 @@ class TestCommandsTestnet(ElectrumTestCase):
funding_tx = Transaction('0200000000010165806607dd458280cb57bf64a16cf4be85d053145227b98c28932e953076b8e20000000000fdffffff02ac150700000000001600147e3ddfe6232e448a8390f3073c7a3b2044fd17eb102908000000000016001427fbe3707bc57e5bb63d6f15733ec88626d8188a02473044022049ce9efbab88808720aa563e2d9bc40226389ab459c4390ea3e89465665d593502206c1c7c30a2f640af1e463e5107ee4cfc0ee22664cfae3f2606a95303b54cdef80121026269e54d06f7070c1f967eb2874ba60de550dfc327a945c98eb773672d9411fd77181e00')
funding_txid = funding_tx.txid()
self.assertEqual('ede61d39e501d65ccf34e6300da439419c43393f793bb9a8a4b06b2d0d80a8a0', funding_txid)
wallet.adb.receive_tx_callback(funding_tx, TX_HEIGHT_UNCONFIRMED)
wallet.adb.receive_tx_callback(funding_tx, tx_height=TX_HEIGHT_UNCONFIRMED)
cmds = Commands(config=self.config)
@@ -291,7 +291,7 @@ class TestCommandsTestnet(ElectrumTestCase):
funding_tx = Transaction('02000000000101f59876b1c65bbe3e182ccc7ea7224fe397bb9b70aadcbbf4f4074c75c8a074840000000000fdffffff021f351f00000000001600144eec851dd980cc36af1f629a32325f511604d6af56732d000000000016001439267bc7f3e3fabeae3bc3f73880de22d8b01ba50247304402207eac5f639806a00878488d58ca651d690292145bca5511531845ae21fab309d102207162708bd344840cc1bacff1092e426eb8484f83f5c068ba4ca579813de324540121020e0798c267ff06ee8b838cd465f3cfa6c843a122a04917364ce000c29ca205cae5f31f00')
funding_txid = funding_tx.txid()
self.assertEqual('e8e977bd9c857d84ec1b8f154ae2ee5dfa49fffb7688942a586196c1ad15de15', funding_txid)
wallet.adb.receive_tx_callback(funding_tx, TX_HEIGHT_UNCONFIRMED)
wallet.adb.receive_tx_callback(funding_tx, tx_height=TX_HEIGHT_UNCONFIRMED)
cmds = Commands(config=self.config)
tx_str = await cmds.paytomany(
@@ -328,7 +328,7 @@ class TestCommandsTestnet(ElectrumTestCase):
funding_txid = funding_tx.txid()
funding_output_value = 1000000
self.assertEqual('add2535aedcbb5ba79cc2260868bb9e57f328738ca192937f2c92e0e94c19203', funding_txid)
wallet.adb.receive_tx_callback(funding_tx, TX_HEIGHT_UNCONFIRMED)
wallet.adb.receive_tx_callback(funding_tx, tx_height=TX_HEIGHT_UNCONFIRMED)
cmds = Commands(config=self.config)
@@ -346,7 +346,7 @@ class TestCommandsTestnet(ElectrumTestCase):
funding_tx = Transaction("02000000000102789e8aa8caa79d87241ff9df0e3fd757a07c85a30195d76e8efced1d57c56b670000000000fdffffff7ee2b6abd52b332f797718ae582f8d3b979b83b1799e0a3bfb2c90c6e070c29e0100000000fdffffff020820000000000000160014c0eb720c93a61615d2d66542d381be8943ca553950c3000000000000160014d7dbd0196a2cbd76420f14a19377096cf6cddb75024730440220485b491ad8d3ce3b4da034a851882da84a06ec9800edff0d3fd6aa42eeba3b440220359ea85d32a05932ac417125e133fa54e54e7e9cd20ebc54b883576b8603fd65012103860f1fbf8a482b9d35d7d4d04be8fb33d856a514117cd8b73e372d36895feec60247304402206c2ca56cc030853fa59b4b3cb293f69a3378ead0f10cb76f640f8c2888773461022079b7055d0f6af6952a48e5b97218015b0723462d667765c142b41bd35e3d9c0a01210359e303f57647094a668d69e8ff0bd46c356d00aa7da6dc533c438e71c057f0793e721f00")
funding_txid = funding_tx.txid()
wallet.adb.receive_tx_callback(funding_tx, TX_HEIGHT_UNCONFIRMED)
wallet.adb.receive_tx_callback(funding_tx, tx_height=TX_HEIGHT_UNCONFIRMED)
cmds = Commands(config=self.config)
orig_rawtx = "02000000000101b9723dfc69af058ef6613539a000d2cd098a2c8a74e802b6d8739db708ba8c9a0100000000fdffffff02a00f00000000000016001429e1fd187f0cac845946ae1b11dc136c536bfc0fe8b2000000000000160014100611bcb3aee7aad176936cf4ed56ade03027aa02473044022063c05e2347f16251922830ccc757231247b3c2970c225f988e9204844a1ab7b802204652d2c4816707e3d3bea2609b83b079001a435bad2a99cc2e730f276d07070c012102ee3f00141178006c78b0b458aab21588388335078c655459afe544211f15aee050721f00"

View File

@@ -34,7 +34,7 @@ class TestWalletPaymentRequests(ElectrumTestCase):
funding_tx = Transaction('0200000000010132515e6aade1b79ec7dd3bac0896d8b32c56195d23d07d48e21659cef24301560100000000fdffffff0112841e000000000016001477fe6d2a27e8860c278d4d2cd90bad716bb9521a02473044022041ed68ef7ef122813ac6a5e996b8284f645c53fbe6823b8e430604a8915a867802203233f5f4d347a687eb19b2aa570829ab12aeeb29a24cc6d6d20b8b3d79e971ae012102bee0ee043817e50ac1bb31132770f7c41e35946ccdcb771750fb9696bdd1b307ad951d00')
funding_txid = funding_tx.txid()
assert 'db949963c3787c90a40fb689ffdc3146c27a9874a970d1fd20921afbe79a7aa9' == funding_txid
wallet2.adb.receive_tx_callback(funding_tx, TX_HEIGHT_UNCONFIRMED)
wallet2.adb.receive_tx_callback(funding_tx, tx_height=TX_HEIGHT_UNCONFIRMED)
return wallet2
async def test_wallet_with_ln_creates_payreq_and_gets_paid_on_ln(self):
@@ -74,7 +74,7 @@ class TestWalletPaymentRequests(ElectrumTestCase):
outputs = [PartialTxOutput.from_address_and_value(pr.get_address(), pr.get_amount_sat())]
tx = wallet2.make_unsigned_transaction(outputs=outputs, fee_policy=FixedFeePolicy(5000))
wallet2.sign_transaction(tx, password=None)
wallet1.adb.receive_tx_callback(tx, TX_HEIGHT_UNCONFIRMED)
wallet1.adb.receive_tx_callback(tx, tx_height=TX_HEIGHT_UNCONFIRMED)
self.assertEqual(PR_UNCONFIRMED, wallet1.get_invoice_status(pr))
# tx gets mined
wallet1.db.put('stored_height', 1010)
@@ -105,7 +105,7 @@ class TestWalletPaymentRequests(ElectrumTestCase):
outputs = [PartialTxOutput.from_address_and_value(pr.get_address(), pr.get_amount_sat())]
tx = wallet2.make_unsigned_transaction(outputs=outputs, fee_policy=FixedFeePolicy(5000))
wallet2.sign_transaction(tx, password=None)
wallet1.adb.receive_tx_callback(tx, TX_HEIGHT_UNCONFIRMED)
wallet1.adb.receive_tx_callback(tx, tx_height=TX_HEIGHT_UNCONFIRMED)
self.assertEqual(PR_UNCONFIRMED, wallet1.get_invoice_status(pr))
# tx gets mined
wallet1.db.put('stored_height', 1010)
@@ -136,7 +136,7 @@ class TestWalletPaymentRequests(ElectrumTestCase):
outputs = [PartialTxOutput.from_address_and_value(pr.get_address(), pr.get_amount_sat())]
tx = wallet2.make_unsigned_transaction(outputs=outputs, fee_policy=FixedFeePolicy(5000))
wallet2.sign_transaction(tx, password=None)
wallet1.adb.receive_tx_callback(tx, TX_HEIGHT_UNCONFIRMED)
wallet1.adb.receive_tx_callback(tx, tx_height=TX_HEIGHT_UNCONFIRMED)
self.assertEqual(PR_UNCONFIRMED, wallet1.get_invoice_status(pr))
# tx mined in the past (before invoice creation)
tx_info = TxMinedInfo(height=990,
@@ -206,7 +206,7 @@ class TestWalletPaymentRequests(ElectrumTestCase):
outputs = [PartialTxOutput.from_address_and_value(pr2.get_address(), pr2.get_amount_sat())]
tx = wallet2.make_unsigned_transaction(outputs=outputs, fee_policy=FixedFeePolicy(5000))
wallet2.sign_transaction(tx, password=None)
wallet1.adb.receive_tx_callback(tx, TX_HEIGHT_UNCONFIRMED)
wallet1.adb.receive_tx_callback(tx, tx_height=TX_HEIGHT_UNCONFIRMED)
self.assertEqual(PR_UNCONFIRMED, wallet1.get_invoice_status(pr2))
self.assertEqual(pr2, wallet1.get_request_by_addr(addr1))

View File

@@ -41,7 +41,7 @@ class MockNetwork(Logger):
async def try_broadcasting(self, tx, name):
for w in self.wallets:
w.adb.receive_tx_callback(tx, TX_HEIGHT_UNCONFIRMED)
w.adb.receive_tx_callback(tx, tx_height=TX_HEIGHT_UNCONFIRMED)
self._tx_queue.put_nowait(tx)
return tx.txid()
@@ -121,7 +121,7 @@ class TestTxBatcher(ElectrumTestCase):
assert output1 in tx1_prime.outputs()
assert output2 in tx1_prime.outputs()
# tx1 gets confirmed, tx2 gets removed
wallet.adb.receive_tx_callback(tx1, 1)
wallet.adb.receive_tx_callback(tx1, tx_height=1)
tx_mined_status = wallet.adb.get_tx_height(tx1.txid())
wallet.adb.add_verified_tx(tx1.txid(), tx_mined_status._replace(conf=1))
assert wallet.adb.get_transaction(tx1.txid()) is not None
@@ -187,7 +187,7 @@ class TestTxBatcher(ElectrumTestCase):
is_redeemed=False,
)
wallet.adb.db.transactions[swap_data.funding_txid] = tx = Transaction(SWAP_FUNDING_TX)
wallet.adb.receive_tx_callback(tx, 1)
wallet.adb.receive_tx_callback(tx, tx_height=1)
txin = PartialTxInput(
prevout=TxOutpoint(txid=bytes.fromhex(swap_data.funding_txid), out_idx=0),
)

View File

@@ -133,7 +133,7 @@ class TestWalletStorage(WalletTestCase):
del wallet1
wallet1 = Daemon._load_wallet(self.wallet_path, password=None, config=self.config)
tx = tx_from_any("02000000000101a97a9ae7fb1a9220fdd170a974987ac24631dcff89b60fa4907c78c3639994db0000000000fdffffff0210270000000000001976a914ea7804a2c266063572cc009a63dc25dcc0e9d9b588ac20491e0000000000160014b8e4fdc91593b67de2bf214694ef47e38dc2ee8e02473044022005326882904906cfa9c1de75333ace1019596f2ab25d21118220d037dfc0e48b02207d0b3f075cfe5e1e0247ff3cdd7155dc05e7459daf1bfa0ea02e9112b9151ec90121026cc6a74c2b0e38661d341ffae48fe7dde5196ca4afe95d28b496673fa4cf646700000000")
wallet1.adb.receive_tx_callback(tx, TX_HEIGHT_UNCONFIRMED)
wallet1.adb.receive_tx_callback(tx, tx_height=TX_HEIGHT_UNCONFIRMED)
self.assertEqual(PR_UNCONFIRMED, wallet1.get_invoice_status(pr))
await wallet1.stop()

File diff suppressed because one or more lines are too long