Skip to content

Bip392 - #192

Open
Sosthene00 wants to merge 6 commits into
masterfrom
bip392
Open

Bip392#192
Sosthene00 wants to merge 6 commits into
masterfrom
bip392

Conversation

@Sosthene00

Copy link
Copy Markdown
Collaborator

Add a new sp-descriptor crate with what's needed to parse and produce drescriptors according to BIP392

Comment thread sp-descriptor/Cargo.toml Outdated
@@ -0,0 +1,16 @@
[package]
name = "sp-descriptor"

@cygnet3 cygnet3 Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe rename the crate to bip392?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

or drop the "sp-", so that the name becomes spdk::descriptor, like miniscript::descriptor

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It depends if we want to release this as a separate crate, much like with silentpayments. I think the scope is pretty well contained so it's not a bad idea I think, though we may want to drop the spdk-core dependency to make it independent of spdk.

Another idea would be to make a PR to add bip392 to the miniscript crate, though maybe since the BIP is still in draft it's too early for that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adding bip392 to miniscript will probably be a bit complicated, bip392 descriptors can't be 100% compliant with "normal" descriptors because they are not enough by themselved to derive a full scriptpubkey. I've changed a lot that branch yesterday I'll see if I can also get rid of the spdk-core dependency and I think what makes more sense is to release it as a standalone for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding bip392 to miniscript will probably be a bit complicated

I agree a standalone crate for bip392 should be better, I've thought about it recently, and I think one option could be to make the crate not depending directly on miniscript/bitcoin crates but rather the crate being generic over a Bitcoin trait

this make it easy to deal w/ different versions, you can supply default implem behing feature flags and the consumer is free to use different bitcoin primitives

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I already got rid of the bitcoin dependency, now it only depends on miniscript, silentpayments and libsecp.

I see what you propose here but just not sure how to actually implement it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

here a clauded draft for the idea: https://github.com/pythcoiner/spdk/tree/bip392-backend

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've looked into it, I'm discussing with my own clanker how to implement that in a way that is clean enough.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I tried different approaches but couldn't find one compelling enough, especially considering I'm not sure about a lot of things in spdk nor your actual needs. I'd rather merge it as it is now, you try to adapt it for what you're doing and then we see if we need a follow up here.

Comment thread bip392/src/keys.rs
match self {
SpKeyError::Bech32(e) => write!(f, "bech32 error: {}", e),
SpKeyError::InvalidHrp(hrp) => write!(f, "invalid HRP: {}", hrp),
SpKeyError::InvalidVersion(v) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess you haven't run the lints yet, but should be Self here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes I rewrote extensively this PR, will push later today

Key-material failures are distinct KeyError variants, wrapped as scan or spend, instead of miniscript Unexpected strings.
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.

4 participants