Skip to content

Introducing bip32::KeySource: wrapper for (Fingerprint, DerivationPath)#480

Merged
apoelstra merged 2 commits intorust-bitcoin:masterfrom
BP-WG:feat/keysource
Oct 7, 2020
Merged

Introducing bip32::KeySource: wrapper for (Fingerprint, DerivationPath)#480
apoelstra merged 2 commits intorust-bitcoin:masterfrom
BP-WG:feat/keysource

Conversation

@dr-orlovsky
Copy link
Copy Markdown
Collaborator

Combinations of (Fingerprint, DerivationPath) are frequently used with PSBTs throughout this library and in many dependencies (like Lightning, Miniscript). It even had it's own serializer! So I think it is reasonable to introduce a type for representing this pair. After a brief discussion in rust-bitcoin/rust-miniscript#131 (comment) it was decided to name it KeySource, but we can change the name if needed.

sgeisler
sgeisler previously approved these changes Sep 13, 2020
Copy link
Copy Markdown
Contributor

@sgeisler sgeisler left a comment

Choose a reason for hiding this comment

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

ACK (I haven't checked if the introduction of the type is exhaustive).

@afilini
Copy link
Copy Markdown
Contributor

afilini commented Sep 13, 2020

I wouldn't say I'm against this, but this has the disadvantage that instances of KeySource would not be unpack-able as tuples anymore, i.e.:

let (fingerprint, derivation_path) = psbt.inputs[0].hd_keypaths.get(my_pk).unwrap();

wouldn't work anymore.

You could theoretically do:

let KeySource(fingerprint, derivation_path) = psbt.inputs[0].hd_keypaths.get(my_pk).unwrap();

but that means that you would have to import the type just to unpack it nicely.

I would rather define this as a type alias, it achieves the same goal of not having to type the full tuple every time, while keeping the nice unpacking properties of tuples, and not making a breaking change in the API.

@sgeisler
Copy link
Copy Markdown
Contributor

I'd be fine with that too.

@dr-orlovsky
Copy link
Copy Markdown
Collaborator Author

dr-orlovsky commented Sep 13, 2020

Yep, alias will work better in this place, see new commit

@dr-orlovsky
Copy link
Copy Markdown
Collaborator Author

@sgeisler

ACK (I haven't checked if the introduction of the type is exhaustive).

I did replacement with search over whole code for Fingerprint use

@apoelstra apoelstra merged commit 8c82129 into rust-bitcoin:master Oct 7, 2020
@apoelstra apoelstra mentioned this pull request Oct 7, 2020
yancyribbens pushed a commit to yancyribbens/rust-bitcoin that referenced this pull request Mar 23, 2024
Add a "base64" feature that enables the `base64` dependency in
`rust-bitcoin`. This enables `Psbt::from_str()`.

Fix: rust-bitcoin#480
yancyribbens pushed a commit to yancyribbens/rust-bitcoin that referenced this pull request Mar 23, 2024
2c67681 Add base64 feature (Tobin C. Harding)

Pull request description:

  Add a "base64" feature that enables the `base64` dependency in `rust-bitcoin`. This enables `Psbt::from_str()`.

  Fix: rust-bitcoin#480

ACKs for top commit:
  sanket1729:
    ACK 2c67681

Tree-SHA512: 24af82329cbbba0fff4bbb686f6108a879163dd44d7fa738677d94daf96a0a892f20f3780d4c2d6a17b183f0aa60423192340420f039d0b39bfde2422262151e
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