Skip to content

Conversation

@miketwenty1
Copy link
Contributor

@miketwenty1 miketwenty1 commented Nov 2, 2024

Adding taptree_of_horror example.
Adding bitcoin_hashes as dev dependency.
Made some formatting consistency corrections in Cargo.toml.

@miketwenty1
Copy link
Contributor Author

@apoelstra @sanket1729

Rebased the last commit into my PR. Looking for review/feedback. I laid out a few talking points for discussion so I can get an idea of how to get this merged in:

  1. Does the setup of the example work for you?
  2. Are you okay with my linter’s consistency edits to Cargo.toml?
  3. Ok that I'm bringing in bitcoin_hashes as a dev-dep?
  4. Would you prefer a themed example referencing TABConf 6's "Taptree of Horror," or a non-themed one? I was thinking themed, and eventually adding the review Youtube video and the Sats Conf video when they are ready https://agenda.satsconf.com.br/satsconf2024/talk/GQC8YK/ , if you would prefer non-themed, let me know what you're thinking for a example and folder name.
  5. I included the .excalidraw file in case the tree graphic needed to be edited, but I can remove it if not needed.

@apoelstra
Copy link
Member

  • Are you okay with my linter’s consistency edits to Cargo.toml?

I'd rather not. It seems like you just need to add some lines to the bottom for the new example and that's it. (Also ironically, your new source files have some trailing spaces in them, so maybe these need to have a linter/formatter run on them.)

  • Ok that I'm bringing in bitcoin_hashes as a dev-dep?

No, this doesn't seem necessary to me. I tried removing this and replacing bitcoin_hashes::Hash with bitcoin::hashes::Hash in your code and everything seemed to compile fine.

  • Would you prefer a themed example referencing TABConf 6's "Taptree of Horror," or a non-themed one? I was thinking themed

Yeah, I like the theme.

@miketwenty1 miketwenty1 force-pushed the master branch 2 times, most recently from 382f633 to 0e30756 Compare November 4, 2024 18:50
@miketwenty1
Copy link
Contributor Author

I'd rather not.

Fixed

(Also ironically, your new source files have some trailing spaces in them, so maybe these need to have a linter/formatter run on them.)

I'm not sure what you mean. Can you give me a specific example.

No, this doesn't seem necessary to me. I tried removing this and replacing bitcoin_hashes::Hash with bitcoin::hashes::Hash in your code and everything seemed to compile fine.

Fixed

Thanks for the feedback, fixed the issues you pointed. Let me know what else you'd like to see in this PR.

@miketwenty1 miketwenty1 force-pushed the master branch 2 times, most recently from 079a1d3 to 1282d30 Compare November 7, 2024 19:59

