SatoshiPortal / boltz-rust

Boltz client rust crate
https://docs.boltz.exchange
30 stars 19 forks source link

Incoming chain swaps: refund only considers 1st UTXO #72

Closed ok300 closed 1 week ago

ok300 commented 1 month ago

For incoming chain swaps (BTC -> LBTC), in case of address re-use (e.g. user locks up funds via several txs to the swap lockup address), the refund will only consider the 1st utxo. This means it's not possible to refund any of the subsequent utxos. It's also not possible to claim them, as the claim is also triggered for the 1st utxo.

There are several variants of this:

In both cases, it would be useful if BtcSwapTx::new_refund would build a refund tx using all available utxos.

i5hi commented 1 month ago

Yes. Kind of related to this: https://github.com/SatoshiPortal/boltz-rust/issues/11

Although this is extremely rare, the library should handle such edge cases.

We should make fetch_utxos return a Vec<(Outpoint, TxOut)> rather than a single (Outpoint,Txout) and SwapTx to have utxos as a Vec rather than a single utxo

i5hi commented 1 month ago

Just noticed you have a PR for this too.

Nice! Reviewing it now.