@@ -21,6 +21,7 @@ import Control.Exception (IOException)
21
21
import Control.Monad.Class.MonadThrow (Handler (Handler ), catches )
22
22
import Control.Tracer (Tracer , traceWith )
23
23
import GHC.IO.Exception (IOErrorType (ResourceExhausted ), IOException (ioe_type ))
24
+ import Hydra.Cardano.Api.Pretty (renderTx )
24
25
import Hydra.Chain.CardanoClient (queryProtocolParameters )
25
26
import Hydra.Chain.Direct.ScriptRegistry (
26
27
publishHydraScripts ,
@@ -112,16 +113,24 @@ returnFundsToFaucet tracer node@RunningNode{networkId, nodeSocket} sender = do
112
113
113
114
(senderVk, senderSk) <- keysFor sender
114
115
utxo <- queryUTxOFor networkId nodeSocket QueryTip senderVk
116
+ traceShowM (" RemainingFunds utxo:" <> renderUTxO utxo)
115
117
retryOnExceptions tracer $ do
116
118
let utxoValue = balance @ Tx utxo
117
119
let allLovelace = selectLovelace utxoValue
120
+ traceShowM (" allLovelace:" <> show allLovelace)
118
121
-- select tokens other than ADA here so we can burn it afterwards
119
122
let otherTokens = filterValue (/= AdaAssetId ) utxoValue
123
+ traceShowM (" otherTokens:" <> renderValue otherTokens)
120
124
-- XXX: Using a hard-coded high-enough value to satisfy the min utxo value.
121
125
-- NOTE: We use the faucet address as the change deliberately here.
122
- fee <- calculateTxFee node senderSk utxo faucetAddress 1_500_000
126
+ fee <- calculateTxFee node senderSk utxo faucetAddress 1_000_000
127
+ traceShowM (" fee:" <> show fee)
123
128
let returnBalance = allLovelace - fee
124
- tx <- sign senderSk <$> buildTxBody utxo faucetAddress returnBalance otherTokens
129
+ traceShowM (" returnBalance:" <> show returnBalance)
130
+ returnTxBody <- buildTxBody utxo faucetAddress returnBalance otherTokens
131
+ traceShowM (" returnTxBody:" <> show returnTxBody)
132
+ let tx = sign senderSk returnTxBody
133
+ traceShowM (" tx:" <> renderTx tx)
125
134
submitTransaction networkId nodeSocket tx
126
135
void $ awaitTransaction networkId nodeSocket tx
127
136
traceWith tracer $ ReturnedFunds {actor = actorName sender, returnAmount = returnBalance}
0 commit comments