Skip to content

Commit

Permalink
Merge rust-bitcoin#2850: Implement GetKey for Vec<Xpriv>
Browse files Browse the repository at this point in the history
8ec3571 Implement GetKey for Vec<Xpriv> (Nadav Ivgi)

Pull request description:

  It appears that the `BTreeSet<Xpriv>`/`HashSet<Xpriv>` sets currently implementing `GetKey` cannot actually be constructed, because `Xpriv` does not implement `Ord` nor `Hash`. (And that the rust-bitcoin code referencing these sets should not even compile? yet evidently it does 👀 )

  This PR adds support for `Vec<Xpriv>` to enable signing with multiple `Xpriv`s, but does not address the issue with the existing sets.

  The added test case demonstrates the issue:

  ```rust
  error[E0277]: the trait bound `bip32::Xpriv: std:#️⃣:Hash` is not satisfied
      --> bitcoin/src/psbt/mod.rs:2301:24
       |
  2301 |         HashSet::new().insert(xpriv.clone());
       |                        ^^^^^^ the trait `std:#️⃣:Hash` is not implemented for `bip32::Xpriv`
       |
  note: required by a bound in `std::collections::HashSet::<T, S>::insert`
      --> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/collections/hash/set.rs:888:5

  error[E0277]: the trait bound `bip32::Xpriv: Ord` is not satisfied
      --> bitcoin/src/psbt/mod.rs:2302:25
       |
  2302 |         BTreeSet::new().insert(xpriv.clone());
       |                         ^^^^^^ the trait `Ord` is not implemented for `bip32::Xpriv`
       |
  note: required by a bound in `std::collections::BTreeSet::<T, A>::insert`
      --> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/collections/btree/set.rs:899:5

  ```

ACKs for top commit:
  apoelstra:
    ACK 8ec3571 successfully ran local tests
  tcharding:
    ACK 8ec3571

Tree-SHA512: aceb95f8eaf11f91c6829e0b5e1c0264ebffbf587fd420145a22e924cb45678b2f4334f0b7de6ed99b57f0ce24c3d61f9e5c1e348e1b40975bc515e8fd16b75d
  • Loading branch information
apoelstra committed Sep 18, 2024
2 parents 10d604a + 8ec3571 commit d9d12da
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions bitcoin/src/psbt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ impl GetKey for $set<Xpriv> {
.transpose()
}
}}}
impl_get_key_for_set!(Vec);
impl_get_key_for_set!(BTreeSet);
#[cfg(feature = "std")]
impl_get_key_for_set!(HashSet);
Expand Down

0 comments on commit d9d12da

Please sign in to comment.