Repository navigation
Add HTLC support to BOLT 3 commitment transaction - #181
NishantBansal2003 wants to merge 11 commits into
Conversation
e930116 to
a0cc8a9
Compare
a0cc8a9 to
06279db
Compare
erickcestari
left a comment
There was a problem hiding this comment.
Nice PR! I've added some notes:
| /// | ||
| /// Returns [`CommitmentError::HtlcNotFound`] if no in-flight HTLC matches | ||
| /// `id` and `offerer`. | ||
| pub fn fulfill_htlc(&mut self, id: u64, offerer: Side) -> Result<(), CommitmentError> { |
There was a problem hiding this comment.
fulfill_htlc, fail_htlc, update_fee, update_per_commitment_point and advance_commitment_number are missing unit tests.
| /// | ||
| /// Returns [`CommitmentError::HtlcExceedsBalance`] if the HTLC amount | ||
| /// would underflow the offerer's balance. | ||
| pub fn add_htlc(&mut self, htlc: Htlc) -> Result<(), CommitmentError> { |
There was a problem hiding this comment.
We could either return an error or assert when an attempt is made to add a duplicate Htlc.
There was a problem hiding this comment.
Currently, we are the initiator here (In the future, when the target might be the initiator, we should definitely sanitize the result in the oracle itself before coming here), If we prohibit the duplicate HTLC case, we won't be able to test that case with the target. So I think we should just add it (it's not an issue in the commitment tx anyway), and if the peer's response is not an error/warning, that should be handled in the oracle.
I was also thinking of removing the HtlcExceedsBalance case as well, similar to how we handled the commitment fee case in the commitment tx with saturating_sub (Will also add a comment discussing the edge cases that are not handled here and should be handled only by the oracle)
| let pos = self | ||
| .htlcs | ||
| .iter() | ||
| .position(|h| h.id == id && h.offerer == offerer) | ||
| .ok_or(CommitmentError::HtlcNotFound)?; |
There was a problem hiding this comment.
I think, based on the discussion in #181 (comment), there might be a comment suggesting that we should remove the HtlcNotFound error and make it a hard assert, since this will also be checked by the oracle before getting here. But I think we should keep this until we have those oracles
06279db to
fef5d69
Compare
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Add optional incoming_htlcs/outgoing_htlcs and the matching local_htlc_signatures/remote_htlc_signatures fields to the commitment test vectors, load them into the commitment state and assert the second-stage HTLC signatures alongside the commitment signatures. Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
fef5d69 to
3096365
Compare
ref: #111
Depends-on: #275
Bolts ref:
Verification
Anchor test vectors (local signatures): https://github.com/ACINQ/eclair/blob/master/eclair-core/src/test/resources/bolt3-tx-test-vectors-anchor-outputs-zero-fee-htlc-tx-format.txt
Custom tests on top of commit ACINQ/eclair@26d035070 (after this commit, eclair removed support for non-anchor channels), with the diff below:
Eclair diff