From 30332dfe5270a03b0be1a598115e696de0edaa38 Mon Sep 17 00:00:00 2001 From: CalDescent <> Date: Fri, 20 May 2022 10:49:30 +0100 Subject: [PATCH] Full redeem script has to be passed to the input when redeeming P2SH --- lib/src/lightwallet.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index 8d0d6f3..75ede5d 100644 --- a/lib/src/lightwallet.rs +++ b/lib/src/lightwallet.rs @@ -77,7 +77,7 @@ pub fn double_sha256(payload: &[u8]) -> Vec { h2.to_vec() } -use base58::{FromBase58, ToBase58}; +use base58::ToBase58; /// A trait for converting a [u8] to base58 encoded string. pub trait ToBase58Check { @@ -2888,10 +2888,6 @@ impl LightWallet { // Add P2SH transaction as transparent input, including secret and redeem script - let p2sh_addr_vec = from.from_base58().unwrap(); - let p2sh_addr_arr = <[u8; 20]>::try_from(&p2sh_addr_vec[2..22]).unwrap(); - let p2sh_script_pubkey = TransparentAddress::Script(p2sh_addr_arr).script(); - let outpoint: OutPoint = OutPoint { hash: <[u8; 32]>::try_from(outpoint_txid).unwrap(), n: 0 @@ -2899,7 +2895,7 @@ impl LightWallet { let coin = TxOut { value: target_value, - script_pubkey: p2sh_script_pubkey, + script_pubkey: Script { 0: redeem_script_pubkey.to_vec() }, }; let sk = SecretKey::from_slice(privkey).unwrap();