L2-Technology / sensei

A lightning node implementation for everyone
https://l2.technology/sensei
Other
198 stars 39 forks source link

duplicate utxos are created when you broadcast a tx (channel open) #57

Closed johncantrell97 closed 2 years ago

johncantrell97 commented 2 years ago

The bdk::database::SqliteDatabase::set_utxo method is intended to be an upsert (create_or_update) by outpoint but is currently implemented as a straight create meaning two calls to set_utxo will insert two of the same utxos into your bdk database. I think this happens when you broadcast a tx (as we process this tx immediately) and then gets set again when the tx is confirmed and is received as part of the block_connected flow.

I opened an issue upstream https://github.com/bitcoindevkit/bdk/issues/591 but I think we can prevent it in listener_database by trying to find the utxo first before calling set_utxo.

This is also not going to be relevant once there's a generic database layer in Sensei that needs to have bdk::Database implemented on it. We can make sure to not have this issue there.

johncantrell97 commented 2 years ago

fixed in #37