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

Record cleartext p2sh redeem scripts in address manager #1688

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

jrick
Copy link
Member

@jrick jrick commented Mar 6, 2020

Pay-to-script-hash (P2SH) addresses managed by the wallet must record
the nested script as well. These scripts are required to redeem a
P2SH output as it must appear in the signature script.

Since the redeem script itself might be the secret to redeem an output
(as in the case for some transaction script puzzles), rather than
needing a private key to produce a signature, btcwallet treated all
redeem scripts as secrets and required they be encrypted using the
private data symmetric encryption key. However, since mainnet launch,
dcrwallet has also recorded redeem scripts unencrypted in the
transaction store buckets (this was added to support the hacked-on
multisignature support). A database upgrade is performed to move
these unencrypted scripts into the address manager's data so that the
redeem script for a managed P2SH address is always known. The
udb.ScriptAddress interface has been extended to provide this redeem
script and the script version it is to be interpreted as.

The listscripts JSON-RPC method has been removed. This method
returned redeem scripts read from the now-removed transaction store
buckets. In the future, it is expected that the wallet may have
account kinds which generate P2SH addresses from derived BIP0044 keys,
complicating what should and should not be returned by a method such
as listscripts. As an alternative to this method, use validateaddress
on one of wallet's P2SH addresses to view the redeem scripts.

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating from the previous db version to this one on testnet vsp dcrstakedinner.com with 30+ imported scripts and no problems.

Pay-to-script-hash (P2SH) addresses managed by the wallet must record
the nested script as well.  These scripts are required to redeem a
P2SH output as it must appear in the signature script.

Since the redeem script itself might be the secret to redeem an output
(as in the case for some transaction script puzzles), rather than
needing a private key to produce a signature, btcwallet treated all
redeem scripts as secrets and required they be encrypted using the
private data symmetric encryption key.  However, since mainnet launch,
dcrwallet has also recorded redeem scripts unencrypted in the
transaction store buckets (this was added to support the hacked-on
multisignature support).  A database upgrade is performed to move
these unencrypted scripts into the address manager's data so that the
redeem script for a managed P2SH address is always known.  The
udb.ScriptAddress interface has been extended to provide this redeem
script and the script version it is to be interpreted as.

The listscripts JSON-RPC method has been removed.  This method
returned redeem scripts read from the now-removed transaction store
buckets.  In the future, it is expected that the wallet may have
account kinds which generate P2SH addresses from derived BIP0044 keys,
complicating what should and should not be returned by a method such
as listscripts.  As an alternative to this method, use validateaddress
on one of wallet's P2SH addresses to view the redeem scripts.
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

Successfully merging this pull request may close these issues.

None yet

3 participants