Skip to content

Commit 45a6938

Browse files
committed
export pset::error::PsetHash
This type appears in the public API as part of the pset::Error type. However, the type itself is not exported, preventing users from naming or directly constructing it. This prevents construction of a single variant of pset::Error, and in particular prevents us from semver-tricking the Error type. It is bad practice to export the pset::Error type without also exporting its constituent types (except as an intentional form of sealing, which this is not). That is enough reason to accept this PR. But to give a more elaborate reason: 1. I would like to semver-trick 0.25.3 by re-exporting all the types from 0.26.0 except the ones that changed (`PartiallySignedTransaction`, `TxOut`, `pset::raw::ProprietaryKey`, and types that expose these in their public APIs: `Transaction`, `Block` and the sighash cache). 2. I need to re-export the `encode::Error` type, which fortunately did not change since 0.25.x, so that I can re-use the Encodable/Decodable logic for all the types that I'm re-exporting. (I can either re-export those traits directly, along with the error type, or implement a new one with impls that pass through to the 0.26.x one ... or retain a *ton* of explicit unreviewable code which probably won't even compile without changes to handle some types becoming foreign). 3. However, `encode::Error` has conversions to and from `pset::Error`. So if I re-export `encode::Error` I need to re-export `pset::Error`. (Also, I just really want to; everything I *don't* re-export is a bunch of extra explicit code that needs to stick around in this version of the library. See above.) 4. But I need to explicitly construct `pset::Error` in the `Map::insert_pair` impl for `pset::Output`. (This *can't* be re-exported because it's private, and I can't re-export the whole `pset::Output` type because it has a method which returns `TxOut`, whose API changed in 0.26.0.) 5. ...so I need a re-export of `PsetHash` to do the construction.
1 parent 6da502c commit 45a6938

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/pset/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ use secp256k1_zkp;
2626
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
2727
/// Enum for marking pset hash error
2828
pub enum PsetHash {
29+
/// Bad preimage for `RIPEMD160` hash.
2930
Ripemd,
31+
/// Bad preimage for `SHA256` hash.
3032
Sha256,
33+
/// Bad preimage for `RIPEMD160-SHA256` hash.
3134
Hash160,
35+
/// Bad preimage for double-`SHA256` hash.
3236
Hash256,
3337
}
3438
/// Ways that a Partially Signed Transaction might fail.

src/pset/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use crate::{
5353
use secp256k1_zkp::rand::{CryptoRng, RngCore};
5454
use secp256k1_zkp::{self, RangeProof, SecretKey, SurjectionProof};
5555

56-
pub use self::error::{Error, PsetBlindError};
56+
pub use self::error::{Error, PsetBlindError, PsetHash};
5757
use self::map::Map;
5858
pub use self::map::{Global, GlobalTxData, Input, Output, PsbtSighashType, TapTree};
5959

0 commit comments

Comments
 (0)