Skip to content

Commit 7df33c8

Browse files
authored
Merge pull request #17 from cardano-scaling/lc/fix-collateral
Use correct addresses for collateral and claim outputs
2 parents 8d12057 + 494358f commit 7df33c8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

hydra-lightning-router/src/Hydra/Lightning/Scenario.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,16 @@ aliceBobIdaTransferAcrossHeads tracer backend hydraScriptsTxId = do
213213
-- CLAIM TX
214214
headUTxO' <- getSnapshotUTxO n2
215215
let claimUTxO = C.filter (\(TxOut a _ _ _) -> a == mkScriptAddress networkId htlcValidatorScript) headUTxO'
216-
let headCollateral = C.filter (\(TxOut a _ _ _) -> a /= mkScriptAddress networkId htlcValidatorScript) headUTxO'
217216

218217
let claimRecipient =
219218
C.shelleyAddressInEra C.ShelleyBasedEraConway (vkAddress networkId carolWalletVk)
219+
let headCollateral = C.filter (\(TxOut a _ _ _) -> a == claimRecipient) headUTxO'
220220
let expectedKeyHashes = [C.verificationKeyHash carolWalletVk]
221221
let collateral = head $ Set.toList $ C.inputSet headCollateral
222222

223-
claimTx <- buildClaimTX pparams preImage' claimRecipient expectedKeyHashes lockedVal claimUTxO headCollateral collateral changeAddress
223+
claimTx <- buildClaimTX pparams preImage' claimRecipient expectedKeyHashes lockedVal claimUTxO headCollateral collateral claimRecipient
224224
-- We only need Alice sig for collateral input
225-
let signedClaimTx = signTx aliceWalletSk $ signTx carolWalletSk claimTx
225+
let signedClaimTx = signTx carolWalletSk claimTx
226226

227227
send n2 $ input "NewTx" ["transaction" Aeson..= signedClaimTx]
228228

@@ -300,17 +300,19 @@ aliceBobIdaTransferAcrossHeads tracer backend hydraScriptsTxId = do
300300
Aeson.toJSON signedL2tx
301301
`elem` (v ^.. key "snapshot" . key "confirmed" . values)
302302

303+
threadDelay 5_000_000
304+
303305
-- CLAIM TX
304306
headUTxO' <- getSnapshotUTxO n3
305307
let claimUTxO = C.filter (\(TxOut a _ _ _) -> a == mkScriptAddress networkId htlcValidatorScript) headUTxO'
306-
let headCollateral = C.filter (\(TxOut a _ _ _) -> a /= mkScriptAddress networkId htlcValidatorScript) headUTxO'
307308
let claimRecipient =
308309
C.shelleyAddressInEra C.ShelleyBasedEraConway (vkAddress networkId bobWalletVk)
310+
let headCollateral = C.filter (\(TxOut a _ _ _) -> a == claimRecipient) headUTxO'
309311
let expectedKeyHashes = [C.verificationKeyHash bobWalletVk]
310312
let collateral = head $ Set.toList $ C.inputSet headCollateral
311313

312-
claimTx <- buildClaimTX pparams preImage claimRecipient expectedKeyHashes lockedVal claimUTxO headCollateral collateral changeAddress
313-
let signedClaimTx = signTx carolWalletSk $ signTx bobWalletSk claimTx
314+
claimTx <- buildClaimTX pparams preImage claimRecipient expectedKeyHashes lockedVal claimUTxO headCollateral collateral claimRecipient
315+
let signedClaimTx = signTx bobWalletSk claimTx
314316

315317
send n3 $ input "NewTx" ["transaction" Aeson..= signedClaimTx]
316318

images/out.mp4

9.15 MB
Binary file not shown.

0 commit comments

Comments
 (0)