@@ -34,28 +34,12 @@ buildScriptAddress script networkId =
34
34
in makeShelleyAddress networkId (PaymentCredentialByScript hashed) NoStakeAddress
35
35
36
36
-- | Build a "raw" transaction from a bunch of inputs, outputs and fees.
37
- buildRaw :: [TxIn ] -> [TxOut CtxTx ] -> Coin -> Either TxBodyError TxBody
38
- buildRaw ins outs fee =
37
+ buildRaw :: [TxIn ] -> [TxOut CtxTx ] -> Either TxBodyError TxBody
38
+ buildRaw ins outs =
39
39
createAndValidateTransactionBody $
40
40
defaultTxBodyContent
41
41
& setTxIns (map (,BuildTxWith $ KeyWitness KeyWitnessForSpending ) ins)
42
42
& setTxOuts outs
43
- & setTxFee (TxFeeExplicit fee)
44
-
45
- calculateMinFee :: NetworkId -> TxBody -> Sizes -> ProtocolParameters -> Coin
46
- calculateMinFee networkId body Sizes {inputs, outputs, witnesses} pparams =
47
- let tx = makeSignedTransaction [] body
48
- noByronWitnesses = 0
49
- in estimateTransactionFee
50
- shelleyBasedEra
51
- networkId
52
- (protocolParamTxFeeFixed pparams)
53
- (protocolParamTxFeePerByte pparams)
54
- tx
55
- inputs
56
- outputs
57
- noByronWitnesses
58
- witnesses
59
43
60
44
data Sizes = Sizes
61
45
{ inputs :: Int
@@ -126,16 +110,15 @@ waitForUTxO networkId nodeSocket utxo =
126
110
127
111
mkGenesisTx ::
128
112
NetworkId ->
129
- ProtocolParameters ->
130
113
-- | Owner of the 'initialFund'.
131
114
SigningKey PaymentKey ->
132
115
-- | Amount of initialFunds
133
116
Coin ->
134
117
-- | Recipients and amounts to pay in this transaction.
135
118
[(VerificationKey PaymentKey , Coin )] ->
136
119
Tx
137
- mkGenesisTx networkId pparams signingKey initialAmount recipients =
138
- case buildRaw [initialInput] (recipientOutputs <> [changeOutput]) fee of
120
+ mkGenesisTx networkId signingKey initialAmount recipients =
121
+ case buildRaw [initialInput] (recipientOutputs <> [changeOutput]) of
139
122
Left err -> error $ " Fail to build genesis transations: " <> show err
140
123
Right tx -> sign signingKey tx
141
124
where
@@ -144,18 +127,13 @@ mkGenesisTx networkId pparams signingKey initialAmount recipients =
144
127
networkId
145
128
(unsafeCastHash $ verificationKeyHash $ getVerificationKey signingKey)
146
129
147
- fee = calculateMinFee networkId rawTx Sizes {inputs = 1 , outputs = length recipients + 1 , witnesses = 1 } pparams
148
- rawTx = case buildRaw [initialInput] [] 0 of
149
- Left err -> error $ " Fail to build genesis transactions: " <> show err
150
- Right tx -> tx
151
-
152
130
totalSent = foldMap snd recipients
153
131
154
132
changeAddr = mkVkAddress networkId (getVerificationKey signingKey)
155
133
changeOutput =
156
134
TxOut
157
135
changeAddr
158
- (lovelaceToValue $ initialAmount - totalSent - fee )
136
+ (lovelaceToValue $ initialAmount - totalSent)
159
137
TxOutDatumNone
160
138
ReferenceScriptNone
161
139
0 commit comments