funding+peer: switch to using new channel ID's

This commit modifies the way the fundingManager tracks pending funding
workflows internally. Rather than using the old auto-incrementing
64-bit pending channel ID’s, we now use a 32-byte pending channel ID
which is generated using a CSPRG. Additionally, once the final funding
message has been sent, we now de-multiplex the FundingLocked message
according to the new Channel ID’s which replace the old ChannelPoint’s
and are exactly 32-bytes long.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-04-16 15:34:29 -07:00
1 parent b3424149ef
commit 609cba95d7
2 files changed
+151 -144

No files matched your search

-29
View File
@@ -137,15 +137,6 @@ type peer struct {
// over.
remoteCloseChanReqs chan *lnwire.CloseRequest
// nextPendingChannelID is an integer which represents the id of the
// next pending channel. Pending channels are tracked by this id
// throughout their lifetime until they become active channels, or are
// cancelled. Channels id's initiated by an outbound node start from 0,
// while channels initiated by an inbound node start from 2^63. In
// either case, this value is always monotonically increasing.
nextPendingChannelID uint64
pendingChannelMtx sync.RWMutex
server *server
// localSharedFeatures is a product of comparison of our and their
@@ -200,15 +191,6 @@ func newPeer(conn net.Conn, connReq *connmgr.ConnReq, server *server,
quit: make(chan struct{}),
}
// Initiate the pending channel identifier properly depending on if this
// node is inbound or outbound. This value will be used in an increasing
// manner to track pending channels.
if p.inbound {
p.nextPendingChannelID = 1 << 63
} else {
p.nextPendingChannelID = 0
}
// Fetch and then load all the active channels we have with this
// remote peer from the database.
activeChans, err := server.chanDB.FetchOpenChannels(p.addr.IdentityKey)
@@ -1721,17 +1703,6 @@ func (p *peer) updateCommitTx(state *commitmentState) error {
return nil
}
// fetchNextPendingChanID provides unique IDs for each channel opened between
// two peers
func (p *peer) fetchNextPendingChanID() uint64 {
p.pendingChannelMtx.Lock()
defer p.pendingChannelMtx.Unlock()
chanID := p.nextPendingChannelID
p.nextPendingChannelID++
return chanID
}
// logEntryToHtlcPkt converts a particular Lightning Commitment Protocol (LCP)
// log entry the corresponding htlcPacket with src/dest set along with the
// proper wire message. This helper method is provided in order to aid an