Strict encoding for script wrapper types
@@ -150,6 +150,10 @@ impl strict_encoding::Strategy for LockScript {
#[wrapper(LowerHex, UpperHex)]
pub struct PubkeyScript(Script);
+impl strict_encoding::Strategy for PubkeyScript {
+ type Strategy = strict_encoding::strategies::Wrapped;
+}
+
/// A content of `sigScript` from a transaction input
#[derive(
Wrapper,
@@ -168,6 +172,10 @@ pub struct PubkeyScript(Script);
#[wrapper(LowerHex, UpperHex)]
pub struct SigScript(Script);
+impl strict_encoding::Strategy for SigScript {
+ type Strategy = strict_encoding::strategies::Wrapped;
+}
+
/// A content of the `witness` field from a transaction input according to
/// BIP-141
#[derive(
@@ -175,6 +183,10 @@ pub struct SigScript(Script);
)]
pub struct Witness(Vec<Vec<u8>>);
+impl strict_encoding::Strategy for Witness {
+ type Strategy = strict_encoding::strategies::Wrapped;
+}
+
impl Display for Witness {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("[\n")?;
@@ -204,6 +216,10 @@ impl Display for Witness {
#[wrapper(LowerHex, UpperHex)]
pub struct RedeemScript(Script);
+impl strict_encoding::Strategy for RedeemScript {
+ type Strategy = strict_encoding::strategies::Wrapped;
+}
+
impl RedeemScript {
pub fn script_hash(&self) -> ScriptHash {
self.as_inner().script_hash()
@@ -237,6 +253,10 @@ impl From<LockScript> for RedeemScript {
#[wrapper(LowerHex, UpperHex)]
pub struct WitnessScript(Script);
+impl strict_encoding::Strategy for WitnessScript {
+ type Strategy = strict_encoding::strategies::Wrapped;
+}
+
impl WitnessScript {
pub fn script_hash(&self) -> WScriptHash {
self.as_inner().wscript_hash()
@@ -267,6 +287,10 @@ impl From<LockScript> for WitnessScript {
#[wrapper(LowerHex, UpperHex)]
pub struct TapScript(Script);
+impl strict_encoding::Strategy for TapScript {
+ type Strategy = strict_encoding::strategies::Wrapped;
+}
+
/// Version of the WitnessProgram: first byte of `scriptPubkey` in
/// transaction output for transactions starting with opcodes ranging from 0
/// to 16 (inclusive).
@@ -398,6 +422,10 @@ impl From<WitnessVersion> for opcodes::All {
)]
pub struct WitnessProgram(Vec<u8>);
+impl strict_encoding::Strategy for WitnessProgram {
+ type Strategy = strict_encoding::strategies::Wrapped;
+}
+
impl Display for WitnessProgram {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
writeln!(f, "{}", self.as_inner().to_hex())
