Skip to content

rpc: decode Miniscript descriptor when possible in decodescript - #27037

Merged
achow101 merged 2 commits into
bitcoin:masterfrom
darosior:decodescript_miniscript
Feb 3, 2023
Merged

achow101 merged 2 commits into
bitcoin:masterfrom
darosior:decodescript_miniscript

Conversation

@darosior

@darosior darosior commented Feb 3, 2023

Copy link
Copy Markdown
Member

The descriptor inference logic would previously always use a dummy signing provider and would never analyze the witness script of a P2WSH scriptPubKey.

It's often not possible to infer a Miniscript only from the onchain Script, but it was such a low hanging fruit that it's probably worth having it?

Fixes #27007. I think it also closes #25606.

@DrahtBot

DrahtBot commented Feb 3, 2023 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK instagibbs, achow101, sipa

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@instagibbs

Copy link
Copy Markdown
Member

Probably slightly better than my version; will test

@instagibbs

Copy link
Copy Markdown
Member

ACK 03ccc34

might need release note?

here's a couple more examples from taproot LN channels discussions that would be nice to include in test to check how it falls back to raw behavior:

Offered HTLC: 82012088a914ffffffffffffffffffffffffffffffffffffffff882102ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffad51b2
"desc": "wsh(and_v(and_v(v:hash160(ffffffffffffffffffffffffffffffffffffffff),v:pk(02ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)),older(1)))#twc36s59"

miniscript incompatible Offered HTLC: 82012088a914ffffffffffffffffffffffffffffffffffffffff882102ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffacb2
"desc": "wsh(raw(82012088a914ffffffffffffffffffffffffffffffffffffffff882102ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffacb2))#ra6w2xa7"

@fanquake
fanquake requested a review from achow101 February 3, 2023 17:06
@darosior

darosior commented Feb 3, 2023

Copy link
Copy Markdown
Member Author

Thanks. I'm adding the incompatible one. The first one is already present: that's the one from your issue but with BIP341's NUMS pubkey as pubkey instead of ffff..ff.

The descriptor inference logic would previously always use a dummy
signing provider and would never analyze the witness script of a P2WSH
scriptPubKey.

Note even a valid Miniscript might not always be decodable from Script
without more contextual information (for instance the key preimage for a
pk_h).
@darosior
darosior force-pushed the decodescript_miniscript branch from 03ccc34 to dfc9acb Compare February 3, 2023 17:16
@darosior

darosior commented Feb 3, 2023

Copy link
Copy Markdown
Member Author

Added a release note too.

@instagibbs

Copy link
Copy Markdown
Member

ACK 6699d85

@achow101

achow101 commented Feb 3, 2023

Copy link
Copy Markdown
Member

ACK 6699d85

@sipa

sipa commented Feb 3, 2023

Copy link
Copy Markdown
Member

utACK 6699d85

@achow101
achow101 merged commit e2ae5c3 into bitcoin:master Feb 3, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decodescript could infer miniscript from given script in "segwit" context Miniscript support for decodescript

5 participants