As part of adding inner witness versions and MAST proofs to our implementation of segwit, there is no longer a relationship between the segwit script hash and the 20-byte P2SH script hash, as there is with bitcoin. As a consequence, the wallet now maintains a separate database of witness scripts, so it is possible that a wallet will recognize some P2SH outputs as its own, but not their P2WSH counterparts, or vice versa. When a bitcoin user adds a redeem script to their wallet the segwit version of that script is automatically known, but in our implementation the witness script needs to be registered for the witness version to be recognized.
Right now, what's implemented is the minimum behavior necessary to satisfy unit and functional tests, with the smallest diff from bitcoin's implementation. Segwit scripts are not automatically registered when new keys are generated, nor does adding a script automatically add the segwit version. Also, weirdly, registering a 1... address as a witness script registers both the P2WPKH and P2WSH-wrapped P2PKH scripts... but that's an oddity that bitcoin does as well, so for now we leave it in.
This issue is to track the task of investigating the registration with witness redeem scripts, implicitly or explicitly, and to make changes necessary for the RPC API to have the right balance of ease of use and future maintainability.
As part of adding inner witness versions and MAST proofs to our implementation of segwit, there is no longer a relationship between the segwit script hash and the 20-byte P2SH script hash, as there is with bitcoin. As a consequence, the wallet now maintains a separate database of witness scripts, so it is possible that a wallet will recognize some P2SH outputs as its own, but not their P2WSH counterparts, or vice versa. When a bitcoin user adds a redeem script to their wallet the segwit version of that script is automatically known, but in our implementation the witness script needs to be registered for the witness version to be recognized.
Right now, what's implemented is the minimum behavior necessary to satisfy unit and functional tests, with the smallest diff from bitcoin's implementation. Segwit scripts are not automatically registered when new keys are generated, nor does adding a script automatically add the segwit version. Also, weirdly, registering a 1... address as a witness script registers both the P2WPKH and P2WSH-wrapped P2PKH scripts... but that's an oddity that bitcoin does as well, so for now we leave it in.
This issue is to track the task of investigating the registration with witness redeem scripts, implicitly or explicitly, and to make changes necessary for the RPC API to have the right balance of ease of use and future maintainability.