Skip to content

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

@dangershony

Description

@dangershony

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions