Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cold stake bug - store more then one redeem script #395

Open
dangershony opened this issue Mar 15, 2022 · 0 comments
Open

Cold stake bug - store more then one redeem script #395

dangershony opened this issue Mar 15, 2022 · 0 comments

Comments

@dangershony
Copy link
Member

There is currently a bug for cold staking for P2SH and P2WSH addresses (the bug it not relevant when sending the coins to the cold stake scrip directly)

When setting up cold staking to a hash of a script the wallet will create an opreturn with the hot and cold pub key hashes so that a wallet can recover the redeem script.
Here is the code
https://github.com/block-core/blockcore/blob/master/src/Features/Blockcore.Features.ColdStaking/ColdStakingManager.cs#L431

When the wallet syncs it will look for opreturns and try to match it with local keys, if we find opreurn keys that the wallet has it will remember the redeem script (later when staking the redeem script is needed to build and sign the trx)
https://github.com/block-core/blockcore/blob/master/src/Features/Blockcore.Features.ColdStaking/ColdStakingManager.cs#L673

The issue is we only store one version of the redeem script, so if a cold stake setup uses a variation of keys on different setuip transactions for example the same hot key can be used with different cold keys, but when we come to store the redeem script we override the previous value and lose the data.
https://github.com/block-core/blockcore/blob/master/src/Features/Blockcore.Features.Miner/Staking/PosMinting.cs#L953

The fix:
To allow storing various combinations of the redeem script per address in the wallet json file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant