cygnet3 / danawallet

A mobile wallet for accepting bitcoin donations
MIT License
20 stars 4 forks source link

Handle desynced wallet; unknown confirmed spending tx #39

Open cygnet3 opened 2 months ago

cygnet3 commented 2 months ago

Right now we error when the user detects an input has been spent, but we cannot find the recorded 'spending transaction' (probably because that input has been spent by the other wallet). I was thinking to just change this to a warning, since it's kinda extreme to crash immediately when this happens. but this leaves the question about what to do with the transaction history.

1: the simplest option is to not do anything. we mark the inputs as 'spent' and don't show anything in the tx history. however, this has the issue that this will look weird in the tx history page. you will see a bunch of incoming txs, and no outgoing txs, but your balance is still quite low. i think that can cause a lot of questions for noobies.

2: a sophisticated option is to 'guess' the recorded outgoing transaction. we lookup all the inputs and outputs, we mark all the inputs as spent. the big issue with this is that we would need to look up the transaction from some source, so that creates a privacy concern.

3: we record a very simple 'dummy' outgoing transaction for every input spent. blindbit only tells you about the spent inputs on a block-level, so we could make the guess that every input from the block is spent in the same transaction, and group them all as a single outgoing tx (with unknown txid). maybe mark those differently from a regular outgoing transaction.

4: a last option would be to instead change the previously made incoming transactions, and remove the affected outpoints. so instead of adding an extra outgoing tx, we remove some incoming txs.

Related PR for sp-client: https://github.com/cygnet3/sp-client/pull/43