lnwallet: properly handle HTLC settles in channel state-machine

We no longer track HTLC’s by their r-hash within the log into the
index, as we may have multiple HTLC’s that can be redeemed by the same
pre-image. Instead we now use a separate index which is keyed by a
log-index.

Additionally, the SettleHTLC method now also returns the index of the
HTLC being settled which allows the remote party to quickly locate the
HTLC within their log.

This commit also introduces a few trace/debug log messages which will
likely be pruned in the near future
This commit is contained in:
Olaoluwa Osuntokun committed 2016-07-12 17:35:57 -07:00
1 parent 06f062e678
commit 7dea354711
3 files changed
+56 -33

No files matched your search

+2 -5
View File
@@ -329,13 +329,10 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
// HTLC once he learns of the preimage.
var preimage [32]byte
copy(preimage[:], paymentPreimage)
wireSettleMsg := &lnwire.HTLCSettleRequest{
RedemptionProofs: [][32]byte{preimage},
}
if err := bobChannel.SettleHTLC(wireSettleMsg, false); err != nil {
if _, err := bobChannel.SettleHTLC(preimage, false); err != nil {
t.Fatalf("bob unable to settle inbound htlc: %v", err)
}
if err := aliceChannel.SettleHTLC(wireSettleMsg, true); err != nil {
if _, err := aliceChannel.SettleHTLC(preimage, true); err != nil {
t.Fatalf("alice unable to accept settle of outbound htlc: %v", err)
}
bobSig2, aliceIndex2, err := bobChannel.SignNextCommitment()