diff --git a/Cargo.lock b/Cargo.lock index 86224f89..e1782df3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,9 +128,12 @@ checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base85" -version = "1.1.1" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b68cde48c539cf9db81c5598e215dc32d0401a167f899cf26e35f61815eb9e" +checksum = "affba8f9496cbbacbefe5b9f3a0a9fac6cc48f6951e7331e293b241e67bdcf06" +dependencies = [ + "thiserror", +] [[package]] name = "bitflags" @@ -163,7 +166,7 @@ dependencies = [ [[package]] name = "bp-core" -version = "0.10.7" +version = "0.10.8" dependencies = [ "amplify", "bp-dbc", @@ -178,7 +181,7 @@ dependencies = [ [[package]] name = "bp-dbc" -version = "0.10.7" +version = "0.10.8" dependencies = [ "amplify", "base85", @@ -203,7 +206,7 @@ dependencies = [ [[package]] name = "bp-seals" -version = "0.10.7" +version = "0.10.8" dependencies = [ "amplify", "baid58", @@ -661,6 +664,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "thiserror" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.27", +] + [[package]] name = "toml" version = "0.5.11" diff --git a/Cargo.toml b/Cargo.toml index b15f09db..45709c85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ single_use_seals = "0.10.0" [package] name = "bp-core" -version = "0.10.7" +version = "0.10.8" description = "Bitcoin protocol core library (BP Core Lib)" keywords = ["lnp-bp", "smart-contracts", "bitcoin", "blockchain"] categories = ["cryptography"] @@ -56,8 +56,8 @@ strict_types = { version = "1.6.0", optional = true } commit_verify = { workspace = true } single_use_seals = { workspace = true } bp-primitives = { version = "0.10.6", path = "./primitives" } -bp-dbc = { version = "0.10.7", path = "./dbc" } -bp-seals = { version = "0.10.7", path = "./seals" } +bp-dbc = { version = "0.10.8", path = "./dbc" } +bp-seals = { version = "0.10.8", path = "./seals" } serde_crate = { package = "serde", version = "1", features = ["derive"], optional = true } [features] diff --git a/dbc/Cargo.toml b/dbc/Cargo.toml index d467f59b..fe45359c 100644 --- a/dbc/Cargo.toml +++ b/dbc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bp-dbc" -version = "0.10.7" +version = "0.10.8" description = "Deterministic bitcoin commitments library" keywords = ["lnp-bp", "bitcoin", "blockchain", "smart-contracts", "single-use-seals"] categories = ["cryptography", "encoding"] @@ -18,7 +18,7 @@ path = "src/lib.rs" [dependencies] amplify = { workspace = true } -base85 = "1.1.1" +base85 = "1.2.1" strict_encoding = { workspace = true } commit_verify = { workspace = true, features = ["rand"] } bp-primitives = { version = "0.10.6", path = "../primitives" } diff --git a/dbc/src/tapret/tapscript.rs b/dbc/src/tapret/tapscript.rs index 830e33a7..97fd526a 100644 --- a/dbc/src/tapret/tapscript.rs +++ b/dbc/src/tapret/tapscript.rs @@ -83,9 +83,10 @@ impl Display for TapretCommitment { impl FromStr for TapretCommitment { type Err = DeserializeError; fn from_str(s: &str) -> Result { - let data = base85::decode(s).ok_or_else(|| { + let data = base85::decode(s).map_err(|err| { DecodeError::DataIntegrityError(format!( - "invalid Base85 encoding of tapret data \"{s}\"" + "invalid Base85 encoding of tapret data \"{s}\": {}", + err.to_string().to_lowercase() )) })?; let data = Confined::try_from(data).map_err(DecodeError::from)?; diff --git a/seals/Cargo.toml b/seals/Cargo.toml index 3efa5a1c..a95712f5 100644 --- a/seals/Cargo.toml +++ b/seals/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bp-seals" -version = "0.10.7" +version = "0.10.8" description = "Bitcoin protocol single-use-seals library" keywords = ["lnp-bp", "bitcoin", "blockchain", "smart-contracts", "single-use-seals"] categories = ["cryptography", "encoding"] diff --git a/seals/src/txout/blind.rs b/seals/src/txout/blind.rs index 257437e9..c84951f8 100644 --- a/seals/src/txout/blind.rs +++ b/seals/src/txout/blind.rs @@ -170,15 +170,25 @@ impl BlindSeal { } /// Creates new seal using TapretFirst closing method for the provided - /// outpoint and seal closing method. Uses `thread_rng` to initialize - /// blinding factor. + /// outpoint. Uses `thread_rng` to initialize blinding factor. + pub fn tapret_first_from(outpoint: Outpoint) -> Self { + BlindSeal::tapret_first(outpoint.txid, outpoint.vout) + } + + /// Creates new seal using OpretFirst closing method for the provided + /// outpoint. Uses `thread_rng` to initialize blinding factor. + pub fn opret_first_from(outpoint: Outpoint) -> Self { + BlindSeal::opret_first(outpoint.txid, outpoint.vout) + } + + /// Creates new seal using TapretFirst closing method for the provided + /// outpoint. Uses `thread_rng` to initialize blinding factor. pub fn tapret_first(txid: impl Into, vout: impl Into) -> Self { BlindSeal::with_rng(CloseMethod::TapretFirst, txid, vout, &mut thread_rng()) } /// Creates new seal using OpretFirst closing method for the provided - /// outpoint and seal closing method. Uses `thread_rng` to initialize - /// blinding factor. + /// outpoint. Uses `thread_rng` to initialize blinding factor. pub fn opret_first(txid: impl Into, vout: impl Into) -> Self { BlindSeal::with_rng(CloseMethod::OpretFirst, txid, vout, &mut thread_rng()) } diff --git a/seals/src/txout/seal.rs b/seals/src/txout/seal.rs index 9760558b..02f6c8eb 100644 --- a/seals/src/txout/seal.rs +++ b/seals/src/txout/seal.rs @@ -146,6 +146,11 @@ impl From<&Txid> for TxPtr { fn from(txid: &Txid) -> Self { TxPtr::Txid(*txid) } } +impl From<[u8; 32]> for TxPtr { + #[inline] + fn from(txid: [u8; 32]) -> Self { TxPtr::Txid(txid.into()) } +} + impl SealTxid for TxPtr { fn txid(&self) -> Option { match self {