Skip to content

Commit eb2c282

Browse files
committed
Fix inconsistent naming in the dummy key hash structs
Also implement `Default` for `DummyHash` and all of its hash types since they are all empty structs.
1 parent cddc22d commit eb2c282

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl ToPublicKey for bitcoin::secp256k1::XOnlyPublicKey {
358358
}
359359

360360
/// Dummy key which de/serializes to the empty string; useful sometimes for testing
361-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
361+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
362362
pub struct DummyKey;
363363

364364
impl str::FromStr for DummyKey {
@@ -375,7 +375,7 @@ impl str::FromStr for DummyKey {
375375
impl MiniscriptKey for DummyKey {
376376
type RawPkHash = DummyKeyHash;
377377
type Sha256 = DummySha256Hash;
378-
type Hash256 = DummyHash256;
378+
type Hash256 = DummyHash256Hash;
379379
type Ripemd160 = DummyRipemd160Hash;
380380
type Hash160 = DummyHash160Hash;
381381

@@ -413,7 +413,7 @@ impl ToPublicKey for DummyKey {
413413
.unwrap()
414414
}
415415

416-
fn to_hash256(_hash: &DummyHash256) -> hash256::Hash {
416+
fn to_hash256(_hash: &DummyHash256Hash) -> hash256::Hash {
417417
hash256::Hash::from_str("50863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352")
418418
.unwrap()
419419
}
@@ -428,7 +428,7 @@ impl ToPublicKey for DummyKey {
428428
}
429429

430430
/// Dummy keyhash which de/serializes to the empty string; useful sometimes for testing
431-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
431+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
432432
pub struct DummyKeyHash;
433433

434434
impl str::FromStr for DummyKeyHash {
@@ -455,7 +455,7 @@ impl hash::Hash for DummyKeyHash {
455455
}
456456

457457
/// Dummy keyhash which de/serializes to the empty string; useful for testing
458-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
458+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
459459
pub struct DummySha256Hash;
460460

461461
impl str::FromStr for DummySha256Hash {
@@ -482,22 +482,22 @@ impl hash::Hash for DummySha256Hash {
482482
}
483483

484484
/// Dummy keyhash which de/serializes to the empty string; useful for testing
485-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
486-
pub struct DummyHash256;
485+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
486+
pub struct DummyHash256Hash;
487487

488-
impl str::FromStr for DummyHash256 {
488+
impl str::FromStr for DummyHash256Hash {
489489
type Err = &'static str;
490-
fn from_str(x: &str) -> Result<DummyHash256, &'static str> {
490+
fn from_str(x: &str) -> Result<DummyHash256Hash, &'static str> {
491491
if x.is_empty() {
492-
Ok(DummyHash256)
492+
Ok(DummyHash256Hash)
493493
} else {
494494
Err("non empty dummy hash")
495495
}
496496
}
497497
}
498498

499499
/// Dummy keyhash which de/serializes to the empty string; useful for testing
500-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
500+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
501501
pub struct DummyRipemd160Hash;
502502

503503
impl str::FromStr for DummyRipemd160Hash {
@@ -511,7 +511,7 @@ impl str::FromStr for DummyRipemd160Hash {
511511
}
512512
}
513513

514-
impl fmt::Display for DummyHash256 {
514+
impl fmt::Display for DummyHash256Hash {
515515
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
516516
f.write_str("")
517517
}
@@ -522,7 +522,7 @@ impl fmt::Display for DummyRipemd160Hash {
522522
}
523523
}
524524

525-
impl hash::Hash for DummyHash256 {
525+
impl hash::Hash for DummyHash256Hash {
526526
fn hash<H: hash::Hasher>(&self, state: &mut H) {
527527
"DummySha256Hash".hash(state);
528528
}
@@ -535,7 +535,7 @@ impl hash::Hash for DummyRipemd160Hash {
535535
}
536536

537537
/// Dummy keyhash which de/serializes to the empty string; useful for testing
538-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
538+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
539539
pub struct DummyHash160Hash;
540540

541541
impl str::FromStr for DummyHash160Hash {

0 commit comments

Comments
 (0)