-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from tcharding/02-08-re-import
Re-import PSBTv0 code from `rust-bitcoin` and `rust-miniscript`
- Loading branch information
Showing
39 changed files
with
7,366 additions
and
4,350 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
//! Private scoped stuff copied from `rust-miniscript`. | ||
|
||
pub(crate) trait ItemSize { | ||
fn size(&self) -> usize; | ||
} | ||
|
||
impl<Pk: MiniscriptKey> ItemSize for Placeholder<Pk> { | ||
fn size(&self) -> usize { | ||
match self { | ||
Placeholder::Pubkey(_, size) => *size, | ||
Placeholder::PubkeyHash(_, size) => *size, | ||
Placeholder::EcdsaSigPk(_) | Placeholder::EcdsaSigPkHash(_) => 73, | ||
Placeholder::SchnorrSigPk(_, _, size) | Placeholder::SchnorrSigPkHash(_, _, size) => | ||
size + 1, // +1 for the OP_PUSH | ||
Placeholder::HashDissatisfaction | ||
| Placeholder::Sha256Preimage(_) | ||
| Placeholder::Hash256Preimage(_) | ||
| Placeholder::Ripemd160Preimage(_) | ||
| Placeholder::Hash160Preimage(_) => 33, | ||
Placeholder::PushOne => 2, // On legacy this should be 1 ? | ||
Placeholder::PushZero => 1, | ||
Placeholder::TapScript(s) => s.len(), | ||
Placeholder::TapControlBlock(cb) => cb.serialize().len(), | ||
} | ||
} | ||
} | ||
|
||
impl ItemSize for Vec<u8> { | ||
fn size(&self) -> usize { self.len() } | ||
} | ||
|
||
// Helper function to calculate witness size | ||
pub(crate) fn witness_size<T: ItemSize>(wit: &[T]) -> usize { | ||
wit.iter().map(T::size).sum::<usize>() + varint_len(wit.len()) | ||
} |
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
Oops, something went wrong.