// define individual variables to make it easy to insert into the policy string.
// Define individual variables with pattern matching in a compact format
let (a0, a1, a2, a3, a4, a5, a6, a7, a8) = match &a_pks[..] {
Copy link
Member

Choose a reason for hiding this comment

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

In 1282d30

Can replace all these with one-liners, e.g.

let [a0, a1, a2, a3, a4, a5, a6, a7, a8] = a_pks[..].try_into().unwrap();

I would also drop the Define individual variables with pattern matching comment since it's just a repetition of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fyi, I'm also be including the explicit type to make the compiler/linter happy
[PublicKey; KEYS_PER_PERSONA]

Copy link
Member

Choose a reason for hiding this comment

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

If you think that's necessary -- though I tried it without type annotations and it seemed to work. (Maybe you need the annotations once you convert all of them; I only did one.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried it again and removed the type for the "alice"/"a" keys and got this:

cargo +1.63.0 run --example taptree_of_horror --features compiler
   Compiling miniscript v12.2.0 (/Users/tzez/git/github/rust-bitcoin/rust-miniscript)
error[E0282]: type annotations needed
  --> examples/taptree_of_horror/taptree_of_horror.rs:88:9
   |
88 |     let [a0, a1, a2, a3, a4, a5, a6, a7, a8] = a_pks[..].try_into().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: type must be known at this point
help: consider giving this pattern a type
   |
88 |     let [a0, a1, a2, a3, a4, a5, a6, a7, a8]: _ = a_pks[..].try_into().unwrap();
   |                                             +++

For more information about this error, try `rustc --explain E0282`.
error: could not compile `miniscript` due to previous error

having the specific type solves this error, if you want to address it in a different way let me know.

@apoelstra
Copy link
Member

apoelstra commented Nov 9, 2024

Super cool! Done reviewing c1282d30653a3cb4e188e59d5a3dd8de909aa9477. Lots of comments but they are all super minor things.

@miketwenty1 miketwenty1 force-pushed the master branch 2 times, most recently from a1f5467 to 85963fc Compare November 9, 2024 16:12
@miketwenty1
Copy link
Contributor Author

miketwenty1 commented Nov 9, 2024

@apoelstra
I made the corrections you suggested, some notes:

  • The new const KEYS_PER_PERSONA still has some try_into() ideas because some places it needs to be a usize and some places it needs to be a u32.
  • There were a few places where the compiler/linter wanted me to define a specific type for some things. (just fyi if you were wondering why I defined some types).
  • Decided to give the commented out code for internal keys full type paths incase someone is confused where it's coming from.
  • I decided to also add in some header comments for the various section of the example.
// ====== 1. Setup Hardcoded Values for all of the Personas ======
// ====== 2. Derive Keys, Preimages, Hashes, and Timelocks for Policy and Signing ======
// ====== 3. Create Taptree Policy and Descriptor ======
// ====== 4. Construct an Unsigned Transaction from the Tapscript ======
// ====== 5. Sign and Create a Spending Transaction ======

Thanks for the first review, I'm ready for anything else you want to change.

@apoelstra
Copy link
Member

89cdeca looks great to me! CI is showing a clippy lint you can address.

@apoelstra
Copy link
Member

utack 08cea1c

@miketwenty1 miketwenty1 force-pushed the master branch 2 times, most recently from f7d3681 to 7574b82 Compare November 9, 2024 18:30
@miketwenty1 miketwenty1 force-pushed the master branch 3 times, most recently from bc9e7e3 to 61a2265 Compare November 9, 2024 19:26
@apoelstra
Copy link
Member

utack 6910eb4

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 6910eb4; successfully ran local tests

@apoelstra
Copy link
Member

cc @sanket1729 do you want to review this? I'll hold off on merging til tomorrow afternoon but I think this is good to go in.

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK 6910eb4

Cargo.toml Outdated
bitcoin = { version = "0.32.0", features = ["base64"] }
secp256k1 = {version = "0.29.0", features = ["rand-std"]}
secp256k1 = { version = "0.29.0", features = ["rand-std"] }
bitcoin_hashes = "0.14.0"
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, do we need explicit dependency for this? Do we not have a feature for this @apoelstra . Been some times since I looked at this.

Copy link
Member

Choose a reason for hiding this comment

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

Oops. I had a partial review from last week. Looks like this was resolved.

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

Did not a careful code review. The psbt APIs are used correctly and will serve as a good reference point for future users.

Maybe, we have a good first issue to simplify this example and create a simple psbt sign/update/finalize flow for a simpler policy :) .

@apoelstra apoelstra merged commit 39c2fa5 into rust-bitcoin:master Nov 11, 2024
30 checks passed
@apoelstra
Copy link
Member

We need to update contrib/test_vars.sh to include this example. (But really, we need to update CI to just read this stuff out of the toml file.)

heap-coder added a commit to heap-coder/rust-miniscript that referenced this pull request Sep 27, 2025
…ple.

6910eb4b76bb84e53aea65a7bb707e27516a473f Adding taptree_of_horror example. (Michael Tidwell)
d28b7ea2cff8285a21fa4e850dcbb600b2dfd356 clippy: remove `.any(|x| x)` construction in the compiler (Andrew Poelstra)

Pull request description:

  Adding taptree_of_horror example.
  ~~Adding bitcoin_hashes as dev dependency.~~
  ~~Made some formatting consistency corrections in Cargo.toml.~~

ACKs for top commit:
  apoelstra:
    ACK 6910eb4b76bb84e53aea65a7bb707e27516a473f; successfully ran local tests
  sanket1729:
    ACK 6910eb4b76bb84e53aea65a7bb707e27516a473f

Tree-SHA512: 683cebd689bbf69ee9bfafeea56c1b76c89668461f9dc104c54875a6fdec601d378d81ff434ae51919f3476a87f288e4642ee2f48f44e5b201af4f9d130fd50b
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.

3 participants