View on GitHub
File Changes

                      
{- Note [Submitting transactions from Plutus contracts]

                      
-
To turn an 'LedgerTxConstraints' value into a valid transaction that can be
-
submitted to the network, the contract backend needs to
+
'UnbalancedTx' is the type of transactions that meet some set of constraints
+
(produced by 'Ledger.Constraints.OffChain.mkTx'), but can't be submitted to
+
the ledger yet because they may not be balanced and they lack signatures and
+
fee payments. To turn an 'UnbalancedTx' value into a valid transaction that can
+
be submitted to the network, the contract backend needs to

                      
* Balance it.
-
  If the total value of 'tcInputs' + the 'tcForge' field is
-
  greater than the total value of 'tcOutputs', then one or more public key
+
  If the total value of 'txInputs' + the 'txForge' field is
+
  greater than the total value of 'txOutputs', then one or more public key
  outputs need to be added. How many and what addresses they are is up
  to the wallet (probably configurable).
-
  If the total balance 'tcInputs' + the 'tcForge' field is less than
-
  the total value of 'tcOutputs', then one or more public key inputs need
+
  If the total balance 'txInputs' + the 'txForge' field is less than
+
  the total value of 'txOutputs', then one or more public key inputs need
  to be added (and potentially some outputs for the change).
-
  If the total value spent is less than what's specified in the 'tcValueSpent'
-
  field then the missing value needs to be added to both sides, inputs and
-
  outputs.

                      
* Compute fees.
  Once the final size of the transaction is known, the fees for the transaction
  can be computed. The transaction fee needs to be paid for with additional
  inputs so I assume that this step and the previous step will be combined.

                      
-
  Also note that even if the 'LedgerTxConstraints' that we get from the contract
+
  Also note that even if the 'UnbalancedTx' that we get from the contract
  endpoint happens to be balanced already, we still need to add fees to it. So
  we can't skip the balancing & fee computation step.

                      
+
  Balancing and coin selection will eventually be performed by the wallet
+
  backend.
+

                      
* Sign it.
  The signing process needs to provide signatures for all public key
  inputs in the balanced transaction, and for all public keys in the
-
  'utxRequiredSignatures' field.
+
  'unBalancedTxRequiredSignatories' field.

                      
-}

                      
        }

                      
-- | An unbalanced transaction. It needs to be balanced and signed before it
-
--   can be submitted to the ledeger.
+
--   can be submitted to the ledeger. See note [Submitting transactions from 
+
--   Plutus contracts] in 'Language.Plutus.Contract.Wallet'.
data UnbalancedTx =
    UnbalancedTx
        { unBalancedTxTx                  :: Tx