Skip to content

Send: improve PSBT funding by using new lnd RPC #118

Closed
@jharveyb

Description

@jharveyb

Right now the send state machine computes TX outputs and constructs a PSBT; we need the connected LND instance to add an input to cover TX fees, and we also need to add the input that carries the input TaroCommitment.

Limitations & solutions:

  • Right now the FundPsbt() call will always BIP69 sort the outputs, which would break existing split commitments. However, we have enough information to restore the original output layout.
  • FundPsbt() will return an error if any inputs are attached that are not owned by the wallet, so we must use FundPsbt() before attaching our asset-bearing input.
  • Without the asset-bearing inputs attached, FundPsbt() will underpay on fees. We can work around this by computing the fee needed to cover the asset-bearing inputs, increase the change output value by this amount, and later decrement the change output value.

Given that, we have some options for implementation:

  1. Pass the PSBT as-is to the wallet via FundPsbt(), attach our input and key derivation info to the funded PSBT, reshuffle outputs, have the wallet sign via SignPsbt(), finalize with FinalizePsbt(). This would result in underpaying on fees.
  2. Same as 1, but compute the fee impact of our asset-bearing input and increment the dummy output values before passing the PSBT to FundPsbt().
  3. Update the FundPsbt() walletrpc call to make BIP69 compliance optional, so we don't have to reshuffle outputs in option 1.
  4. Perform coin selection on the tarod side via ListUnspent(), attach the asset-bearing inputs, then use SignPsbt() and FinalizePsbt().

The initial implementation is using option 1, but it may be worth revising the FundPsbt() RPC call in the future to simplify this flow.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions