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

Add 'compile' sub-command, minor cleanup #21

Merged
merged 1 commit into from
Mar 5, 2021

Conversation

notmandatory
Copy link
Member

@notmandatory notmandatory commented Mar 3, 2021

Description

Closes issue #20

Add to library CliSubCommand::Compile enum variant and handle_compile_subcommand() function.

Add to bdk-cli tool a new top level command "Compile" to compile a miniscript policy to an output descriptor.

Help output:

$ cargo run --features=repl,electrum,compiler help compile
...
bdk-cli-compile 0.2.1-dev
Miniscript policy compiler

USAGE:
    bdk-cli compile [OPTIONS] <POLICY>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -t, --type <TYPE>    Sets the script type used to embed the compiled policy [default: wsh]  [possible values: sh,
                         wsh, sh-wsh]

ARGS:
    <POLICY>    Sets the spending policy to compile

Example usage:

$ cargo run --features=repl,electrum,compiler compile --type sh-wsh "thresh(3,pk($ALICE_XPUB),pk($BOB_XPUB),pk($CAROL_XPUB),older(2))"
...
{
  "descriptor": "sh(wsh(thresh(3,pk([0da98f81/84'/1'/0']tpubDD3Fqx9RKeKUqwGSJpdQTAD1kN1misu4CW4zDNFKPphGJJ5K841B58aGHDFxSo65zDttffmLTSTLgwPPyqRVkhqE6D8JWZzm85K1sZ4A85N/0/*),s:pk([65aac7d2/84'/1'/0']tpubDDmA13CwXYp2ocpSGiiF1YKZK9BVVe9go898of7mYuBfwhmXX3GeYoGMHewk9J1b1xurQFJEQTvc2nSsEmYHwL4wdnNdgXRqvs57DYXjHbp/0/*),s:pk([0b7402df/84'/1'/0']tpubDCJWHKMgzMaT8i8wHzRq73wTmRJMzAyEaRsRBRrQfBxQC949jgkiBw1GqtCFunWVVxkmxs8ZuWt6GrPYrcZyHEDRTnozaxKMGXaAkBtAzTo/0/*),sdv:older(2))))#xmglnxx7"

Notes to the reviewers

This command requires the compiler feature be enabled. I didn't add an option to parse the policy since this can already be done with the wallet policies sub-command.

I also renamed the cli arg parsing tests.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

@notmandatory notmandatory force-pushed the feat/compile branch 3 times, most recently from 3f552e9 to 04267f8 Compare March 3, 2021 05:42
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.

2 participants