From 34596b30843606dc91628795815f9390febe45d6 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Feb 2023 15:58:34 +0100 Subject: [PATCH] Fix collecting withdrawal scripts in eval_phase_one The current implementation assumed that ALL withdrawals present in a transaction had to be locked by a script and failed otherwise. But a transaction can actually be composed of both. So instead of failing, we should rather just ignore withdrawals that can't be referenced by redeemers. --- crates/uplc/src/tx/phase_one.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/uplc/src/tx/phase_one.rs b/crates/uplc/src/tx/phase_one.rs index 127188f6..3fc3dc02 100644 --- a/crates/uplc/src/tx/phase_one.rs +++ b/crates/uplc/src/tx/phase_one.rs @@ -283,15 +283,13 @@ fn build_redeemer_ptr( for (idx, x) in reward_accounts.iter().enumerate() { let cred = match Address::from_bytes(x).unwrap() { Address::Stake(a) => match a.payload() { - StakePayload::Script(sh) => StakeCredential::Scripthash(*sh), - StakePayload::Stake(_) => { - return Err(Error::ScriptKeyHash); - } + StakePayload::Script(sh) => Some(StakeCredential::Scripthash(*sh)), + StakePayload::Stake(_) => None, }, _ => return Err(Error::BadWithdrawalAddress), }; - if cred == *racnt { + if cred == Some(racnt.to_owned()) { maybe_idx = Some(idx); } }