Skip to content

Commit b3f4c18

Browse files
committed
Correct redeem script/script code caluclation
The APIs unsigned_script_sig give a single script element push <elem>. But what Psbt redeem script, we need the script without the prefixing the op pushbytes opcode
1 parent e9b53e9 commit b3f4c18

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/psbt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,9 @@ impl PsbtExt for Psbt {
728728
Descriptor::Sh(sh) => match sh.as_inner() {
729729
descriptor::ShInner::Wsh(wsh) => {
730730
inp.witness_script = Some(wsh.inner_script());
731-
inp.redeem_script = Some(sh.unsigned_script_sig());
731+
inp.redeem_script = Some(wsh.inner_script().to_v0_p2wsh());
732732
}
733-
descriptor::ShInner::Wpkh(..) => inp.redeem_script = Some(sh.unsigned_script_sig()),
733+
descriptor::ShInner::Wpkh(..) => inp.redeem_script = Some(sh.inner_script()),
734734
descriptor::ShInner::SortedMulti(_) | descriptor::ShInner::Ms(_) => {
735735
inp.redeem_script = Some(sh.inner_script())
736736
}
@@ -848,7 +848,7 @@ impl PsbtExt for Psbt {
848848
fn script_code_wpkh(script: &Script) -> Script {
849849
assert!(script.is_v0_p2wpkh());
850850
// ugly segwit stuff
851-
let mut script_code = vec![0x19u8, 0x76, 0xa9, 0x14];
851+
let mut script_code = vec![0x76u8, 0xa9, 0x14];
852852
script_code.extend(&script.as_bytes()[2..]);
853853
script_code.push(0x88);
854854
script_code.push(0xac);

0 commit comments

Comments
 (0)