From 88c15abeefbf88311781c14853a0a699274e73c6 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 29 Jul 2017 17:40:14 -0700 Subject: [PATCH] channeldb: remove RevocationDelay field from the HTLC struct This commit removes the RevocationDelay field from the HTLC struct as with the latest commitment transaction scheme, it is no longer needed. This is due to the fact the the delay is now observed when an on-chain HTLC claim is attempted, rather than from Shane the HTLC itself has been broadcast. --- channeldb/channel.go | 22 ++++------------------ channeldb/channel_test.go | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/channeldb/channel.go b/channeldb/channel.go index 45336e07..56278e17 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -530,13 +530,6 @@ type HTLC struct { // must wait before reclaiming the funds in limbo. RefundTimeout uint32 - // RevocationDelay is the relative timeout the party who broadcasts the - // commitment transaction must wait before being able to fully sweep - // the funds on-chain in the case of a unilateral channel closure. - // - // TODO(roasbeef): no longer needed? - RevocationDelay uint32 - // OutputIndex is the output index for this particular HTLC output // within the commitment transaction. OutputIndex int32 @@ -549,11 +542,10 @@ type HTLC struct { // Copy returns a full copy of the target HTLC. func (h *HTLC) Copy() HTLC { clone := HTLC{ - Incoming: h.Incoming, - Amt: h.Amt, - RefundTimeout: h.RefundTimeout, - RevocationDelay: h.RevocationDelay, - OutputIndex: h.OutputIndex, + Incoming: h.Incoming, + Amt: h.Amt, + RefundTimeout: h.RefundTimeout, + OutputIndex: h.OutputIndex, } copy(clone.Signature[:], h.Signature) copy(clone.RHash[:], h.RHash[:]) @@ -2045,9 +2037,6 @@ func serializeHTLC(w io.Writer, h *HTLC) error { if err := binary.Write(w, byteOrder, h.RefundTimeout); err != nil { return err } - if err := binary.Write(w, byteOrder, h.RevocationDelay); err != nil { - return err - } if err := binary.Write(w, byteOrder, h.OutputIndex); err != nil { return err } @@ -2085,9 +2074,6 @@ func deserializeHTLC(r io.Reader) (*HTLC, error) { if err := binary.Read(r, byteOrder, &h.RefundTimeout); err != nil { return nil, err } - if err := binary.Read(r, byteOrder, &h.RevocationDelay); err != nil { - return nil, err - } if err := binary.Read(r, byteOrder, &h.OutputIndex); err != nil { return nil, err } diff --git a/channeldb/channel_test.go b/channeldb/channel_test.go index 917e689e..98087a55 100644 --- a/channeldb/channel_test.go +++ b/channeldb/channel_test.go @@ -205,12 +205,11 @@ func TestOpenChannelPutGetDelete(t *testing.T) { } state.Htlcs = []*HTLC{ { - Signature: testSig.Serialize(), - Incoming: true, - Amt: 10, - RHash: key, - RefundTimeout: 1, - RevocationDelay: 2, + Signature: testSig.Serialize(), + Incoming: true, + Amt: 10, + RHash: key, + RefundTimeout: 1, }, } if err := state.FullSync(); err != nil { @@ -348,18 +347,19 @@ func TestChannelStateTransition(t *testing.T) { incoming = true } htlc := &HTLC{ - Signature: testSig.Serialize(), - Incoming: incoming, - Amt: 10, - RHash: key, - RefundTimeout: i, - RevocationDelay: i + 2, - OutputIndex: int32(i * 3), + Signature: testSig.Serialize(), + Incoming: incoming, + Amt: 10, + RHash: key, + RefundTimeout: i, + OutputIndex: int32(i * 3), } htlcs = append(htlcs, htlc) htlcAmt += htlc.Amt } + // TODO(roasbeef): ensure that expiry matches + // Create a new channel delta which includes the above HTLCs, some // balance updates, and an increment of the current commitment height. // Additionally, modify the signature and commitment transaction.