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.
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.
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 callingset_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.