funding: add fundmax flag to OpenChannelRequest (funding)

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

Host: Crypt-IQ  -  PR author: hieblmi

Notes

  • The majority of the code change is in the lnwallet/chanfunding package. The flow for opening channels at the code-level is, roughly, rpcserver.go -> funding/manager.go -> lnwallet. User-specified parameters such as fundmax will reach the lnwallet code through this path.
  • Check out the channel funding coin selection logic in lnwallet/chanfunding/coin_select.go
  • Consider checking out itest/lnd_channel_funding_fund_max_test.go to have a good overview of fundmax behavior.

Questions

Questions:

  • Did you review the PR and, if so, what’s your overall verdict? (ACK, NACK, concept ACK, unknown, mega-NACK, tACK)
  • Did you test the PR and, if so, how did you find the fundmax option?
    • Could it use more documentation on the cli?
    • Did anything break?
  • What is the problem that fundmax is trying to solve?
  • Why do we disallow setting LocalFundingAmt and FundMax?
  • Why do we disallow setting a psbt with FundMax?
  • Why do we disable fundmax for CannedAssembler and PsbtAssembler?
  • In lnwallet/chanfunding/coin_select.go:
    • What does the CoinSelect function do?
    • What does the CoinSelectSubtractFees function do?
      • How does CoinSelect differ from CoinSelectSubtractFees?
    • What does the CoinSelectUpToAmount function do?
      • How does CoinSelectUpToAmount differ from the previous two functions?
  • In lnwallet/chanfunding/assembler.go:
    • What role does RemoteChanReserve play in the Request struct?
    • What about WalletReserve?