Multibit-Legacy / multibit-hd

Deprecated Bitcoin Wallet
https://multibit.org/blog/2017/07/26/multibit-shutdown.html
Other
169 stars 124 forks source link

Missing confirmation #794

Closed jim618 closed 8 years ago

jim618 commented 8 years ago

"I recieved a miner's payment to this address in my MultiBit HD wallet"

Transaction received but not confirmed

jim618 commented 8 years ago

One approach would be: At wallet startup see if there are any unconfirmed transactions in the 'last period of time' and then sync from there instead of the last block seen.

So, if you had an unconfirmed transaction from a few days ago then MBHD would replay from before then.

The SPVBlockStore can only (currently) replay from the last checkpoint (> a month ago) so this would be a bit expensive. The SPVBLockStore contains 5K heads (about a month) so perhaps this could be optimised so that you could replay only a few days

jim618 commented 8 years ago

I've checked in code that enables the SPVBLockStore to be used to replay from more recent in time than the last checkpoint.

When you do a replay, it now:

There is a complication that you need to have a difficulty transition in the SPVBlockStore (to build on it correctly) so the replay code checks this. If there is no difficulty transition it falls back to using checkpoints.

To test this you want a wallet that is a few weeks old so that the replay date is within the range of the SPVBLockStore (5000 blocks. Just over a month).

The functionality is mainly useful for the 'replay from a short while ago to catch unconfirmed transactions appearing in a block'. I'll do that next.

jim618 commented 8 years ago

I've pushed code that when the wallet opens it checks whether there are unconfirmed tx in the window of interest from 4 hours to 4 days. If there are it performs a replay to double check if the tx have confirmed.

If you want to force it to replay more quickly, look at the UnconfirmedTransactionDetector and change the LOWER_LIMIT_OF_TIME_WINDOW. There is a commented line in the code to change it to a minute.

I haven't put in code that limits the number of times it does a replay as we discussed. It's simpler for it to try every time - like bitcoinj/ MBHD does for retransmitting tx that haven't been seen by the network.

As long as the blockstore is fully populated it'll only be syncing a few hundred blocks so I don't think the user will notice (and they'll want their tx confirmed).

PROTIP: To test it send your wallet tx with really low fees as they don't confirm quickly.

Awaiting review and closing

jim618 commented 8 years ago

Added unit test

gary-rowe commented 8 years ago

Verified working. Closing.