Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API additions for automating transaction building #2906

Merged
merged 11 commits into from
Jul 13, 2021

Commits on Jul 8, 2021

  1. Tidy up the {to,from}ShelleyTxOut conversion functions

    Make them more regular by having both take an era param, fix the names
    and make them both clearly general in the era.
    dcoutts committed Jul 8, 2021
    Configuration menu
    Copy the full SHA
    132e0a2 View commit details
    Browse the repository at this point in the history
  2. Add rename fromUTxO to fromLedgerUTxO and add toLedgerUTxO

    Conversion functions within the API. We'll need both.
    dcoutts committed Jul 8, 2021
    Configuration menu
    Copy the full SHA
    9147b7b View commit details
    Browse the repository at this point in the history
  3. Add API evaluateTransactionBalance

    Compute the total balance of the proposed transaction. Ultimately a
    valid transaction must be fully balanced: that is have a total value
    of zero.
    
    Finding the (non-zero) balance of partially constructed transaction
    is useful for adjusting a transaction to be fully balanced.
    dcoutts committed Jul 8, 2021
    Configuration menu
    Copy the full SHA
    a67dc66 View commit details
    Browse the repository at this point in the history
  4. Add API evaluateTransactionFee

    Compute the transaction fee for a proposed transaction, with the
    assumption that there will be the given number of key witnesses
    (i.e. signatures).
    dcoutts committed Jul 8, 2021
    1 Configuration menu
    Copy the full SHA
    a8e2460 View commit details
    Browse the repository at this point in the history
  5. Add API estimateTransactionKeyWitnessCount

    Give an approximate count of the number of key witnesses
    (i.e. signatures) a transaction will need.
    dcoutts committed Jul 8, 2021
    1 Configuration menu
    Copy the full SHA
    ead1a15 View commit details
    Browse the repository at this point in the history
  6. Introduce API concept of ScriptWitnessIndex

    This more-or-less mirrors the RdmrPtr, which we generally want to hide,
    but for some kinds of tx manipulation it is inevitable. In particular we
    will need it to be able to provide the execution units for each script
    use, and to perform substitutions.
    dcoutts committed Jul 8, 2021
    1 Configuration menu
    Copy the full SHA
    ea5c08f View commit details
    Browse the repository at this point in the history
  7. Export collectTxBodyScriptWitnesses and make it use ScriptWitnessIndex

    The collectTxBodyScriptWitnesses helper function was previously only
    being used within makeShelleyTransactionBody, but with the addition of
    the public ScriptWitnessIndex type, it now makes sense to have it use
    that and to expose the function.
    
    It also makes it clearer what the types ScriptWitnessIndex and
    AnyScriptWitness are for.
    dcoutts committed Jul 8, 2021
    1 Configuration menu
    Copy the full SHA
    7a6da1f View commit details
    Browse the repository at this point in the history
  8. Add API evaluateTransactionExecutionUnits

    Compute the ExecutionUnits needed for each script in the transaction.
    
    This works by running all the scripts and counting how many execution
    units are actually used.
    dcoutts committed Jul 8, 2021
    1 Configuration menu
    Copy the full SHA
    ddfe2b4 View commit details
    Browse the repository at this point in the history

Commits on Jul 9, 2021

  1. Add a few TxBody utils

    That we will use for the auto-balancing tx construction.
    dcoutts committed Jul 9, 2021
    1 Configuration menu
    Copy the full SHA
    e20909a View commit details
    Browse the repository at this point in the history
  2. Add API makeTransactionBodyAutoBalance

    This is much like 'makeTransactionBody' but with greater automation to
    calculate suitable values for several things.
    
    In particular:
    
     * It calculates the correct script 'ExecutionUnits' (ignoring the provided
       values, which can thus be zero).
    
     * It calculates the transaction fees, based on the script 'ExecutionUnits',
       the current 'ProtocolParameters', and an estimate of the number of
       key witnesses (i.e. signatures). There is an override for the number of
       key witnesses.
    
     * It accepts a change address, calculates the balance of the transaction
       and puts the excess change into the change output.
    
     * It also checks that the balance is positive and the change is above the
       minimum threshold.
    
    To do this it needs more information than 'makeTransactionBody', all of
     which can be queried from a local node.
    dcoutts committed Jul 9, 2021
    1 Configuration menu
    Copy the full SHA
    66c86f2 View commit details
    Browse the repository at this point in the history
  3. Fix hlint warnings

    Well, in this case supress since it was not helpful.
    dcoutts committed Jul 9, 2021
    Configuration menu
    Copy the full SHA
    1600261 View commit details
    Browse the repository at this point in the history