decred / dcrwallet

A secure Decred wallet daemon written in Go (golang).
https://decred.org
ISC License
219 stars 155 forks source link

Transaction not spendable #1740

Open jholdstock opened 4 years ago

jholdstock commented 4 years ago

I own the address TsiYnTiBdVshdDTMi4P88v4WrHUUDv3Updx which I have used for mining on testnet. Occasionally I will receive transactions which I am then unable to spend.

For example, dc98c495538d5c2b412da8265a83134746c74529db553ab7f78e8df1440b4360 pays to my address, and I see a dcrwallet log line indicating so:

2020-05-12 14:54:30.126 [DBG] WLLT: Marking transaction dc98c495538d5c2b412da8265a83134746c74529db553ab7f78e8df1440b4360 output 2 (1.93182412 DCR) spendable

However, upon an attempt to spend the output ~20 minutes later I get:

2020-05-12 15:16:05.152 [ERR] GRPC: Unary method /walletrpc.WalletService/SignTransaction invoked by 127.0.0.1:33952 errored: rpc error: code = Unknown desc = wallet.SignTransaction: dc98c495538d5c2b412da8265a83134746c74529db553ab7f78e8df1440b4360:2 not found

The wallet was running non-stop throughout this period. The outputs received in transactions immediately before this one, and immediately after this one, are both spendable.

Providing the full log for this time period here: https://pastebin.com/TxZTNJ8b. It may be note-worthy that the log line indicating the output is spendable actually appeared twice, apparently due to a re-org.

Transaction is not returned when querying the wallet with dcrctl:

$ dcrctl --wallet gettransaction dc98c495538d5c2b412da8265a83134746c74529db553ab7f78e8df1440b4360
-5: no information for transaction

The above behaviour was seen on dcrwallet release 1.5.1, built from source locally. The issue is resolved by a wallet rescan - the transaction can be retrieved using gettransaction and the output becomes spendable.

jrick commented 3 years ago

This is an issue with our reorg handling under the rpc syncer (the syncers themselves are responsible with providing the relevant txs for blocks they are trying to attach). When a block is reorged out of the main chain, and a later reorg adds it back in, the relevant txs from this block are not recorded in the wallet any longer.