@@ -12,7 +12,12 @@ module Cardano.Wallet.Kernel.CoinSelection.FromGeneric (
12
12
, newOptions
13
13
-- * Transaction building
14
14
, CoinSelFinalResult (.. )
15
+ , UnsignedTx -- opaque
16
+ , utxOwnedInputs
17
+ , utxOutputs
18
+ , utxChange
15
19
, mkStdTx
20
+ , mkStdUnsignedTx
16
21
-- * Coin selection policies
17
22
, random
18
23
, largestFirst
@@ -178,6 +183,27 @@ feeOptions CoinSelectionOptions{..} = FeeOptions{
178
183
Building transactions
179
184
-------------------------------------------------------------------------------}
180
185
186
+ -- | Our notion of @unsigned transaction@. Unfortunately we cannot reuse
187
+ -- directly the 'Tx' from @Core@ as that discards the information about
188
+ -- "ownership" of inputs, which is instead required when dealing with the
189
+ -- Core Txp.Util API.
190
+ data UnsignedTx = UnsignedTx {
191
+ utxOwnedInputs :: NonEmpty (Core. TxIn , Core. TxOutAux )
192
+ , utxOutputs :: NonEmpty Core. TxOutAux
193
+ , utxChange :: [Core. Coin ]
194
+ }
195
+
196
+ -- | Creates a "standard" unsigned transaction.
197
+ mkStdUnsignedTx :: NonEmpty (Core. TxIn , Core. TxOutAux )
198
+ -- ^ Selected inputs
199
+ -> NonEmpty Core. TxOutAux
200
+ -- ^ Selected outputs
201
+ -> [Core. Coin ]
202
+ -- ^ Change coins
203
+ -> UnsignedTx
204
+ mkStdUnsignedTx inps outs change = UnsignedTx inps outs change
205
+
206
+
181
207
-- | Build a transaction
182
208
183
209
-- | Construct a standard transaction
@@ -200,11 +226,12 @@ mkStdTx :: Monad m
200
226
mkStdTx pm shuffle hdwSigners inps outs change = do
201
227
allOuts <- shuffle $ foldl' (flip NE. cons) outs change
202
228
return $ CTxp. makeMPubKeyTxAddrs pm hdwSigners (fmap repack inps) allOuts
203
- where
204
- -- Repack a utxo-derived tuple into a format suitable for
205
- -- 'TxOwnedInputs'.
206
- repack :: (Core. TxIn , Core. TxOutAux ) -> (Core. TxOut , Core. TxIn )
207
- repack (txIn, aux) = (Core. toaOut aux, txIn)
229
+
230
+ -- | Repacks a utxo-derived tuple into a format suitable for
231
+ -- 'TxOwnedInputs'.
232
+ repack :: (Core. TxIn , Core. TxOutAux ) -> (Core. TxOut , Core. TxIn )
233
+ repack (txIn, aux) = (Core. toaOut aux, txIn)
234
+
208
235
209
236
{- ------------------------------------------------------------------------------
210
237
Coin selection policy top-level entry point
0 commit comments