Account for existing input amounts throughout coin selection
authorWilmer Paulino <wilmer@wilmerpaulino.com>
Mon, 18 Sep 2023 21:00:37 +0000 (14:00 -0700)
committerWilmer Paulino <wilmer@wilmerpaulino.com>
Tue, 19 Sep 2023 18:13:41 +0000 (11:13 -0700)
commit38f18ceba6fa2e67222fc43e75d9bb3561bad109
tree3ff6ad666f1effe2712b1a2e3adee76753bd9a78
parentceebf6256e339642c0380a6379ce0f2020d1a6cf
Account for existing input amounts throughout coin selection

We'd previously ignore the existing amount transactions were already
attempting to spend when deciding whether we should add more inputs
throughout coin selection. This would result in us attaching more inputs
than necessary to satisfy our target amount. In the case of HTLC
transactions, we'd burn the HTLC amount completely, since the pre-signed
transaction has zero fee (input amount == output amount).

Along the way, we also fix the slight overpayment in anchor
transactions. We now properly account for the fees the transaction
already paid for, simply by pretending the fees are part of the anchor
input amount.
lightning/src/events/bump_transaction.rs