Skip to content

Commit

Permalink
Merge #95: Remove inner checksum in pegin descriptor
Browse files Browse the repository at this point in the history
fe43086 remove inner checksum in pegin desc and fix test (Riccardo Casatta)
1a0fa05 expand pegin test to show inner checksum (Riccardo Casatta)

Pull request description:

  I noticed in the pegin descriptor inner checksum are printed, for example:

  `pegin(feddesc#cheksum, elem_desc#cheksum)#checksum`

  and this changes it to

  `pegin(feddesc, elem_desc)#checksum`

ACKs for top commit:
  apoelstra:
    ACK fe43086; successfully ran local tests

Tree-SHA512: 59c411c4ec17b71a244a92e73fd9f1938bda68df5e7fff5211055065c66b336b65ea2aea35ae1437a41ab90678f9ed6d8646ca01e229f2f10d39771ce01877e8
  • Loading branch information
apoelstra committed Nov 27, 2024
2 parents 6cdb0d2 + fe43086 commit d3037cc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/descriptor/pegin/dynafed_pegin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Pegin<Pk> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use fmt::Write;
let mut wrapped_f = checksum::Formatter::new(f);
write!(wrapped_f, "pegin({},{})", self.fed_desc, self.elem_desc)?;
write!(wrapped_f, "pegin({:#},{:#})", self.fed_desc, self.elem_desc)?;
wrapped_f.write_checksum_if_not_alt()
}
}
Expand Down Expand Up @@ -311,7 +311,8 @@ where
mod tests {
use elements::hex::FromHex;

use crate::BtcDescriptor;
use crate::descriptor::pegin::Pegin;
use crate::{BtcDescriptor, ConfidentialDescriptor, DescriptorPublicKey};

// test vector created with:
// ```
Expand Down Expand Up @@ -352,5 +353,13 @@ mod tests {
let s = super::bitcoin_witness_script(&d, &claimscript, &secp).unwrap();
let b = bitcoin::Address::p2wsh(&s, bitcoin::Network::Bitcoin);
assert_eq!(mainchain_address, b.to_string());

let elem_desc = "ct(slip77(ab5824f4477b4ebb00a132adfd8eb0b7935cf24f6ac151add5d1913db374ce92),elwpkh([759db348/84'/1'/0']tpubDCRMaF33e44pcJj534LXVhFbHibPbJ5vuLhSSPFAw57kYURv4tzXFL6LSnd78bkjqdmE3USedkbpXJUPA1tdzKfuYSL7PianceqAhwL2UkA/0/*))";
let elem_desc: ConfidentialDescriptor<DescriptorPublicKey> = elem_desc.parse().unwrap();
let elem_desc = elem_desc.descriptor.at_derivation_index(0).unwrap();
let elem_desc = elem_desc.derived_descriptor(&secp).unwrap();
let pegin = Pegin::new(d.clone(), elem_desc);

assert_eq!(pegin.to_string(), "pegin(wsh(or_d(multi(11,020e0338c96a8870479f2396c373cc7696ba124e8635d41b0ea581112b67817261,02675333a4e4b8fb51d9d4e22fa5a8eaced3fdac8a8cbf9be8c030f75712e6af99,02896807d54bc55c24981f24a453c60ad3e8993d693732288068a23df3d9f50d48,029e51a5ef5db3137051de8323b001749932f2ff0d34c82e96a2c2461de96ae56c,02a4e1a9638d46923272c266631d94d36bdb03a64ee0e14c7518e49d2f29bc4010,031c41fdbcebe17bec8d49816e00ca1b5ac34766b91c9f2ac37d39c63e5e008afb,03079e252e85abffd3c401a69b087e590a9b86f33f574f08129ccbd3521ecf516b,03111cf405b627e22135b3b3733a4a34aa5723fb0f58379a16d32861bf576b0ec2,0318f331b3e5d38156da6633b31929c5b220349859cc9ca3d33fb4e68aa0840174,03230dae6b4ac93480aeab26d000841298e3b8f6157028e47b0897c1e025165de1,035abff4281ff00660f99ab27bb53e6b33689c2cd8dcd364bc3c90ca5aea0d71a6,03bd45cddfacf2083b14310ae4a84e25de61e451637346325222747b157446614c,03cc297026b06c71cbfa52089149157b5ff23de027ac5ab781800a578192d17546,03d3bde5d63bdb3a6379b461be64dad45eabff42f758543a9645afd42f6d424828,03ed1e8d5109c9ed66f7941bc53cc71137baa76d50d274bda8d5e8ffbd6e61fe9a),and_v(v:older(4032),multi(2,03aab896d53a8e7d6433137bbba940f9c521e085dd07e60994579b64a6d992cf79,0291b7d0b1b692f8f524516ed950872e5da10fb1b808b5a526dedc6fed1cf29807,0386aa9372fbab374593466bc5451dc59954e90787f08060964d95c87ef34ca5bb)))),elwpkh(0321da398ca2ddc09be89caa26e6730ae84751b6ea3a1ca46aa365bb5e1c3d9620))#qp4fan9q");
}
}

0 comments on commit d3037cc

Please sign in to comment.