not finished index persistence
This commit is contained in:
parent
28dd6e5d84
commit
9247168c5d
@ -3,6 +3,7 @@ package channeldb
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -68,6 +69,8 @@ var (
|
|||||||
minFeePerKwPrefix = []byte("mfp")
|
minFeePerKwPrefix = []byte("mfp")
|
||||||
chanConfigPrefix = []byte("chan-config")
|
chanConfigPrefix = []byte("chan-config")
|
||||||
updatePrefix = []byte("uup")
|
updatePrefix = []byte("uup")
|
||||||
|
ourIndexPrefix = []byte("tip")
|
||||||
|
theirIndexPrefix = []byte("oip")
|
||||||
satSentPrefix = []byte("ssp")
|
satSentPrefix = []byte("ssp")
|
||||||
satReceivedPrefix = []byte("srp")
|
satReceivedPrefix = []byte("srp")
|
||||||
commitFeePrefix = []byte("cfp")
|
commitFeePrefix = []byte("cfp")
|
||||||
@ -328,6 +331,22 @@ type OpenChannel struct {
|
|||||||
// channel.
|
// channel.
|
||||||
NumUpdates uint64
|
NumUpdates uint64
|
||||||
|
|
||||||
|
// OurMessageIndex...
|
||||||
|
OurMessageIndex uint64
|
||||||
|
|
||||||
|
// TheirMessageIndex...
|
||||||
|
TheirMessageIndex uint64
|
||||||
|
|
||||||
|
// OurMessageIndex...
|
||||||
|
OurAckedIndex uint64
|
||||||
|
|
||||||
|
// TheirMessageIndex...
|
||||||
|
TheirAckedIndex uint64
|
||||||
|
|
||||||
|
// TotalSatoshisSent is the total number of satoshis we've sent within
|
||||||
|
// this channel.
|
||||||
|
TotalSatoshisSent uint64
|
||||||
|
|
||||||
// TotalMSatSent is the total number of milli-satoshis we've sent
|
// TotalMSatSent is the total number of milli-satoshis we've sent
|
||||||
// within this channel.
|
// within this channel.
|
||||||
TotalMSatSent lnwire.MilliSatoshi
|
TotalMSatSent lnwire.MilliSatoshi
|
||||||
@ -474,6 +493,8 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *wire.MsgTx,
|
|||||||
c.LocalBalance = delta.LocalBalance
|
c.LocalBalance = delta.LocalBalance
|
||||||
c.RemoteBalance = delta.RemoteBalance
|
c.RemoteBalance = delta.RemoteBalance
|
||||||
c.NumUpdates = delta.UpdateNum
|
c.NumUpdates = delta.UpdateNum
|
||||||
|
c.OurMessageIndex = delta.OurMessageIndex
|
||||||
|
c.TheirMessageIndex = delta.TheirMessageIndex
|
||||||
c.Htlcs = delta.Htlcs
|
c.Htlcs = delta.Htlcs
|
||||||
c.CommitFee = delta.CommitFee
|
c.CommitFee = delta.CommitFee
|
||||||
c.FeePerKw = delta.FeePerKw
|
c.FeePerKw = delta.FeePerKw
|
||||||
@ -491,6 +512,12 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *wire.MsgTx,
|
|||||||
if err := putChanNumUpdates(chanBucket, c); err != nil {
|
if err := putChanNumUpdates(chanBucket, c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := putOurMessageIndex(chanBucket, c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := putTheirMessageIndex(chanBucket, c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := putChanCommitFee(chanBucket, c); err != nil {
|
if err := putChanCommitFee(chanBucket, c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -509,6 +536,32 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *wire.MsgTx,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateHTLCs....
|
||||||
|
func (c *OpenChannel) UpdateHTLCs(htlcs []*HTLC) error {
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
|
||||||
|
return c.Db.Update(func(tx *bolt.Tx) error {
|
||||||
|
chanBucket, err := tx.CreateBucketIfNotExists(openChannelBucket)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
id := c.IdentityPub.SerializeCompressed()
|
||||||
|
nodeChanBucket, err := chanBucket.CreateBucketIfNotExists(id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := putCurrentHtlcs(nodeChanBucket, htlcs,
|
||||||
|
&c.FundingOutpoint); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// HTLC is the on-disk representation of a hash time-locked contract. HTLCs
|
// HTLC is the on-disk representation of a hash time-locked contract. HTLCs
|
||||||
// are contained within ChannelDeltas which encode the current state of the
|
// are contained within ChannelDeltas which encode the current state of the
|
||||||
// commitment between state updates.
|
// commitment between state updates.
|
||||||
@ -542,6 +595,15 @@ type HTLC struct {
|
|||||||
// OnionBlob is an opaque blob which is used to complete multi-hop
|
// OnionBlob is an opaque blob which is used to complete multi-hop
|
||||||
// routing.
|
// routing.
|
||||||
OnionBlob []byte
|
OnionBlob []byte
|
||||||
|
|
||||||
|
// AddLocalInclusionHeight...
|
||||||
|
AddLocalInclusionHeight uint64
|
||||||
|
|
||||||
|
// AddRemoteInclusionHeight...
|
||||||
|
AddRemoteInclusionHeight uint64
|
||||||
|
|
||||||
|
// DescriptorIndex...
|
||||||
|
DescriptorIndex uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy returns a full copy of the target HTLC.
|
// Copy returns a full copy of the target HTLC.
|
||||||
@ -565,6 +627,12 @@ func (h *HTLC) Copy() HTLC {
|
|||||||
// For ourselves (the local node) we ONLY store our most recent (unrevoked)
|
// For ourselves (the local node) we ONLY store our most recent (unrevoked)
|
||||||
// state for safety purposes.
|
// state for safety purposes.
|
||||||
type ChannelDelta struct {
|
type ChannelDelta struct {
|
||||||
|
// OurMessageIndex...
|
||||||
|
OurMessageIndex uint64
|
||||||
|
|
||||||
|
// TheirMessageIndex...
|
||||||
|
TheirMessageIndex uint64
|
||||||
|
|
||||||
// LocalBalance is our current balance at this particular update
|
// LocalBalance is our current balance at this particular update
|
||||||
// number.
|
// number.
|
||||||
LocalBalance lnwire.MilliSatoshi
|
LocalBalance lnwire.MilliSatoshi
|
||||||
@ -606,9 +674,7 @@ type CommitDiff struct {
|
|||||||
|
|
||||||
// decode...
|
// decode...
|
||||||
func (d *CommitDiff) decode(w io.Writer) error {
|
func (d *CommitDiff) decode(w io.Writer) error {
|
||||||
var h [8]byte
|
if err := binary.Write(w, byteOrder, d.PendingHeight); err != nil {
|
||||||
binary.BigEndian.PutUint64(h[:], d.PendingHeight)
|
|
||||||
if _, err := w.Write(h[:]); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,9 +682,7 @@ func (d *CommitDiff) decode(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var l [2]byte
|
if err := binary.Write(w, byteOrder, uint16(len(d.Updates))); err != nil {
|
||||||
binary.BigEndian.PutUint16(l[:], uint16(len(d.Updates)))
|
|
||||||
if _, err := w.Write(l[:]); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,11 +697,9 @@ func (d *CommitDiff) decode(w io.Writer) error {
|
|||||||
|
|
||||||
// encode...
|
// encode...
|
||||||
func (d *CommitDiff) encode(r io.Reader) error {
|
func (d *CommitDiff) encode(r io.Reader) error {
|
||||||
var h [8]byte
|
if err := binary.Read(r, byteOrder, &d.PendingHeight); err != nil {
|
||||||
if _, err := r.Read(h[:]); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
d.PendingHeight = binary.BigEndian.Uint64(h[:])
|
|
||||||
|
|
||||||
delta, err := deserializeChannelDelta(r)
|
delta, err := deserializeChannelDelta(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -645,11 +707,11 @@ func (d *CommitDiff) encode(r io.Reader) error {
|
|||||||
}
|
}
|
||||||
d.PendingCommitment = delta
|
d.PendingCommitment = delta
|
||||||
|
|
||||||
var l [2]byte
|
var length uint16
|
||||||
if _, err := r.Read(l[:]); err != nil {
|
if err := binary.Read(r, byteOrder, &length); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
d.Updates = make([]lnwire.Message, binary.BigEndian.Uint16(l[:]))
|
d.Updates = make([]lnwire.Message, length)
|
||||||
|
|
||||||
for i, _ := range d.Updates {
|
for i, _ := range d.Updates {
|
||||||
msg, err := lnwire.ReadMessage(r, 0)
|
msg, err := lnwire.ReadMessage(r, 0)
|
||||||
@ -663,7 +725,8 @@ func (d *CommitDiff) encode(r io.Reader) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddCommitDiff...
|
// AddCommitDiff...
|
||||||
func AddCommitDiff(db *DB, diff *CommitDiff) error {
|
func AddCommitDiff(db *DB, fundingOutpoint *wire.OutPoint,
|
||||||
|
diff *CommitDiff) error {
|
||||||
return db.Update(func(tx *bolt.Tx) error {
|
return db.Update(func(tx *bolt.Tx) error {
|
||||||
bucket, err := tx.CreateBucketIfNotExists(commitDiffBucket)
|
bucket, err := tx.CreateBucketIfNotExists(commitDiffBucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -675,12 +738,19 @@ func AddCommitDiff(db *DB, diff *CommitDiff) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return bucket.Put([]byte("cdf"), b.Bytes())
|
var outpoint bytes.Buffer
|
||||||
|
if err := writeOutpoint(&outpoint, fundingOutpoint); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
key := []byte("cdf")
|
||||||
|
key = append(key, outpoint.Bytes()...)
|
||||||
|
return bucket.Put(key, b.Bytes())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchCommitDiff...
|
// FetchCommitDiff...
|
||||||
func FetchCommitDiff(db *DB) (*CommitDiff, error) {
|
func FetchCommitDiff(db *DB, fundingOutpoint *wire.OutPoint) (*CommitDiff, error) {
|
||||||
var diff *CommitDiff
|
var diff *CommitDiff
|
||||||
err := db.View(func(tx *bolt.Tx) error {
|
err := db.View(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket(commitDiffBucket)
|
bucket := tx.Bucket(commitDiffBucket)
|
||||||
@ -688,8 +758,15 @@ func FetchCommitDiff(db *DB) (*CommitDiff, error) {
|
|||||||
return errors.New("commit diff bucket haven't been found")
|
return errors.New("commit diff bucket haven't been found")
|
||||||
}
|
}
|
||||||
|
|
||||||
data := bucket.Get([]byte("cdf"))
|
var outpoint bytes.Buffer
|
||||||
if data != nil {
|
if err := writeOutpoint(&outpoint, fundingOutpoint); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
key := []byte("cdf")
|
||||||
|
key = append(key, outpoint.Bytes()...)
|
||||||
|
data := bucket.Get(key)
|
||||||
|
if data == nil {
|
||||||
return errors.New("unable to find commit diff")
|
return errors.New("unable to find commit diff")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,8 +845,15 @@ func (c *OpenChannel) AppendToRevocationLog(delta *ChannelDelta) error {
|
|||||||
// ...
|
// ...
|
||||||
diffBucket := tx.Bucket(commitDiffBucket)
|
diffBucket := tx.Bucket(commitDiffBucket)
|
||||||
if diffBucket != nil {
|
if diffBucket != nil {
|
||||||
if diffBucket.Get([]byte("cdf")) != nil {
|
var outpoint bytes.Buffer
|
||||||
if err := diffBucket.Delete([]byte("cdf")); err != nil {
|
if err := writeOutpoint(&outpoint, &c.FundingOutpoint); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
key := []byte("cdf")
|
||||||
|
key = append(key, outpoint.Bytes()...)
|
||||||
|
if diffBucket.Get(key) != nil {
|
||||||
|
if err := diffBucket.Delete(key); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1241,6 +1325,12 @@ func putOpenChannel(openChanBucket *bolt.Bucket, nodeChanBucket *bolt.Bucket,
|
|||||||
if err := putChanNumUpdates(openChanBucket, channel); err != nil {
|
if err := putChanNumUpdates(openChanBucket, channel); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := putOurMessageIndex(openChanBucket, channel); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := putTheirMessageIndex(openChanBucket, channel); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := putChanAmountsTransferred(openChanBucket, channel); err != nil {
|
if err := putChanAmountsTransferred(openChanBucket, channel); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1322,6 +1412,12 @@ func fetchOpenChannel(openChanBucket *bolt.Bucket, nodeChanBucket *bolt.Bucket,
|
|||||||
if err = fetchChanNumUpdates(openChanBucket, channel); err != nil {
|
if err = fetchChanNumUpdates(openChanBucket, channel); err != nil {
|
||||||
return nil, fmt.Errorf("unable to read num updates: %v", err)
|
return nil, fmt.Errorf("unable to read num updates: %v", err)
|
||||||
}
|
}
|
||||||
|
if err = fetchOurMessageIndex(openChanBucket, channel); err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to read our message index: %v", err)
|
||||||
|
}
|
||||||
|
if err = fetchTheirMessageIndex(openChanBucket, channel); err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to read their message index: %v", err)
|
||||||
|
}
|
||||||
if err = fetchChanAmountsTransferred(openChanBucket, channel); err != nil {
|
if err = fetchChanAmountsTransferred(openChanBucket, channel); err != nil {
|
||||||
return nil, fmt.Errorf("unable to read sat transferred: %v", err)
|
return nil, fmt.Errorf("unable to read sat transferred: %v", err)
|
||||||
}
|
}
|
||||||
@ -1352,6 +1448,12 @@ func deleteOpenChannel(openChanBucket *bolt.Bucket, nodeChanBucket *bolt.Bucket,
|
|||||||
if err := deleteChanNumUpdates(openChanBucket, channelID); err != nil {
|
if err := deleteChanNumUpdates(openChanBucket, channelID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := deleteOurMessageIndex(openChanBucket, channelID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := deleteTheirMessageIndex(openChanBucket, channelID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := deleteChanAmountsTransferred(openChanBucket, channelID); err != nil {
|
if err := deleteChanAmountsTransferred(openChanBucket, channelID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -2182,6 +2284,84 @@ func fetchChanRevocationState(nodeChanBucket *bolt.Bucket, channel *OpenChannel)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func putOurMessageIndex(openChanBucket *bolt.Bucket, channel *OpenChannel) error {
|
||||||
|
scratch := make([]byte, 8)
|
||||||
|
byteOrder.PutUint64(scratch, channel.OurMessageIndex)
|
||||||
|
|
||||||
|
var b bytes.Buffer
|
||||||
|
if err := writeOutpoint(&b, &channel.FundingOutpoint); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPrefix := make([]byte, 3+b.Len())
|
||||||
|
copy(keyPrefix, ourIndexPrefix)
|
||||||
|
copy(keyPrefix[3:], b.Bytes())
|
||||||
|
|
||||||
|
return openChanBucket.Put(keyPrefix, scratch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteOurMessageIndex(openChanBucket *bolt.Bucket, chanID []byte) error {
|
||||||
|
keyPrefix := make([]byte, 3+len(chanID))
|
||||||
|
copy(keyPrefix, ourIndexPrefix)
|
||||||
|
copy(keyPrefix[3:], chanID)
|
||||||
|
return openChanBucket.Delete(keyPrefix)
|
||||||
|
}
|
||||||
|
|
||||||
|
func fetchOurMessageIndex(openChanBucket *bolt.Bucket, channel *OpenChannel) error {
|
||||||
|
var b bytes.Buffer
|
||||||
|
if err := writeOutpoint(&b, &channel.FundingOutpoint); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPrefix := make([]byte, 3+b.Len())
|
||||||
|
copy(keyPrefix, ourIndexPrefix)
|
||||||
|
copy(keyPrefix[3:], b.Bytes())
|
||||||
|
|
||||||
|
updateBytes := openChanBucket.Get(keyPrefix)
|
||||||
|
channel.OurMessageIndex = byteOrder.Uint64(updateBytes)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func putTheirMessageIndex(openChanBucket *bolt.Bucket, channel *OpenChannel) error {
|
||||||
|
scratch := make([]byte, 8)
|
||||||
|
byteOrder.PutUint64(scratch, channel.TheirMessageIndex)
|
||||||
|
|
||||||
|
var b bytes.Buffer
|
||||||
|
if err := writeOutpoint(&b, &channel.FundingOutpoint); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPrefix := make([]byte, 3+b.Len())
|
||||||
|
copy(keyPrefix, theirIndexPrefix)
|
||||||
|
copy(keyPrefix[3:], b.Bytes())
|
||||||
|
|
||||||
|
return openChanBucket.Put(keyPrefix, scratch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteTheirMessageIndex(openChanBucket *bolt.Bucket, chanID []byte) error {
|
||||||
|
keyPrefix := make([]byte, 3+len(chanID))
|
||||||
|
copy(keyPrefix, theirIndexPrefix)
|
||||||
|
copy(keyPrefix[3:], chanID)
|
||||||
|
return openChanBucket.Delete(keyPrefix)
|
||||||
|
}
|
||||||
|
|
||||||
|
func fetchTheirMessageIndex(openChanBucket *bolt.Bucket, channel *OpenChannel) error {
|
||||||
|
var b bytes.Buffer
|
||||||
|
if err := writeOutpoint(&b, &channel.FundingOutpoint); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPrefix := make([]byte, 3+b.Len())
|
||||||
|
copy(keyPrefix, theirIndexPrefix)
|
||||||
|
copy(keyPrefix[3:], b.Bytes())
|
||||||
|
|
||||||
|
updateBytes := openChanBucket.Get(keyPrefix)
|
||||||
|
channel.TheirMessageIndex = byteOrder.Uint64(updateBytes)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func serializeHTLC(w io.Writer, h *HTLC) error {
|
func serializeHTLC(w io.Writer, h *HTLC) error {
|
||||||
if err := wire.WriteVarBytes(w, 0, h.Signature); err != nil {
|
if err := wire.WriteVarBytes(w, 0, h.Signature); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -2222,6 +2402,18 @@ func serializeHTLC(w io.Writer, h *HTLC) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := binary.Write(w, byteOrder, h.AddLocalInclusionHeight); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := binary.Write(w, byteOrder, h.AddRemoteInclusionHeight); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := binary.Write(w, byteOrder, h.DescriptorIndex); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2272,6 +2464,18 @@ func deserializeHTLC(r io.Reader) (*HTLC, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := binary.Read(r, byteOrder, &h.AddLocalInclusionHeight); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := binary.Read(r, byteOrder, &h.AddRemoteInclusionHeight); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := binary.Read(r, byteOrder, &h.DescriptorIndex); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,6 +872,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
case *lnwire.UpdateFee:
|
case *lnwire.UpdateFee:
|
||||||
// We received fee update from peer. If we are the initator we
|
// We received fee update from peer. If we are the initator we
|
||||||
// will fail the channel, if not we will apply the update.
|
// will fail the channel, if not we will apply the update.
|
||||||
|
@ -1828,9 +1828,9 @@ func TestChannelRetransmission(t *testing.T) {
|
|||||||
serverErr := make(chan error, 4)
|
serverErr := make(chan error, 4)
|
||||||
|
|
||||||
aliceInterceptor := createInterceptorFunc("[alice] <-- [bob]",
|
aliceInterceptor := createInterceptorFunc("[alice] <-- [bob]",
|
||||||
"alice", messages, chanID, false)
|
"alice", messages, chanID, true)
|
||||||
bobInterceptor := createInterceptorFunc("[alice] --> [bob]",
|
bobInterceptor := createInterceptorFunc("[alice] --> [bob]",
|
||||||
"bob", messages, chanID, false)
|
"bob", messages, chanID, true)
|
||||||
|
|
||||||
// Add interceptor to check the order of Bob and Alice messages.
|
// Add interceptor to check the order of Bob and Alice messages.
|
||||||
n := newThreeHopNetwork(t, channels.aliceToBob, channels.bobToAlice,
|
n := newThreeHopNetwork(t, channels.aliceToBob, channels.bobToAlice,
|
||||||
|
@ -516,61 +516,80 @@ func (c *commitment) populateHtlcIndexes(ourCommitTx bool,
|
|||||||
// toChannelDelta converts the target commitment into a format suitable to be
|
// toChannelDelta converts the target commitment into a format suitable to be
|
||||||
// written to disk after an accepted state transition.
|
// written to disk after an accepted state transition.
|
||||||
func (c *commitment) toChannelDelta(ourCommit bool) (*channeldb.ChannelDelta, error) {
|
func (c *commitment) toChannelDelta(ourCommit bool) (*channeldb.ChannelDelta, error) {
|
||||||
numHtlcs := len(c.outgoingHTLCs) + len(c.incomingHTLCs)
|
var ourMessageIndex uint64
|
||||||
|
var theirMessageIndex uint64
|
||||||
|
|
||||||
delta := &channeldb.ChannelDelta{
|
if ourCommit {
|
||||||
LocalBalance: c.ourBalance,
|
ourMessageIndex = c.ourMessageIndex
|
||||||
RemoteBalance: c.theirBalance,
|
theirMessageIndex = c.theirMessageIndex
|
||||||
UpdateNum: c.height,
|
} else {
|
||||||
CommitFee: c.fee,
|
ourMessageIndex = c.theirMessageIndex
|
||||||
FeePerKw: c.feePerKw,
|
theirMessageIndex = c.ourMessageIndex
|
||||||
Htlcs: make([]*channeldb.HTLC, 0, numHtlcs),
|
}
|
||||||
|
|
||||||
|
return &channeldb.ChannelDelta{
|
||||||
|
OurMessageIndex: ourMessageIndex,
|
||||||
|
TheirMessageIndex: theirMessageIndex,
|
||||||
|
LocalBalance: c.ourBalance,
|
||||||
|
RemoteBalance: c.theirBalance,
|
||||||
|
UpdateNum: c.height,
|
||||||
|
CommitFee: c.fee,
|
||||||
|
FeePerKw: c.feePerKw,
|
||||||
|
Htlcs: c.htlcs(ourCommit),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// htlcs...
|
||||||
|
func (c *commitment) htlcs(ourCommit bool) []*channeldb.HTLC {
|
||||||
|
numHtlcs := len(c.outgoingHTLCs) + len(c.incomingHTLCs)
|
||||||
|
htlcs := make([]*channeldb.HTLC, 0, numHtlcs)
|
||||||
|
|
||||||
|
pdToHtlc := func(incoming bool, htlc PaymentDescriptor) *channeldb.HTLC {
|
||||||
|
outputIndex := htlc.localOutputIndex
|
||||||
|
if !ourCommit {
|
||||||
|
outputIndex = htlc.remoteOutputIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
h := &channeldb.HTLC{
|
||||||
|
Incoming: incoming,
|
||||||
|
Amt: htlc.Amount,
|
||||||
|
RHash: htlc.RHash,
|
||||||
|
RefundTimeout: htlc.Timeout,
|
||||||
|
OutputIndex: outputIndex,
|
||||||
|
OnionBlob: htlc.OnionBlob,
|
||||||
|
AddLocalInclusionHeight: htlc.addCommitHeightLocal,
|
||||||
|
AddRemoteInclusionHeight: htlc.addCommitHeightRemote,
|
||||||
|
DescriptorIndex: htlc.Index,
|
||||||
|
}
|
||||||
|
|
||||||
|
//if incoming {
|
||||||
|
// fmt.Println("save, receiver:",
|
||||||
|
// "remote:", h.AddRemoteInclusionHeight,
|
||||||
|
// "local:", h.AddLocalInclusionHeight,
|
||||||
|
// "index:", h.DescriptorIndex)
|
||||||
|
//} else {
|
||||||
|
// fmt.Println("save, sender:",
|
||||||
|
// "remote:", h.AddRemoteInclusionHeight,
|
||||||
|
// "local:", h.AddLocalInclusionHeight,
|
||||||
|
// "index:", h.DescriptorIndex)
|
||||||
|
//}
|
||||||
|
|
||||||
|
if ourCommit && htlc.sig != nil {
|
||||||
|
h.Signature = htlc.sig.Serialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, htlc := range c.outgoingHTLCs {
|
for _, htlc := range c.outgoingHTLCs {
|
||||||
outputIndex := htlc.localOutputIndex
|
htlcs = append(htlcs, pdToHtlc(false, htlc))
|
||||||
if !ourCommit {
|
|
||||||
outputIndex = htlc.remoteOutputIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
h := &channeldb.HTLC{
|
|
||||||
Incoming: false,
|
|
||||||
Amt: htlc.Amount,
|
|
||||||
RHash: htlc.RHash,
|
|
||||||
RefundTimeout: htlc.Timeout,
|
|
||||||
OutputIndex: outputIndex,
|
|
||||||
}
|
|
||||||
|
|
||||||
if ourCommit && htlc.sig != nil {
|
|
||||||
h.Signature = htlc.sig.Serialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
delta.Htlcs = append(delta.Htlcs, h)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, htlc := range c.incomingHTLCs {
|
for _, htlc := range c.incomingHTLCs {
|
||||||
outputIndex := htlc.localOutputIndex
|
htlcs = append(htlcs, pdToHtlc(true, htlc))
|
||||||
if !ourCommit {
|
|
||||||
outputIndex = htlc.remoteOutputIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
h := &channeldb.HTLC{
|
|
||||||
Incoming: true,
|
|
||||||
Amt: htlc.Amount,
|
|
||||||
RHash: htlc.RHash,
|
|
||||||
RefundTimeout: htlc.Timeout,
|
|
||||||
OutputIndex: outputIndex,
|
|
||||||
OnionBlob: htlc.OnionBlob,
|
|
||||||
}
|
|
||||||
|
|
||||||
if ourCommit && htlc.sig != nil {
|
|
||||||
h.Signature = htlc.sig.Serialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
delta.Htlcs = append(delta.Htlcs, h)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return delta, nil
|
return htlcs
|
||||||
}
|
}
|
||||||
|
|
||||||
// commitmentChain represents a chain of unrevoked commitments. The tail of the
|
// commitmentChain represents a chain of unrevoked commitments. The tail of the
|
||||||
@ -671,18 +690,20 @@ type updateLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newUpdateLog creates a new updateLog instance.
|
// newUpdateLog creates a new updateLog instance.
|
||||||
func newUpdateLog() *updateLog {
|
func newUpdateLog(logIndex, ackedIndex uint64) *updateLog {
|
||||||
return &updateLog{
|
return &updateLog{
|
||||||
List: list.New(),
|
List: list.New(),
|
||||||
updateIndex: make(map[uint64]*list.Element),
|
updateIndex: make(map[uint64]*list.Element),
|
||||||
htlcIndex: make(map[uint64]*list.Element),
|
htlcIndex: make(map[uint64]*list.Element),
|
||||||
|
logIndex: logIndex,
|
||||||
|
ackedIndex: ackedIndex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// appendUpdate appends a new update to the tip of the updateLog. The entry is
|
// appendUpdate appends a new update to the tip of the updateLog. The entry is
|
||||||
// also added to index accordingly.
|
// also added to index accordingly.
|
||||||
func (u *updateLog) appendUpdate(pd *PaymentDescriptor) {
|
func (u *updateLog) appendUpdate(pd *PaymentDescriptor) {
|
||||||
u.updateIndex[u.logIndex] = u.PushBack(pd)
|
u.updateIndex[pd.Index] = u.PushBack(pd)
|
||||||
u.logIndex++
|
u.logIndex++
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -964,8 +985,8 @@ func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
|
|||||||
channelState: state,
|
channelState: state,
|
||||||
localChanCfg: &state.LocalChanCfg,
|
localChanCfg: &state.LocalChanCfg,
|
||||||
remoteChanCfg: &state.RemoteChanCfg,
|
remoteChanCfg: &state.RemoteChanCfg,
|
||||||
localUpdateLog: newUpdateLog(),
|
localUpdateLog: newUpdateLog(state.OurMessageIndex, state.OurMessageIndex),
|
||||||
remoteUpdateLog: newUpdateLog(),
|
remoteUpdateLog: newUpdateLog(state.TheirMessageIndex, state.TheirMessageIndex),
|
||||||
rHashMap: make(map[PaymentHash][]*PaymentDescriptor),
|
rHashMap: make(map[PaymentHash][]*PaymentDescriptor),
|
||||||
Capacity: state.Capacity,
|
Capacity: state.Capacity,
|
||||||
FundingWitnessScript: multiSigScript,
|
FundingWitnessScript: multiSigScript,
|
||||||
@ -983,12 +1004,16 @@ func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
|
|||||||
lc.localCommitChain.addCommitment(&commitment{
|
lc.localCommitChain.addCommitment(&commitment{
|
||||||
height: lc.currentHeight,
|
height: lc.currentHeight,
|
||||||
ourBalance: state.LocalBalance,
|
ourBalance: state.LocalBalance,
|
||||||
ourMessageIndex: 0,
|
ourMessageIndex: state.OurMessageIndex,
|
||||||
theirBalance: state.RemoteBalance,
|
theirBalance: state.RemoteBalance,
|
||||||
theirMessageIndex: 0,
|
theirMessageIndex: state.TheirMessageIndex,
|
||||||
fee: state.CommitFee,
|
fee: state.CommitFee,
|
||||||
feePerKw: state.FeePerKw,
|
feePerKw: state.FeePerKw,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fmt.Println("local commit restored:", "our:", state.OurMessageIndex,
|
||||||
|
"their:", state.TheirMessageIndex)
|
||||||
|
|
||||||
walletLog.Debugf("ChannelPoint(%v), starting local commitment: %v",
|
walletLog.Debugf("ChannelPoint(%v), starting local commitment: %v",
|
||||||
state.FundingOutpoint, newLogClosure(func() string {
|
state.FundingOutpoint, newLogClosure(func() string {
|
||||||
return spew.Sdump(lc.localCommitChain.tail())
|
return spew.Sdump(lc.localCommitChain.tail())
|
||||||
@ -1003,37 +1028,42 @@ func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
|
|||||||
err != channeldb.ErrNoPastDeltas {
|
err != channeldb.ErrNoPastDeltas {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteCommitment := &commitment{}
|
remoteCommitment := &commitment{}
|
||||||
if logTail == nil {
|
if logTail == nil {
|
||||||
remoteCommitment.ourBalance = state.LocalBalance
|
remoteCommitment.ourBalance = state.LocalBalance
|
||||||
remoteCommitment.ourMessageIndex = 0
|
remoteCommitment.ourMessageIndex = state.OurMessageIndex
|
||||||
remoteCommitment.theirBalance = state.RemoteBalance
|
remoteCommitment.theirBalance = state.RemoteBalance
|
||||||
remoteCommitment.theirMessageIndex = 0
|
remoteCommitment.theirMessageIndex = state.TheirMessageIndex
|
||||||
remoteCommitment.fee = state.CommitFee
|
remoteCommitment.fee = state.CommitFee
|
||||||
remoteCommitment.feePerKw = state.FeePerKw
|
remoteCommitment.feePerKw = state.FeePerKw
|
||||||
remoteCommitment.height = 0
|
remoteCommitment.height = 0
|
||||||
} else {
|
} else {
|
||||||
remoteCommitment.ourBalance = logTail.LocalBalance
|
remoteCommitment.ourBalance = state.LocalBalance
|
||||||
remoteCommitment.ourMessageIndex = 0
|
remoteCommitment.ourMessageIndex = logTail.OurMessageIndex
|
||||||
remoteCommitment.theirBalance = logTail.RemoteBalance
|
remoteCommitment.theirBalance = state.RemoteBalance
|
||||||
remoteCommitment.theirMessageIndex = 0
|
remoteCommitment.theirMessageIndex = logTail.TheirMessageIndex
|
||||||
remoteCommitment.fee = logTail.CommitFee
|
remoteCommitment.fee = state.CommitFee
|
||||||
remoteCommitment.feePerKw = logTail.FeePerKw
|
remoteCommitment.feePerKw = state.FeePerKw
|
||||||
remoteCommitment.height = logTail.UpdateNum + 1
|
remoteCommitment.height = logTail.UpdateNum + 1
|
||||||
}
|
}
|
||||||
lc.remoteCommitChain.addCommitment(remoteCommitment)
|
lc.remoteCommitChain.addCommitment(remoteCommitment)
|
||||||
|
|
||||||
commitDiff, err := channeldb.FetchCommitDiff(lc.channelState.Db)
|
commitDiff, err := channeldb.FetchCommitDiff(lc.channelState.Db,
|
||||||
|
&lc.channelState.FundingOutpoint)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
lc.remoteCommitChain.addCommitment(&commitment{
|
lc.remoteCommitChain.addCommitment(&commitment{
|
||||||
height: commitDiff.PendingHeight,
|
height: commitDiff.PendingHeight,
|
||||||
ourBalance: commitDiff.PendingCommitment.LocalBalance,
|
ourBalance: commitDiff.PendingCommitment.LocalBalance,
|
||||||
theirBalance: commitDiff.PendingCommitment.RemoteBalance,
|
theirBalance: commitDiff.PendingCommitment.RemoteBalance,
|
||||||
ourMessageIndex: 0,
|
ourMessageIndex: commitDiff.PendingCommitment.OurMessageIndex,
|
||||||
theirMessageIndex: 0,
|
theirMessageIndex: commitDiff.PendingCommitment.TheirMessageIndex,
|
||||||
fee: commitDiff.PendingCommitment.CommitFee,
|
fee: commitDiff.PendingCommitment.CommitFee,
|
||||||
feePerKw: commitDiff.PendingCommitment.FeePerKw,
|
feePerKw: commitDiff.PendingCommitment.FeePerKw,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fmt.Println("commit diff:", commitDiff.PendingCommitment.OurMessageIndex,
|
||||||
|
commitDiff.PendingCommitment.TheirMessageIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
walletLog.Debugf("ChannelPoint(%v), starting remote commitment: %v",
|
walletLog.Debugf("ChannelPoint(%v), starting remote commitment: %v",
|
||||||
@ -1650,11 +1680,6 @@ func htlcIsDust(incoming, ourCommit bool,
|
|||||||
// remote) for each HTLC read from disk. This method is required to sync the
|
// remote) for each HTLC read from disk. This method is required to sync the
|
||||||
// in-memory state of the state machine with that read from persistent storage.
|
// in-memory state of the state machine with that read from persistent storage.
|
||||||
func (lc *LightningChannel) restoreStateLogs() error {
|
func (lc *LightningChannel) restoreStateLogs() error {
|
||||||
var pastHeight uint64
|
|
||||||
if lc.currentHeight > 0 {
|
|
||||||
pastHeight = lc.currentHeight - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtain the local and remote channel configurations. These house all
|
// Obtain the local and remote channel configurations. These house all
|
||||||
// the relevant public keys and points we'll need in order to restore
|
// the relevant public keys and points we'll need in order to restore
|
||||||
// the state log.
|
// the state log.
|
||||||
@ -1681,8 +1706,6 @@ func (lc *LightningChannel) restoreStateLogs() error {
|
|||||||
remoteCommitKeys := deriveCommitmentKeys(remoteCommitPoint, false,
|
remoteCommitKeys := deriveCommitmentKeys(remoteCommitPoint, false,
|
||||||
localChanCfg, remoteChanCfg)
|
localChanCfg, remoteChanCfg)
|
||||||
|
|
||||||
var ourCounter, theirCounter uint64
|
|
||||||
|
|
||||||
// Grab the current fee rate as we'll need this to determine if the
|
// Grab the current fee rate as we'll need this to determine if the
|
||||||
// prior HTLC's were considered dust or not at this particular
|
// prior HTLC's were considered dust or not at this particular
|
||||||
// commitment state.
|
// commitment state.
|
||||||
@ -1728,12 +1751,14 @@ func (lc *LightningChannel) restoreStateLogs() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pd := &PaymentDescriptor{
|
pd := &PaymentDescriptor{
|
||||||
RHash: htlc.RHash,
|
RHash: htlc.RHash,
|
||||||
Timeout: htlc.RefundTimeout,
|
Timeout: htlc.RefundTimeout,
|
||||||
Amount: htlc.Amt,
|
Amount: htlc.Amt,
|
||||||
EntryType: Add,
|
EntryType: Add,
|
||||||
addCommitHeightRemote: pastHeight,
|
Index: htlc.DescriptorIndex,
|
||||||
addCommitHeightLocal: pastHeight,
|
addCommitHeightRemote: htlc.AddRemoteInclusionHeight,
|
||||||
|
addCommitHeightLocal: htlc.AddLocalInclusionHeight,
|
||||||
|
OnionBlob: htlc.OnionBlob,
|
||||||
ourPkScript: ourP2WSH,
|
ourPkScript: ourP2WSH,
|
||||||
ourWitnessScript: ourWitnessScript,
|
ourWitnessScript: ourWitnessScript,
|
||||||
theirPkScript: theirP2WSH,
|
theirPkScript: theirP2WSH,
|
||||||
@ -1743,22 +1768,14 @@ func (lc *LightningChannel) restoreStateLogs() error {
|
|||||||
if !htlc.Incoming {
|
if !htlc.Incoming {
|
||||||
pd.HtlcIndex = ourCounter
|
pd.HtlcIndex = ourCounter
|
||||||
lc.localUpdateLog.appendHtlc(pd)
|
lc.localUpdateLog.appendHtlc(pd)
|
||||||
|
|
||||||
ourCounter++
|
|
||||||
} else {
|
} else {
|
||||||
pd.HtlcIndex = theirCounter
|
pd.HtlcIndex = theirCounter
|
||||||
lc.remoteUpdateLog.appendHtlc(pd)
|
lc.remoteUpdateLog.appendHtlc(pd)
|
||||||
lc.rHashMap[pd.RHash] = append(lc.rHashMap[pd.RHash], pd)
|
|
||||||
|
|
||||||
theirCounter++
|
lc.rHashMap[pd.RHash] = append(lc.rHashMap[pd.RHash], pd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lc.localCommitChain.tail().ourMessageIndex = ourCounter
|
|
||||||
lc.localCommitChain.tail().theirMessageIndex = theirCounter
|
|
||||||
lc.remoteCommitChain.tail().ourMessageIndex = ourCounter
|
|
||||||
lc.remoteCommitChain.tail().theirMessageIndex = theirCounter
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2521,8 +2538,13 @@ func (lc *LightningChannel) SignNextCommitment() (*btcec.Signature, []*btcec.Sig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
if err := channeldb.AddCommitDiff(lc.channelState.Db, commitDiff); err != nil {
|
if err := channeldb.AddCommitDiff(lc.channelState.Db,
|
||||||
fmt.Println(err)
|
&lc.channelState.FundingOutpoint,
|
||||||
|
commitDiff); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := lc.channelState.UpdateHTLCs(newCommitView.htlcs(false)); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2582,6 +2604,9 @@ func (lc *LightningChannel) ReceiveReestablish(msg *lnwire.ChannelReestablish) (
|
|||||||
// last commit sig message.
|
// last commit sig message.
|
||||||
commitment := lc.remoteCommitChain.tip()
|
commitment := lc.remoteCommitChain.tip()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&lc.channelState.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(&lc.channelState.FundingOutpoint)
|
||||||
|
|
||||||
|
// TODO: Read from update log, which will contains settle/fail
|
||||||
|
// updates also.
|
||||||
for _, htlc := range commitment.outgoingHTLCs {
|
for _, htlc := range commitment.outgoingHTLCs {
|
||||||
// If htlc is included in the local commitment chain (have been
|
// If htlc is included in the local commitment chain (have been
|
||||||
// included by remote side) or htlc is included in remote chain, but
|
// included by remote side) or htlc is included in remote chain, but
|
||||||
@ -3014,6 +3039,11 @@ func (lc *LightningChannel) FullySynced() bool {
|
|||||||
remoteUpdatesSynced :=
|
remoteUpdatesSynced :=
|
||||||
lastLocalCommit.theirMessageIndex == lastRemoteCommit.theirMessageIndex
|
lastLocalCommit.theirMessageIndex == lastRemoteCommit.theirMessageIndex
|
||||||
|
|
||||||
|
fmt.Println("remote, our:", lc.remoteCommitChain.tip().ourMessageIndex,
|
||||||
|
"local, our:", lc.localCommitChain.tip().ourMessageIndex)
|
||||||
|
fmt.Println("remote, their:", lc.remoteCommitChain.tip().theirMessageIndex,
|
||||||
|
"local, their:", lc.localCommitChain.tip().theirMessageIndex)
|
||||||
|
fmt.Println(!oweCommitment, localUpdatesSynced, remoteUpdatesSynced)
|
||||||
return !oweCommitment && localUpdatesSynced && remoteUpdatesSynced
|
return !oweCommitment && localUpdatesSynced && remoteUpdatesSynced
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3140,6 +3170,9 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) ([]*P
|
|||||||
// * either record add height, or set to N - 1
|
// * either record add height, or set to N - 1
|
||||||
uncomitted := (htlc.addCommitHeightRemote == 0 ||
|
uncomitted := (htlc.addCommitHeightRemote == 0 ||
|
||||||
htlc.addCommitHeightLocal == 0)
|
htlc.addCommitHeightLocal == 0)
|
||||||
|
fmt.Println(remoteChainTail, localChainTail,
|
||||||
|
htlc.addCommitHeightRemote,
|
||||||
|
htlc.addCommitHeightLocal)
|
||||||
if htlc.EntryType == Add && uncomitted {
|
if htlc.EntryType == Add && uncomitted {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user