decred / dcrwallet

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

Rescanned wallets can have missing spend tracking due to script import order #890

Open jrick opened 7 years ago

jrick commented 7 years ago

On rescan, if a relevant transaction is added to the wallet with a P2SH output for a multisig redeem script, if the redeem script has not yet been seen, the output is not marked as a credit because it is unknown if it is relevant to the wallet. Later (either later during the rescan, or after) when the script is seen, the earlier P2SH outputs are not reconsidered and there is no recorded credit/debit relationship between the two transactions.

This can be commonly encountered by stakepool users since the voting rights are assigned to a 1-of-2 multisig P2SH address.

A workaround for this issue is to force a second rescan from the genesis blocks. As all scripts should be imported at this point, when transactions are reprocessed, the missing credits and debits will be recorded.

yashmankad commented 6 years ago

I am going to take a crack at this. @jrick will reach out for help