Skip to content

Commit

Permalink
fixup! SFT-UNKN: Add foundation-bip32 crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandudey committed Nov 13, 2023
1 parent 70099e3 commit ffd0ae6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bip32/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ where
Error: ParseError<Input>,
Error: FromExternalError<Input, secp256k1::Error>,
{
let depth = u8::<Input, Error>;
let parent_fingerprint = fingerprint::<Input, Error>;
let child_number = be_u32::<Input, Error>;
let chain_code = map(take::<_, Input, Error>(32usize), to_fixed_bytes::<_, 32>);
let depth = u8;
let parent_fingerprint = fingerprint;
let child_number = be_u32;
let public_key = map_res(
map(take::<_, Input, Error>(33usize), to_fixed_bytes::<_, 33>),
|pk| PublicKey::from_slice(&pk),
Expand Down Expand Up @@ -162,6 +161,17 @@ where
Ok((i, Fingerprint(buf)))
}

/// Parses a BIP-32 chain code.
pub fn chain_code<Input, Error>(i: Input) -> IResult<Input, [u8; 32], Error>
where
Input: PartialEq + Clone + Slice<RangeFrom<usize>> + InputIter<Item = u8> + InputLength,
Error: ParseError<Input>,
{
let mut buf = [0; 32];
let (i, ()) = fill(u8, &mut buf)(i)?;
Ok((i, buf))
}

/// Parses a [`KeySource`].
pub fn key_source<Input, Error>(i: Input) -> IResult<Input, KeySource<Input>, Error>
where
Expand Down

0 comments on commit ffd0ae6

Please sign in to comment.