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

Redesign TxBuilder #899

Open
Tracked by #57 ...
evanlinjin opened this issue Mar 17, 2023 · 2 comments
Open
Tracked by #57 ...

Redesign TxBuilder #899

evanlinjin opened this issue Mar 17, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request module-wallet

Comments

@evanlinjin
Copy link
Member

evanlinjin commented Mar 17, 2023

Description

We can design a more intuitive transaction-building flow by splitting tx-building into the follow stages:

  1. Coin Control
    • Determine which coins can be candidates, and which coins to filter out.
    • Determine coin groups (which coins must be spent together, and which coins must NOT be spent together).
    • Add plan to each coin (from planning module).
  2. Coin Selection
    • Select coins for the actual transaction.
    • Determine whether we need a drain output (change policy).
  3. Transaction Finalization
    • Formulate unsigned transaction.
    • Reordering/shuffling of inputs/outputs.
  4. PSBT Preparation
    • Maps the candidates chosen by coin selection to their plans and uses the plan to create the PSBT input.
    • Maps the outputs (including drain if exists) into the PSBT.
  5. Signing

Implementation Details

  • For "must be spent together", group them somehow like: Vec<(Plan, TxOut, OutPoint)>.

Related

@evanlinjin evanlinjin added the enhancement New feature or request label Mar 17, 2023
@evanlinjin evanlinjin added this to the 1.0.0 milestone Mar 17, 2023
@notmandatory notmandatory removed this from the 1.0.0 milestone May 4, 2023
@evanlinjin
Copy link
Member Author

@stevenroose mentioned the following to me in a private conversation:

with bdk, it should be easy to say "hey, I have this tx, I want to add inputs from my bdk and sign them"

basically like "fundrawtx" in Core

This is probably something we should keep in mind when redesigning the TxBuilder.

@ValuedMammal
Copy link
Contributor

  • An ergonomic design would try to decouple signing a PSBT from finalizing it. Technically the finalizer shouldn't require a descriptor or signing keys, per BIP174. This isn't the case in BDK's finalize_psbt which intends to use descriptor.satisfy(). For more context Question: Finalizing a fully signed PSBT bdk-ffi#469.

  • BIP174 states that "All other data except the UTXO and unknown fields in the input key-value map should be cleared from the PSBT," but BDK only partially respects this or treats it as optional (the extra customization could be justified). See finalize_mut for how this might look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request module-wallet
Projects
Status: In Progress
Development

No branches or pull requests

4 participants