-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
btc: convert pkscript_from_multisig() to Rust
Alternative implementation of this function based on rust-miniscript: ``` pub fn pkscript( multisig: &Multisig, keypath_change: u32, keypath_address: u32, ) -> Result<Vec<u8>, Error> { let pubkeys: Vec<bitcoin::PublicKey> = multisig .xpubs .iter() .map(|xpub| -> Result<bitcoin::PublicKey, ()> { bitcoin::PublicKey::from_slice( bip32::Xpub::from(xpub) .derive(&[keypath_change, keypath_address])? .public_key(), ) .map_err(|_| ()) }) .collect::<Result<_, _>>()?; let sorted_multi = miniscript::descriptor::SortedMultiVec::< bitcoin::PublicKey, miniscript::Legacy, >::new(multisig.threshold as _, pubkeys) .map_err(|_| Error::InvalidInput)?; Ok(sorted_multi.encode().into_bytes()) } ``` This cost about 10kB of binary space. The manual implementation of this commit costs nearly nothing.
- Loading branch information
Showing
8 changed files
with
29 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters