funding: fund channel with selected utxos (funding)

https://github.com/lightningnetwork/lnd/pull/7516

Host: hieblmi  -  PR author: hieblmi

Notes

  • The PR description itself should provide a good intro.
  • This PR is utilizing the fundmax flag introduced with https://github.com/lightningnetwork/lnd/pull/6903. It might be helpful to get a rough idea of how it works - especially CoinSelectUpToAmount.
  • The integration test itest/lnd_channel_funding_utxo_selection_test.go provides a good overview of the proposed behavior introduced by this PR.

Questions

  • Did you review the PR and, if so, what’s your overall verdict? (ACK, NACK, concept ACK, unknown, mega-NACK)
  • What use cases can you think of where it might be useful to only take a subset of coins in our wallet into account for funding a channel?
  • How could the lncli openchannel --local_amt flow mix coins that the user potentially would want to keep separate? Hint: Checkout chanfunding/coin_select.go - func CoinSelect().
  • Is there another way of selecting specific UTXOs to fund a channel? If so, what are pros and cons you can think of for this alternative?
  • Since we are manually selecting coins - why are we still calling

    • CoinSelect in case we lncli openchannel --local_amt ?
    • CoinSelectUpToAmount in case we lncli openchannel --fundmax ?
  • Why is reserve set to 0 here? (Note, this is the fundmax flow of the PR) https://github.com/lightningnetwork/lnd/blob/e0b2308265da554115cae5ece244c3b5afb7346f/lnwallet/chanfunding/wallet_assembler.go#L382
    • Can you think of an edge case that isn’t considered here? What if sumAll-sumManual < reserve?
    • Do you see a problem here in the case of the local_amt flow? This flow is handled in the default case of the switch statement, here https://github.com/lightningnetwork/lnd/blob/e0b2308265da554115cae5ece244c3b5afb7346f/lnwallet/chanfunding/wallet_assembler.go#L431