mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-12 10:30:40 +01:00
multi: make NewChanIDFromOutpoint accept value instead of pointer
This commit is contained in:
parent
fd1cd315ce
commit
db39a905cb
27 changed files with 108 additions and 106 deletions
|
@ -1169,7 +1169,7 @@ func (c *OpenChannel) fullSync(tx kvdb.RwTx) error {
|
||||||
return ErrChanAlreadyExists
|
return ErrChanAlreadyExists
|
||||||
}
|
}
|
||||||
|
|
||||||
cid := lnwire.NewChanIDFromOutPoint(&c.FundingOutpoint)
|
cid := lnwire.NewChanIDFromOutPoint(c.FundingOutpoint)
|
||||||
if cidBucket.Get(cid[:]) != nil {
|
if cidBucket.Get(cid[:]) != nil {
|
||||||
return ErrChanAlreadyExists
|
return ErrChanAlreadyExists
|
||||||
}
|
}
|
||||||
|
@ -1574,7 +1574,7 @@ func (c *OpenChannel) ChanSyncMsg() (*lnwire.ChannelReestablish, error) {
|
||||||
|
|
||||||
return &lnwire.ChannelReestablish{
|
return &lnwire.ChannelReestablish{
|
||||||
ChanID: lnwire.NewChanIDFromOutPoint(
|
ChanID: lnwire.NewChanIDFromOutPoint(
|
||||||
&c.FundingOutpoint,
|
c.FundingOutpoint,
|
||||||
),
|
),
|
||||||
NextLocalCommitHeight: nextLocalCommitHeight,
|
NextLocalCommitHeight: nextLocalCommitHeight,
|
||||||
RemoteCommitTailHeight: remoteChainTipHeight,
|
RemoteCommitTailHeight: remoteChainTipHeight,
|
||||||
|
|
|
@ -704,7 +704,7 @@ func (c *ChannelStateDB) FetchChannelByID(tx kvdb.RTx, id lnwire.ChannelID) (
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&outPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(outPoint)
|
||||||
if chanID != id {
|
if chanID != id {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ func TestFetchClosedChannelForID(t *testing.T) {
|
||||||
state.FundingOutpoint.Index = i
|
state.FundingOutpoint.Index = i
|
||||||
|
|
||||||
// We calculate the ChannelID and use it to fetch the summary.
|
// We calculate the ChannelID and use it to fetch the summary.
|
||||||
cid := lnwire.NewChanIDFromOutPoint(&state.FundingOutpoint)
|
cid := lnwire.NewChanIDFromOutPoint(state.FundingOutpoint)
|
||||||
fetchedSummary, err := cdb.FetchClosedChannelForID(cid)
|
fetchedSummary, err := cdb.FetchClosedChannelForID(cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to fetch close summary: %v", err)
|
t.Fatalf("unable to fetch close summary: %v", err)
|
||||||
|
@ -158,7 +158,7 @@ func TestFetchClosedChannelForID(t *testing.T) {
|
||||||
// As a final test we make sure that we get ErrClosedChannelNotFound
|
// As a final test we make sure that we get ErrClosedChannelNotFound
|
||||||
// for a ChannelID we didn't add to the DB.
|
// for a ChannelID we didn't add to the DB.
|
||||||
state.FundingOutpoint.Index++
|
state.FundingOutpoint.Index++
|
||||||
cid := lnwire.NewChanIDFromOutPoint(&state.FundingOutpoint)
|
cid := lnwire.NewChanIDFromOutPoint(state.FundingOutpoint)
|
||||||
_, err = cdb.FetchClosedChannelForID(cid)
|
_, err = cdb.FetchClosedChannelForID(cid)
|
||||||
if err != ErrClosedChannelNotFound {
|
if err != ErrClosedChannelNotFound {
|
||||||
t.Fatalf("expected ErrClosedChannelNotFound, instead got: %v", err)
|
t.Fatalf("expected ErrClosedChannelNotFound, instead got: %v", err)
|
||||||
|
@ -240,7 +240,7 @@ func TestFetchChannel(t *testing.T) {
|
||||||
require.Equal(t, channelState, dbChannel)
|
require.Equal(t, channelState, dbChannel)
|
||||||
|
|
||||||
// Next, attempt to fetch the channel by its channel ID.
|
// Next, attempt to fetch the channel by its channel ID.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channelState.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channelState.FundingOutpoint)
|
||||||
dbChannel, err = cdb.FetchChannelByID(nil, chanID)
|
dbChannel, err = cdb.FetchChannelByID(nil, chanID)
|
||||||
require.NoError(t, err, "unable to fetch channel")
|
require.NoError(t, err, "unable to fetch channel")
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ func TestFetchChannel(t *testing.T) {
|
||||||
_, err = cdb.FetchChannel(nil, channelState2.FundingOutpoint)
|
_, err = cdb.FetchChannel(nil, channelState2.FundingOutpoint)
|
||||||
require.ErrorIs(t, err, ErrChannelNotFound)
|
require.ErrorIs(t, err, ErrChannelNotFound)
|
||||||
|
|
||||||
chanID2 := lnwire.NewChanIDFromOutPoint(&channelState2.FundingOutpoint)
|
chanID2 := lnwire.NewChanIDFromOutPoint(channelState2.FundingOutpoint)
|
||||||
_, err = cdb.FetchChannelByID(nil, chanID2)
|
_, err = cdb.FetchChannelByID(nil, chanID2)
|
||||||
require.ErrorIs(t, err, ErrChannelNotFound)
|
require.ErrorIs(t, err, ErrChannelNotFound)
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ func checkPkgFilterEncodeDecode(t *testing.T, i uint16, f *channeldb.PkgFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
chanID = lnwire.NewChanIDFromOutPoint(&wire.OutPoint{})
|
chanID = lnwire.NewChanIDFromOutPoint(wire.OutPoint{})
|
||||||
|
|
||||||
adds = []channeldb.LogUpdate{
|
adds = []channeldb.LogUpdate{
|
||||||
{
|
{
|
||||||
|
|
|
@ -1748,8 +1748,9 @@ func (d *AuthenticatedGossiper) processChanPolicyUpdate(
|
||||||
// update with the peer's alias. We do this after
|
// update with the peer's alias. We do this after
|
||||||
// updateChannel so that the alias isn't persisted to
|
// updateChannel so that the alias isn't persisted to
|
||||||
// the database.
|
// the database.
|
||||||
op := &edgeInfo.Info.ChannelPoint
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(op)
|
edgeInfo.Info.ChannelPoint,
|
||||||
|
)
|
||||||
|
|
||||||
var defaultAlias lnwire.ShortChannelID
|
var defaultAlias lnwire.ShortChannelID
|
||||||
foundAlias, _ := d.cfg.GetAlias(chanID)
|
foundAlias, _ := d.cfg.GetAlias(chanID)
|
||||||
|
|
|
@ -698,7 +698,7 @@ func (f *Manager) start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, channel := range allChannels {
|
for _, channel := range allChannels {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
|
|
||||||
// For any channels that were in a pending state when the
|
// For any channels that were in a pending state when the
|
||||||
// daemon was last connected, the Funding Manager will
|
// daemon was last connected, the Funding Manager will
|
||||||
|
@ -1113,7 +1113,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,
|
||||||
channelState channelOpeningState,
|
channelState channelOpeningState,
|
||||||
updateChan chan<- *lnrpc.OpenStatusUpdate) error {
|
updateChan chan<- *lnrpc.OpenStatusUpdate) error {
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
log.Debugf("Channel(%v) with ShortChanID %v has opening state %v",
|
log.Debugf("Channel(%v) with ShortChanID %v has opening state %v",
|
||||||
chanID, shortChanID, channelState)
|
chanID, shortChanID, channelState)
|
||||||
|
|
||||||
|
@ -1273,7 +1273,7 @@ func (f *Manager) advancePendingChannelState(
|
||||||
|
|
||||||
// Find and close the discoverySignal for this channel such
|
// Find and close the discoverySignal for this channel such
|
||||||
// that ChannelReady messages will be processed.
|
// that ChannelReady messages will be processed.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
discoverySignal, ok := f.localDiscoverySignals.Load(chanID)
|
discoverySignal, ok := f.localDiscoverySignals.Load(chanID)
|
||||||
if ok {
|
if ok {
|
||||||
close(discoverySignal)
|
close(discoverySignal)
|
||||||
|
@ -1339,7 +1339,7 @@ func (f *Manager) advancePendingChannelState(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success, funding transaction was confirmed.
|
// Success, funding transaction was confirmed.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
log.Debugf("ChannelID(%v) is now fully confirmed! "+
|
log.Debugf("ChannelID(%v) is now fully confirmed! "+
|
||||||
"(shortChanID=%v)", chanID, confChannel.shortChanID)
|
"(shortChanID=%v)", chanID, confChannel.shortChanID)
|
||||||
|
|
||||||
|
@ -2246,7 +2246,7 @@ func (f *Manager) continueFundingAccept(resCtx *reservationWithCtx,
|
||||||
// properly synchronize with the writeHandler goroutine, we add a new
|
// properly synchronize with the writeHandler goroutine, we add a new
|
||||||
// channel to the barriers map which will be closed once the channel is
|
// channel to the barriers map which will be closed once the channel is
|
||||||
// fully open.
|
// fully open.
|
||||||
channelID := lnwire.NewChanIDFromOutPoint(outPoint)
|
channelID := lnwire.NewChanIDFromOutPoint(*outPoint)
|
||||||
log.Debugf("Creating chan barrier for ChanID(%v)", channelID)
|
log.Debugf("Creating chan barrier for ChanID(%v)", channelID)
|
||||||
|
|
||||||
// The next message that advances the funding flow will reference the
|
// The next message that advances the funding flow will reference the
|
||||||
|
@ -2421,7 +2421,7 @@ func (f *Manager) fundeeProcessFundingCreated(peer lnpeer.Peer,
|
||||||
// properly synchronize with the writeHandler goroutine, we add a new
|
// properly synchronize with the writeHandler goroutine, we add a new
|
||||||
// channel to the barriers map which will be closed once the channel is
|
// channel to the barriers map which will be closed once the channel is
|
||||||
// fully open.
|
// fully open.
|
||||||
channelID := lnwire.NewChanIDFromOutPoint(&fundingOut)
|
channelID := lnwire.NewChanIDFromOutPoint(fundingOut)
|
||||||
log.Debugf("Creating chan barrier for ChanID(%v)", channelID)
|
log.Debugf("Creating chan barrier for ChanID(%v)", channelID)
|
||||||
|
|
||||||
fundingSigned := &lnwire.FundingSigned{}
|
fundingSigned := &lnwire.FundingSigned{}
|
||||||
|
@ -2582,7 +2582,7 @@ func (f *Manager) funderProcessFundingSigned(peer lnpeer.Peer,
|
||||||
// process the channel confirmation fully before we receive a
|
// process the channel confirmation fully before we receive a
|
||||||
// channel_ready message.
|
// channel_ready message.
|
||||||
fundingPoint := resCtx.reservation.FundingOutpoint()
|
fundingPoint := resCtx.reservation.FundingOutpoint()
|
||||||
permChanID := lnwire.NewChanIDFromOutPoint(fundingPoint)
|
permChanID := lnwire.NewChanIDFromOutPoint(*fundingPoint)
|
||||||
f.localDiscoverySignals.Store(permChanID, make(chan struct{}))
|
f.localDiscoverySignals.Store(permChanID, make(chan struct{}))
|
||||||
|
|
||||||
// We have to store the forwardingPolicy before the reservation context
|
// We have to store the forwardingPolicy before the reservation context
|
||||||
|
@ -2788,7 +2788,7 @@ func (f *Manager) fundingTimeout(c *channeldb.OpenChannel,
|
||||||
|
|
||||||
// Create channel identifier and set the channel ID.
|
// Create channel identifier and set the channel ID.
|
||||||
cid := newChanIdentifier(pendingID)
|
cid := newChanIdentifier(pendingID)
|
||||||
cid.setChanID(lnwire.NewChanIDFromOutPoint(&c.FundingOutpoint))
|
cid.setChanID(lnwire.NewChanIDFromOutPoint(c.FundingOutpoint))
|
||||||
|
|
||||||
// TODO(halseth): should this send be made
|
// TODO(halseth): should this send be made
|
||||||
// reliable?
|
// reliable?
|
||||||
|
@ -2953,7 +2953,7 @@ func (f *Manager) waitForFundingConfirmation(
|
||||||
|
|
||||||
fundingPoint := completeChan.FundingOutpoint
|
fundingPoint := completeChan.FundingOutpoint
|
||||||
log.Infof("ChannelPoint(%v) is now active: ChannelID(%v)",
|
log.Infof("ChannelPoint(%v) is now active: ChannelID(%v)",
|
||||||
fundingPoint, lnwire.NewChanIDFromOutPoint(&fundingPoint))
|
fundingPoint, lnwire.NewChanIDFromOutPoint(fundingPoint))
|
||||||
|
|
||||||
// With the block height and the transaction index known, we can
|
// With the block height and the transaction index known, we can
|
||||||
// construct the compact chanID which is used on the network to unique
|
// construct the compact chanID which is used on the network to unique
|
||||||
|
@ -3071,7 +3071,7 @@ func (f *Manager) handleFundingConfirmation(
|
||||||
confChannel *confirmedChannel) error {
|
confChannel *confirmedChannel) error {
|
||||||
|
|
||||||
fundingPoint := completeChan.FundingOutpoint
|
fundingPoint := completeChan.FundingOutpoint
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingPoint)
|
||||||
|
|
||||||
// TODO(roasbeef): ideally persistent state update for chan above
|
// TODO(roasbeef): ideally persistent state update for chan above
|
||||||
// should be abstracted
|
// should be abstracted
|
||||||
|
@ -3147,7 +3147,7 @@ func (f *Manager) handleFundingConfirmation(
|
||||||
func (f *Manager) sendChannelReady(completeChan *channeldb.OpenChannel,
|
func (f *Manager) sendChannelReady(completeChan *channeldb.OpenChannel,
|
||||||
channel *lnwallet.LightningChannel) error {
|
channel *lnwallet.LightningChannel) error {
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&completeChan.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(completeChan.FundingOutpoint)
|
||||||
|
|
||||||
var peerKey [33]byte
|
var peerKey [33]byte
|
||||||
copy(peerKey[:], completeChan.IdentityPub.SerializeCompressed())
|
copy(peerKey[:], completeChan.IdentityPub.SerializeCompressed())
|
||||||
|
@ -3374,7 +3374,7 @@ func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel,
|
||||||
peerAlias *lnwire.ShortChannelID,
|
peerAlias *lnwire.ShortChannelID,
|
||||||
ourPolicy *models.ChannelEdgePolicy) error {
|
ourPolicy *models.ChannelEdgePolicy) error {
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&completeChan.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(completeChan.FundingOutpoint)
|
||||||
|
|
||||||
fwdMinHTLC, fwdMaxHTLC := f.extractAnnounceParams(completeChan)
|
fwdMinHTLC, fwdMaxHTLC := f.extractAnnounceParams(completeChan)
|
||||||
|
|
||||||
|
@ -3465,7 +3465,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
|
||||||
}
|
}
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&completeChan.FundingOutpoint,
|
completeChan.FundingOutpoint,
|
||||||
)
|
)
|
||||||
pubKey := peer.PubKey()
|
pubKey := peer.PubKey()
|
||||||
log.Debugf("Sending our NodeAnnouncement for "+
|
log.Debugf("Sending our NodeAnnouncement for "+
|
||||||
|
@ -3530,7 +3530,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
|
||||||
}
|
}
|
||||||
|
|
||||||
fundingPoint := completeChan.FundingOutpoint
|
fundingPoint := completeChan.FundingOutpoint
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingPoint)
|
||||||
|
|
||||||
log.Infof("Announcing ChannelPoint(%v), short_chan_id=%v",
|
log.Infof("Announcing ChannelPoint(%v), short_chan_id=%v",
|
||||||
&fundingPoint, shortChanID)
|
&fundingPoint, shortChanID)
|
||||||
|
@ -3964,7 +3964,7 @@ func (f *Manager) handleChannelReadyReceived(channel *channeldb.OpenChannel,
|
||||||
scid *lnwire.ShortChannelID, pendingChanID [32]byte,
|
scid *lnwire.ShortChannelID, pendingChanID [32]byte,
|
||||||
updateChan chan<- *lnrpc.OpenStatusUpdate) error {
|
updateChan chan<- *lnrpc.OpenStatusUpdate) error {
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
|
|
||||||
// Since we've sent+received funding locked at this point, we
|
// Since we've sent+received funding locked at this point, we
|
||||||
// can clean up the pending musig2 nonce state.
|
// can clean up the pending musig2 nonce state.
|
||||||
|
@ -3981,7 +3981,7 @@ func (f *Manager) handleChannelReadyReceived(channel *channeldb.OpenChannel,
|
||||||
// we'll just return, letting the next iteration of the loop
|
// we'll just return, letting the next iteration of the loop
|
||||||
// check again.
|
// check again.
|
||||||
var defaultAlias lnwire.ShortChannelID
|
var defaultAlias lnwire.ShortChannelID
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
foundAlias, _ := f.cfg.AliasManager.GetPeerAlias(chanID)
|
foundAlias, _ := f.cfg.AliasManager.GetPeerAlias(chanID)
|
||||||
if foundAlias == defaultAlias {
|
if foundAlias == defaultAlias {
|
||||||
return nil
|
return nil
|
||||||
|
@ -4876,7 +4876,7 @@ func (f *Manager) pruneZombieReservations() {
|
||||||
log.Warnf(err.Error())
|
log.Warnf(err.Error())
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
resCtx.reservation.FundingOutpoint(),
|
*resCtx.reservation.FundingOutpoint(),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create channel identifier and set the channel ID.
|
// Create channel identifier and set the channel ID.
|
||||||
|
|
|
@ -3365,7 +3365,7 @@ func TestFundingManagerCustomChannelParameters(t *testing.T) {
|
||||||
t, alice, bob, func(node *testNode, msg *newChannelMsg) bool {
|
t, alice, bob, func(node *testNode, msg *newChannelMsg) bool {
|
||||||
aliceDB := alice.fundingMgr.cfg.ChannelDB
|
aliceDB := alice.fundingMgr.cfg.ChannelDB
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&msg.channel.FundingOutpoint,
|
msg.channel.FundingOutpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
if node == alice {
|
if node == alice {
|
||||||
|
|
|
@ -2602,8 +2602,7 @@ func (l *channelLink) UpdateShortChanID() (lnwire.ShortChannelID, error) {
|
||||||
//
|
//
|
||||||
// NOTE: Part of the ChannelLink interface.
|
// NOTE: Part of the ChannelLink interface.
|
||||||
func (l *channelLink) ChanID() lnwire.ChannelID {
|
func (l *channelLink) ChanID() lnwire.ChannelID {
|
||||||
chanPoint := l.channel.ChannelPoint()
|
return lnwire.NewChanIDFromOutPoint(l.channel.ChannelPoint())
|
||||||
return lnwire.NewChanIDFromOutPoint(&chanPoint)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bandwidth returns the total amount that can flow through the channel link at
|
// Bandwidth returns the total amount that can flow through the channel link at
|
||||||
|
|
|
@ -1497,7 +1497,7 @@ func TestChannelLinkMultiHopUnknownNextHop(t *testing.T) {
|
||||||
// back the payment to Alice since he is unaware of Carol when the
|
// back the payment to Alice since he is unaware of Carol when the
|
||||||
// payment comes across.
|
// payment comes across.
|
||||||
bobChanID := lnwire.NewChanIDFromOutPoint(
|
bobChanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&channels.bobToCarol.State().FundingOutpoint,
|
channels.bobToCarol.ChannelPoint(),
|
||||||
)
|
)
|
||||||
n.bobServer.htlcSwitch.RemoveLink(bobChanID)
|
n.bobServer.htlcSwitch.RemoveLink(bobChanID)
|
||||||
|
|
||||||
|
@ -3763,7 +3763,7 @@ func TestChannelRetransmission(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
chanPoint := channels.aliceToBob.ChannelPoint()
|
chanPoint := channels.aliceToBob.ChannelPoint()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
serverErr := make(chan error, 4)
|
serverErr := make(chan error, 4)
|
||||||
|
|
||||||
aliceInterceptor := createInterceptorFunc("[alice] <-- [bob]",
|
aliceInterceptor := createInterceptorFunc("[alice] <-- [bob]",
|
||||||
|
|
|
@ -621,7 +621,7 @@ func (s *Switch) UpdateForwardingPolicies(
|
||||||
|
|
||||||
// Update each link in chanPolicies.
|
// Update each link in chanPolicies.
|
||||||
for targetLink, policy := range chanPolicies {
|
for targetLink, policy := range chanPolicies {
|
||||||
cid := lnwire.NewChanIDFromOutPoint(&targetLink)
|
cid := lnwire.NewChanIDFromOutPoint(targetLink)
|
||||||
|
|
||||||
link, ok := s.linkIndex[cid]
|
link, ok := s.linkIndex[cid]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -1797,7 +1797,7 @@ out:
|
||||||
// relevant link (if it exists) so the channel can be
|
// relevant link (if it exists) so the channel can be
|
||||||
// cooperatively closed (if possible).
|
// cooperatively closed (if possible).
|
||||||
case req := <-s.chanCloseRequests:
|
case req := <-s.chanCloseRequests:
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(req.ChanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(*req.ChanPoint)
|
||||||
|
|
||||||
s.indexMtx.RLock()
|
s.indexMtx.RLock()
|
||||||
link, ok := s.linkIndex[chanID]
|
link, ok := s.linkIndex[chanID]
|
||||||
|
|
|
@ -73,7 +73,7 @@ func genID() (lnwire.ChannelID, lnwire.ShortChannelID) {
|
||||||
hash1, _ := chainhash.NewHash(bytes.Repeat(scratch[:], 4))
|
hash1, _ := chainhash.NewHash(bytes.Repeat(scratch[:], 4))
|
||||||
|
|
||||||
chanPoint1 := wire.NewOutPoint(hash1, uint32(id))
|
chanPoint1 := wire.NewOutPoint(hash1, uint32(id))
|
||||||
chanID1 := lnwire.NewChanIDFromOutPoint(chanPoint1)
|
chanID1 := lnwire.NewChanIDFromOutPoint(*chanPoint1)
|
||||||
aliceChanID := lnwire.NewShortChanIDFromInt(id)
|
aliceChanID := lnwire.NewShortChanIDFromInt(id)
|
||||||
|
|
||||||
return chanID1, aliceChanID
|
return chanID1, aliceChanID
|
||||||
|
|
|
@ -731,7 +731,7 @@ func shouldIncludeChannel(cfg *SelectHopHintsCfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&channel.FundingOutpoint,
|
channel.FundingOutpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
hopHintInfo := newHopHintInfo(channel, cfg.IsChannelActive(chanID))
|
hopHintInfo := newHopHintInfo(channel, cfg.IsChannelActive(chanID))
|
||||||
|
|
|
@ -120,7 +120,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 0,
|
Index: 0,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
).Once().Return(true)
|
).Once().Return(true)
|
||||||
|
@ -137,7 +137,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 0,
|
Index: 0,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
).Once().Return(false)
|
).Once().Return(false)
|
||||||
|
@ -154,7 +154,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 0,
|
Index: 0,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
|
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
|
@ -178,7 +178,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 0,
|
Index: 0,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
|
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
|
@ -213,7 +213,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 0,
|
Index: 0,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
|
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
|
@ -251,7 +251,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 0,
|
Index: 0,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
|
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
|
@ -289,7 +289,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 1,
|
Index: 1,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
|
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
|
@ -340,7 +340,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 1,
|
Index: 1,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
|
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
|
@ -385,7 +385,7 @@ var shouldIncludeChannelTestCases = []struct {
|
||||||
fundingOutpoint := wire.OutPoint{
|
fundingOutpoint := wire.OutPoint{
|
||||||
Index: 1,
|
Index: 1,
|
||||||
}
|
}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
|
|
||||||
h.Mock.On(
|
h.Mock.On(
|
||||||
"IsChannelActive", chanID,
|
"IsChannelActive", chanID,
|
||||||
|
@ -538,7 +538,7 @@ var populateHopHintsTestCases = []struct {
|
||||||
"hop hints allowed",
|
"hop hints allowed",
|
||||||
setupMock: func(h *hopHintsConfigMock) {
|
setupMock: func(h *hopHintsConfigMock) {
|
||||||
fundingOutpoint := wire.OutPoint{Index: 9}
|
fundingOutpoint := wire.OutPoint{Index: 9}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
allChannels := []*channeldb.OpenChannel{
|
allChannels := []*channeldb.OpenChannel{
|
||||||
{
|
{
|
||||||
FundingOutpoint: fundingOutpoint,
|
FundingOutpoint: fundingOutpoint,
|
||||||
|
@ -584,7 +584,7 @@ var populateHopHintsTestCases = []struct {
|
||||||
name: "populate hop hints stops when we reached the targeted bandwidth",
|
name: "populate hop hints stops when we reached the targeted bandwidth",
|
||||||
setupMock: func(h *hopHintsConfigMock) {
|
setupMock: func(h *hopHintsConfigMock) {
|
||||||
fundingOutpoint := wire.OutPoint{Index: 9}
|
fundingOutpoint := wire.OutPoint{Index: 9}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
remoteBalance := lnwire.MilliSatoshi(10_000_000)
|
remoteBalance := lnwire.MilliSatoshi(10_000_000)
|
||||||
allChannels := []*channeldb.OpenChannel{
|
allChannels := []*channeldb.OpenChannel{
|
||||||
{
|
{
|
||||||
|
@ -635,7 +635,7 @@ var populateHopHintsTestCases = []struct {
|
||||||
"remote balance frist",
|
"remote balance frist",
|
||||||
setupMock: func(h *hopHintsConfigMock) {
|
setupMock: func(h *hopHintsConfigMock) {
|
||||||
fundingOutpoint := wire.OutPoint{Index: 9}
|
fundingOutpoint := wire.OutPoint{Index: 9}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&fundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(fundingOutpoint)
|
||||||
remoteBalance := lnwire.MilliSatoshi(10_000_000)
|
remoteBalance := lnwire.MilliSatoshi(10_000_000)
|
||||||
allChannels := []*channeldb.OpenChannel{
|
allChannels := []*channeldb.OpenChannel{
|
||||||
// Because the channels with higher remote balance have
|
// Because the channels with higher remote balance have
|
||||||
|
@ -829,11 +829,11 @@ func setupMockTwoChannels(h *hopHintsConfigMock) (lnwire.ChannelID,
|
||||||
lnwire.ChannelID) {
|
lnwire.ChannelID) {
|
||||||
|
|
||||||
fundingOutpoint1 := wire.OutPoint{Index: 9}
|
fundingOutpoint1 := wire.OutPoint{Index: 9}
|
||||||
chanID1 := lnwire.NewChanIDFromOutPoint(&fundingOutpoint1)
|
chanID1 := lnwire.NewChanIDFromOutPoint(fundingOutpoint1)
|
||||||
remoteBalance1 := lnwire.MilliSatoshi(10_000_000)
|
remoteBalance1 := lnwire.MilliSatoshi(10_000_000)
|
||||||
|
|
||||||
fundingOutpoint2 := wire.OutPoint{Index: 2}
|
fundingOutpoint2 := wire.OutPoint{Index: 2}
|
||||||
chanID2 := lnwire.NewChanIDFromOutPoint(&fundingOutpoint2)
|
chanID2 := lnwire.NewChanIDFromOutPoint(fundingOutpoint2)
|
||||||
remoteBalance2 := lnwire.MilliSatoshi(1_000_000)
|
remoteBalance2 := lnwire.MilliSatoshi(1_000_000)
|
||||||
|
|
||||||
allChannels := []*channeldb.OpenChannel{
|
allChannels := []*channeldb.OpenChannel{
|
||||||
|
|
|
@ -269,7 +269,7 @@ func NewChanCloser(cfg ChanCloseCfg, deliveryScript []byte,
|
||||||
closeReq *htlcswitch.ChanClose, locallyInitiated bool) *ChanCloser {
|
closeReq *htlcswitch.ChanClose, locallyInitiated bool) *ChanCloser {
|
||||||
|
|
||||||
chanPoint := cfg.Channel.ChannelPoint()
|
chanPoint := cfg.Channel.ChannelPoint()
|
||||||
cid := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
cid := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
return &ChanCloser{
|
return &ChanCloser{
|
||||||
closeReq: closeReq,
|
closeReq: closeReq,
|
||||||
state: closeIdle,
|
state: closeIdle,
|
||||||
|
|
|
@ -3560,7 +3560,7 @@ func (lc *LightningChannel) createCommitDiff(
|
||||||
// used on the wire to identify this channel. We'll use this shortly
|
// used on the wire to identify this channel. We'll use this shortly
|
||||||
// when recording the exact CommitSig message that we'll be sending
|
// when recording the exact CommitSig message that we'll be sending
|
||||||
// out.
|
// out.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&lc.channelState.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(lc.channelState.FundingOutpoint)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logUpdates []channeldb.LogUpdate
|
logUpdates []channeldb.LogUpdate
|
||||||
|
@ -3680,7 +3680,7 @@ func (lc *LightningChannel) createCommitDiff(
|
||||||
Commitment: *diskCommit,
|
Commitment: *diskCommit,
|
||||||
CommitSig: &lnwire.CommitSig{
|
CommitSig: &lnwire.CommitSig{
|
||||||
ChanID: lnwire.NewChanIDFromOutPoint(
|
ChanID: lnwire.NewChanIDFromOutPoint(
|
||||||
&lc.channelState.FundingOutpoint,
|
lc.channelState.FundingOutpoint,
|
||||||
),
|
),
|
||||||
CommitSig: commitSig,
|
CommitSig: commitSig,
|
||||||
HtlcSigs: htlcSigs,
|
HtlcSigs: htlcSigs,
|
||||||
|
@ -3698,7 +3698,7 @@ func (lc *LightningChannel) createCommitDiff(
|
||||||
func (lc *LightningChannel) getUnsignedAckedUpdates() []channeldb.LogUpdate {
|
func (lc *LightningChannel) getUnsignedAckedUpdates() []channeldb.LogUpdate {
|
||||||
// First, we need to convert the funding outpoint into the ID that's
|
// First, we need to convert the funding outpoint into the ID that's
|
||||||
// used on the wire to identify this channel.
|
// used on the wire to identify this channel.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&lc.channelState.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(lc.channelState.FundingOutpoint)
|
||||||
|
|
||||||
// Fetch the last remote update that we have signed for.
|
// Fetch the last remote update that we have signed for.
|
||||||
lastRemoteCommitted := lc.remoteCommitChain.tail().theirMessageIndex
|
lastRemoteCommitted := lc.remoteCommitChain.tail().theirMessageIndex
|
||||||
|
@ -4543,7 +4543,7 @@ func (lc *LightningChannel) ProcessChanSyncMsg(
|
||||||
case err == nil:
|
case err == nil:
|
||||||
commitSig := &lnwire.CommitSig{
|
commitSig := &lnwire.CommitSig{
|
||||||
ChanID: lnwire.NewChanIDFromOutPoint(
|
ChanID: lnwire.NewChanIDFromOutPoint(
|
||||||
&lc.channelState.FundingOutpoint,
|
lc.channelState.FundingOutpoint,
|
||||||
),
|
),
|
||||||
CommitSig: newCommit.CommitSig,
|
CommitSig: newCommit.CommitSig,
|
||||||
HtlcSigs: newCommit.HtlcSigs,
|
HtlcSigs: newCommit.HtlcSigs,
|
||||||
|
@ -5571,7 +5571,7 @@ func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.RevokeAndAck,
|
||||||
len(unsignedAckedUpdates))
|
len(unsignedAckedUpdates))
|
||||||
|
|
||||||
revocationMsg.ChanID = lnwire.NewChanIDFromOutPoint(
|
revocationMsg.ChanID = lnwire.NewChanIDFromOutPoint(
|
||||||
&lc.channelState.FundingOutpoint,
|
lc.channelState.FundingOutpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
return revocationMsg, newCommitment.Htlcs, finalHtlcs, nil
|
return revocationMsg, newCommitment.Htlcs, finalHtlcs, nil
|
||||||
|
@ -5638,7 +5638,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
||||||
localChainTail := lc.localCommitChain.tail().height
|
localChainTail := lc.localCommitChain.tail().height
|
||||||
|
|
||||||
source := lc.ShortChanID()
|
source := lc.ShortChanID()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&lc.channelState.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(lc.channelState.FundingOutpoint)
|
||||||
|
|
||||||
// Determine the set of htlcs that can be forwarded as a result of
|
// Determine the set of htlcs that can be forwarded as a result of
|
||||||
// having received the revocation. We will simultaneously construct the
|
// having received the revocation. We will simultaneously construct the
|
||||||
|
@ -8517,7 +8517,7 @@ func (lc *LightningChannel) generateRevocation(height uint64) (*lnwire.RevokeAnd
|
||||||
|
|
||||||
revocationMsg.NextRevocationKey = input.ComputeCommitmentPoint(nextCommitSecret[:])
|
revocationMsg.NextRevocationKey = input.ComputeCommitmentPoint(nextCommitSecret[:])
|
||||||
revocationMsg.ChanID = lnwire.NewChanIDFromOutPoint(
|
revocationMsg.ChanID = lnwire.NewChanIDFromOutPoint(
|
||||||
&lc.channelState.FundingOutpoint,
|
lc.channelState.FundingOutpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
// If this is a taproot channel, then we also need to generate the
|
// If this is a taproot channel, then we also need to generate the
|
||||||
|
|
|
@ -3052,7 +3052,7 @@ func TestChanSyncOweCommitment(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&aliceChannel.channelState.FundingOutpoint,
|
aliceChannel.channelState.FundingOutpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
// With the HTLC's applied to both update logs, we'll initiate a state
|
// With the HTLC's applied to both update logs, we'll initiate a state
|
||||||
|
@ -3419,7 +3419,7 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
|
||||||
require.NoError(t, err, "unable to create test channels")
|
require.NoError(t, err, "unable to create test channels")
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&aliceChannel.channelState.FundingOutpoint,
|
aliceChannel.channelState.FundingOutpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
// We'll start the test with Bob extending a single HTLC to Alice, and
|
// We'll start the test with Bob extending a single HTLC to Alice, and
|
||||||
|
@ -4682,7 +4682,7 @@ func TestChanSyncUnableToSync(t *testing.T) {
|
||||||
// state.
|
// state.
|
||||||
badChanSync := &lnwire.ChannelReestablish{
|
badChanSync := &lnwire.ChannelReestablish{
|
||||||
ChanID: lnwire.NewChanIDFromOutPoint(
|
ChanID: lnwire.NewChanIDFromOutPoint(
|
||||||
&aliceChannel.channelState.FundingOutpoint,
|
aliceChannel.channelState.FundingOutpoint,
|
||||||
),
|
),
|
||||||
NextLocalCommitHeight: 1000,
|
NextLocalCommitHeight: 1000,
|
||||||
RemoteCommitTailHeight: 9000,
|
RemoteCommitTailHeight: 9000,
|
||||||
|
|
|
@ -269,8 +269,7 @@ func addTestHtlcs(t *testing.T, remote, local *LightningChannel,
|
||||||
hash160map[hash160] = preimage
|
hash160map[hash160] = preimage
|
||||||
|
|
||||||
// Add htlc to the channel.
|
// Add htlc to the channel.
|
||||||
chanPoint := remote.ChannelPoint()
|
chanID := lnwire.NewChanIDFromOutPoint(remote.ChannelPoint())
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
|
||||||
|
|
||||||
msg := &lnwire.UpdateAddHTLC{
|
msg := &lnwire.UpdateAddHTLC{
|
||||||
Amount: htlc.amount,
|
Amount: htlc.amount,
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (c ChannelID) String() string {
|
||||||
// usable within the network. In order to convert the OutPoint into a ChannelID,
|
// usable within the network. In order to convert the OutPoint into a ChannelID,
|
||||||
// we XOR the lower 2-bytes of the txid within the OutPoint with the big-endian
|
// we XOR the lower 2-bytes of the txid within the OutPoint with the big-endian
|
||||||
// serialization of the Index of the OutPoint, truncated to 2-bytes.
|
// serialization of the Index of the OutPoint, truncated to 2-bytes.
|
||||||
func NewChanIDFromOutPoint(op *wire.OutPoint) ChannelID {
|
func NewChanIDFromOutPoint(op wire.OutPoint) ChannelID {
|
||||||
// First we'll copy the txid of the outpoint into our channel ID slice.
|
// First we'll copy the txid of the outpoint into our channel ID slice.
|
||||||
var cid ChannelID
|
var cid ChannelID
|
||||||
copy(cid[:], op.Hash[:])
|
copy(cid[:], op.Hash[:])
|
||||||
|
@ -85,7 +85,7 @@ func (c *ChannelID) GenPossibleOutPoints() [MaxFundingTxOutputs]wire.OutPoint {
|
||||||
// IsChanPoint returns true if the OutPoint passed corresponds to the target
|
// IsChanPoint returns true if the OutPoint passed corresponds to the target
|
||||||
// ChannelID.
|
// ChannelID.
|
||||||
func (c ChannelID) IsChanPoint(op *wire.OutPoint) bool {
|
func (c ChannelID) IsChanPoint(op *wire.OutPoint) bool {
|
||||||
candidateCid := NewChanIDFromOutPoint(op)
|
candidateCid := NewChanIDFromOutPoint(*op)
|
||||||
|
|
||||||
return candidateCid == c
|
return candidateCid == c
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ func TestChannelIDOutPointConversion(t *testing.T) {
|
||||||
|
|
||||||
// With the output index mutated, we'll convert it into a
|
// With the output index mutated, we'll convert it into a
|
||||||
// ChannelID.
|
// ChannelID.
|
||||||
cid := NewChanIDFromOutPoint(&testChanPoint)
|
cid := NewChanIDFromOutPoint(testChanPoint)
|
||||||
|
|
||||||
// Once the channel point has been converted to a channelID, it
|
// Once the channel point has been converted to a channelID, it
|
||||||
// should recognize its original outpoint.
|
// should recognize its original outpoint.
|
||||||
|
@ -48,7 +48,7 @@ func TestGenPossibleOutPoints(t *testing.T) {
|
||||||
// We'll first convert out test outpoint into a ChannelID.
|
// We'll first convert out test outpoint into a ChannelID.
|
||||||
testChanPoint := *outpoint1
|
testChanPoint := *outpoint1
|
||||||
testChanPoint.Index = 24
|
testChanPoint.Index = 24
|
||||||
chanID := NewChanIDFromOutPoint(&testChanPoint)
|
chanID := NewChanIDFromOutPoint(testChanPoint)
|
||||||
|
|
||||||
// With the chan ID created, we'll generate all possible root outpoints
|
// With the chan ID created, we'll generate all possible root outpoints
|
||||||
// given this channel ID.
|
// given this channel ID.
|
||||||
|
|
|
@ -391,7 +391,7 @@ func (m *ChanStatusManager) processEnableRequest(outpoint wire.OutPoint,
|
||||||
|
|
||||||
// Quickly check to see if the requested channel is active within the
|
// Quickly check to see if the requested channel is active within the
|
||||||
// htlcswitch and return an error if it isn't.
|
// htlcswitch and return an error if it isn't.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&outpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(outpoint)
|
||||||
if !m.cfg.IsChannelActive(chanID) {
|
if !m.cfg.IsChannelActive(chanID) {
|
||||||
return ErrEnableInactiveChan
|
return ErrEnableInactiveChan
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ func (m *ChanStatusManager) markPendingInactiveChannels() {
|
||||||
// If our bookkeeping shows the channel as active, sample the
|
// If our bookkeeping shows the channel as active, sample the
|
||||||
// htlcswitch to see if it believes the link is also active. If
|
// htlcswitch to see if it believes the link is also active. If
|
||||||
// so, we will skip marking it as ChanStatusPendingDisabled.
|
// so, we will skip marking it as ChanStatusPendingDisabled.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&c.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(c.FundingOutpoint)
|
||||||
if m.cfg.IsChannelActive(chanID) {
|
if m.cfg.IsChannelActive(chanID) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,7 +391,7 @@ func (h *testHarness) markActive(channels []*channeldb.OpenChannel) {
|
||||||
h.t.Helper()
|
h.t.Helper()
|
||||||
|
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
h.htlcSwitch.SetStatus(chanID, true)
|
h.htlcSwitch.SetStatus(chanID, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ func (h *testHarness) markInactive(channels []*channeldb.OpenChannel) {
|
||||||
h.t.Helper()
|
h.t.Helper()
|
||||||
|
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
h.htlcSwitch.SetStatus(chanID, false)
|
h.htlcSwitch.SetStatus(chanID, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -834,7 +834,7 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
||||||
}
|
}
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&dbChan.FundingOutpoint,
|
dbChan.FundingOutpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fetch the second commitment point to send in
|
// Fetch the second commitment point to send in
|
||||||
|
@ -870,7 +870,7 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
chanPoint := &dbChan.FundingOutpoint
|
chanPoint := dbChan.FundingOutpoint
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
|
@ -932,7 +932,9 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
||||||
// need to fetch its current link-layer forwarding policy from
|
// need to fetch its current link-layer forwarding policy from
|
||||||
// the database.
|
// the database.
|
||||||
graph := p.cfg.ChannelGraph
|
graph := p.cfg.ChannelGraph
|
||||||
info, p1, p2, err := graph.FetchChannelEdgesByOutpoint(chanPoint)
|
info, p1, p2, err := graph.FetchChannelEdgesByOutpoint(
|
||||||
|
&chanPoint,
|
||||||
|
)
|
||||||
if err != nil && err != channeldb.ErrEdgeNotFound {
|
if err != nil && err != channeldb.ErrEdgeNotFound {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1020,7 +1022,7 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
||||||
}
|
}
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&lnChan.State().FundingOutpoint,
|
lnChan.State().FundingOutpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
p.activeChanCloses[chanID] = chanCloser
|
p.activeChanCloses[chanID] = chanCloser
|
||||||
|
@ -1042,14 +1044,14 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
||||||
|
|
||||||
// Subscribe to the set of on-chain events for this channel.
|
// Subscribe to the set of on-chain events for this channel.
|
||||||
chainEvents, err := p.cfg.ChainArb.SubscribeChannelEvents(
|
chainEvents, err := p.cfg.ChainArb.SubscribeChannelEvents(
|
||||||
*chanPoint,
|
chanPoint,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = p.addLink(
|
err = p.addLink(
|
||||||
chanPoint, lnChan, forwardingPolicy, chainEvents,
|
&chanPoint, lnChan, forwardingPolicy, chainEvents,
|
||||||
true, shutdownMsg,
|
true, shutdownMsg,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1144,7 +1146,7 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
|
||||||
// links going by the same channel id. If one is found, we'll shut it
|
// links going by the same channel id. If one is found, we'll shut it
|
||||||
// down to ensure that the mailboxes are only ever under the control of
|
// down to ensure that the mailboxes are only ever under the control of
|
||||||
// one link.
|
// one link.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(*chanPoint)
|
||||||
p.cfg.Switch.RemoveLink(chanID)
|
p.cfg.Switch.RemoveLink(chanID)
|
||||||
|
|
||||||
// With the channel link created, we'll now notify the htlc switch so
|
// With the channel link created, we'll now notify the htlc switch so
|
||||||
|
@ -2912,7 +2914,7 @@ func (p *Brontide) restartCoopClose(lnChan *lnwallet.LightningChannel) (
|
||||||
// This does not need a mutex even though it is in a different
|
// This does not need a mutex even though it is in a different
|
||||||
// goroutine since this is done before the channelManager goroutine is
|
// goroutine since this is done before the channelManager goroutine is
|
||||||
// created.
|
// created.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&c.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(c.FundingOutpoint)
|
||||||
p.activeChanCloses[chanID] = chanCloser
|
p.activeChanCloses[chanID] = chanCloser
|
||||||
|
|
||||||
// Create the Shutdown message.
|
// Create the Shutdown message.
|
||||||
|
@ -2976,7 +2978,7 @@ func (p *Brontide) createChanCloser(channel *lnwallet.LightningChannel,
|
||||||
// handleLocalCloseReq kicks-off the workflow to execute a cooperative or
|
// handleLocalCloseReq kicks-off the workflow to execute a cooperative or
|
||||||
// forced unilateral closure of the channel initiated by a local subsystem.
|
// forced unilateral closure of the channel initiated by a local subsystem.
|
||||||
func (p *Brontide) handleLocalCloseReq(req *htlcswitch.ChanClose) {
|
func (p *Brontide) handleLocalCloseReq(req *htlcswitch.ChanClose) {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(req.ChanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(*req.ChanPoint)
|
||||||
|
|
||||||
channel, ok := p.activeChannels.Load(chanID)
|
channel, ok := p.activeChannels.Load(chanID)
|
||||||
|
|
||||||
|
@ -3099,7 +3101,7 @@ type linkFailureReport struct {
|
||||||
func (p *Brontide) handleLinkFailure(failure linkFailureReport) {
|
func (p *Brontide) handleLinkFailure(failure linkFailureReport) {
|
||||||
// Retrieve the channel from the map of active channels. We do this to
|
// Retrieve the channel from the map of active channels. We do this to
|
||||||
// have access to it even after WipeChannel remove it from the map.
|
// have access to it even after WipeChannel remove it from the map.
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&failure.chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(failure.chanPoint)
|
||||||
lnChan, _ := p.activeChannels.Load(chanID)
|
lnChan, _ := p.activeChannels.Load(chanID)
|
||||||
|
|
||||||
// We begin by wiping the link, which will remove it from the switch,
|
// We begin by wiping the link, which will remove it from the switch,
|
||||||
|
@ -3212,7 +3214,7 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
|
||||||
p.WipeChannel(&chanPoint)
|
p.WipeChannel(&chanPoint)
|
||||||
|
|
||||||
// Also clear the activeChanCloses map of this channel.
|
// Also clear the activeChanCloses map of this channel.
|
||||||
cid := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
cid := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
delete(p.activeChanCloses, cid)
|
delete(p.activeChanCloses, cid)
|
||||||
|
|
||||||
// Next, we'll launch a goroutine which will request to be notified by
|
// Next, we'll launch a goroutine which will request to be notified by
|
||||||
|
@ -3302,7 +3304,7 @@ func WaitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier,
|
||||||
// WipeChannel removes the passed channel point from all indexes associated with
|
// WipeChannel removes the passed channel point from all indexes associated with
|
||||||
// the peer and the switch.
|
// the peer and the switch.
|
||||||
func (p *Brontide) WipeChannel(chanPoint *wire.OutPoint) {
|
func (p *Brontide) WipeChannel(chanPoint *wire.OutPoint) {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(*chanPoint)
|
||||||
|
|
||||||
p.activeChannels.Delete(chanID)
|
p.activeChannels.Delete(chanID)
|
||||||
|
|
||||||
|
@ -3881,7 +3883,7 @@ func (p *Brontide) attachChannelEventSubscription() error {
|
||||||
// updateNextRevocation updates the existing channel's next revocation if it's
|
// updateNextRevocation updates the existing channel's next revocation if it's
|
||||||
// nil.
|
// nil.
|
||||||
func (p *Brontide) updateNextRevocation(c *channeldb.OpenChannel) error {
|
func (p *Brontide) updateNextRevocation(c *channeldb.OpenChannel) error {
|
||||||
chanPoint := &c.FundingOutpoint
|
chanPoint := c.FundingOutpoint
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
// Read the current channel.
|
// Read the current channel.
|
||||||
|
@ -3925,7 +3927,7 @@ func (p *Brontide) updateNextRevocation(c *channeldb.OpenChannel) error {
|
||||||
// takes a `channeldb.OpenChannel`, creates a `lnwallet.LightningChannel` from
|
// takes a `channeldb.OpenChannel`, creates a `lnwallet.LightningChannel` from
|
||||||
// it and assembles it with a channel link.
|
// it and assembles it with a channel link.
|
||||||
func (p *Brontide) addActiveChannel(c *lnpeer.NewChannel) error {
|
func (p *Brontide) addActiveChannel(c *lnpeer.NewChannel) error {
|
||||||
chanPoint := &c.FundingOutpoint
|
chanPoint := c.FundingOutpoint
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
// If we've reached this point, there are two possible scenarios. If
|
// If we've reached this point, there are two possible scenarios. If
|
||||||
|
@ -3960,7 +3962,7 @@ func (p *Brontide) addActiveChannel(c *lnpeer.NewChannel) error {
|
||||||
|
|
||||||
// Next, we'll assemble a ChannelLink along with the necessary items it
|
// Next, we'll assemble a ChannelLink along with the necessary items it
|
||||||
// needs to function.
|
// needs to function.
|
||||||
chainEvents, err := p.cfg.ChainArb.SubscribeChannelEvents(*chanPoint)
|
chainEvents, err := p.cfg.ChainArb.SubscribeChannelEvents(chanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to subscribe to chain events: %w",
|
return fmt.Errorf("unable to subscribe to chain events: %w",
|
||||||
err)
|
err)
|
||||||
|
@ -3976,7 +3978,7 @@ func (p *Brontide) addActiveChannel(c *lnpeer.NewChannel) error {
|
||||||
|
|
||||||
// Create the link and add it to the switch.
|
// Create the link and add it to the switch.
|
||||||
err = p.addLink(
|
err = p.addLink(
|
||||||
chanPoint, lnChan, initialPolicy, chainEvents,
|
&chanPoint, lnChan, initialPolicy, chainEvents,
|
||||||
shouldReestablish, fn.None[lnwire.Shutdown](),
|
shouldReestablish, fn.None[lnwire.Shutdown](),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3992,7 +3994,7 @@ func (p *Brontide) addActiveChannel(c *lnpeer.NewChannel) error {
|
||||||
// or init the next revocation for it.
|
// or init the next revocation for it.
|
||||||
func (p *Brontide) handleNewActiveChannel(req *newChannelMsg) {
|
func (p *Brontide) handleNewActiveChannel(req *newChannelMsg) {
|
||||||
newChan := req.channel
|
newChan := req.channel
|
||||||
chanPoint := &newChan.FundingOutpoint
|
chanPoint := newChan.FundingOutpoint
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
// Only update RemoteNextRevocation if the channel is in the
|
// Only update RemoteNextRevocation if the channel is in the
|
||||||
|
|
|
@ -54,7 +54,7 @@ func TestPeerChannelClosureShutdownResponseLinkRemoved(t *testing.T) {
|
||||||
require.NoError(t, err, "unable to create test channels")
|
require.NoError(t, err, "unable to create test channels")
|
||||||
|
|
||||||
chanPoint := bobChan.ChannelPoint()
|
chanPoint := bobChan.ChannelPoint()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
dummyDeliveryScript := genScript(t, p2wshAddress)
|
dummyDeliveryScript := genScript(t, p2wshAddress)
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) {
|
||||||
require.NoError(t, err, "unable to create test channels")
|
require.NoError(t, err, "unable to create test channels")
|
||||||
|
|
||||||
chanPoint := bobChan.ChannelPoint()
|
chanPoint := bobChan.ChannelPoint()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
mockLink := newMockUpdateHandler(chanID)
|
mockLink := newMockUpdateHandler(chanID)
|
||||||
mockSwitch.links = append(mockSwitch.links, mockLink)
|
mockSwitch.links = append(mockSwitch.links, mockLink)
|
||||||
|
@ -207,7 +207,7 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
|
||||||
require.NoError(t, err, "unable to create test channels")
|
require.NoError(t, err, "unable to create test channels")
|
||||||
|
|
||||||
chanPoint := bobChan.ChannelPoint()
|
chanPoint := bobChan.ChannelPoint()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
mockLink := newMockUpdateHandler(chanID)
|
mockLink := newMockUpdateHandler(chanID)
|
||||||
mockSwitch.links = append(mockSwitch.links, mockLink)
|
mockSwitch.links = append(mockSwitch.links, mockLink)
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
||||||
require.NoError(t, err, "unable to create test channels")
|
require.NoError(t, err, "unable to create test channels")
|
||||||
|
|
||||||
chanPoint := bobChan.ChannelPoint()
|
chanPoint := bobChan.ChannelPoint()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
mockLink := newMockUpdateHandler(chanID)
|
mockLink := newMockUpdateHandler(chanID)
|
||||||
mockSwitch.links = append(mockSwitch.links, mockLink)
|
mockSwitch.links = append(mockSwitch.links, mockLink)
|
||||||
|
@ -518,7 +518,7 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
|
||||||
require.NoError(t, err, "unable to create test channels")
|
require.NoError(t, err, "unable to create test channels")
|
||||||
|
|
||||||
chanPoint := bobChan.ChannelPoint()
|
chanPoint := bobChan.ChannelPoint()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
mockLink := newMockUpdateHandler(chanID)
|
mockLink := newMockUpdateHandler(chanID)
|
||||||
mockSwitch.links = append(mockSwitch.links, mockLink)
|
mockSwitch.links = append(mockSwitch.links, mockLink)
|
||||||
|
|
||||||
|
@ -849,7 +849,7 @@ func TestCustomShutdownScript(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
chanPoint := bobChan.ChannelPoint()
|
chanPoint := bobChan.ChannelPoint()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
mockLink := newMockUpdateHandler(chanID)
|
mockLink := newMockUpdateHandler(chanID)
|
||||||
mockSwitch.links = append(mockSwitch.links, mockLink)
|
mockSwitch.links = append(mockSwitch.links, mockLink)
|
||||||
|
|
||||||
|
@ -1218,7 +1218,7 @@ func TestUpdateNextRevocation(t *testing.T) {
|
||||||
// Test an error is returned when the chanID's corresponding channel is
|
// Test an error is returned when the chanID's corresponding channel is
|
||||||
// nil.
|
// nil.
|
||||||
testChannel.FundingOutpoint = wire.OutPoint{Index: 1}
|
testChannel.FundingOutpoint = wire.OutPoint{Index: 1}
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&testChannel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(testChannel.FundingOutpoint)
|
||||||
alicePeer.activeChannels.Store(chanID, nil)
|
alicePeer.activeChannels.Store(chanID, nil)
|
||||||
|
|
||||||
err = alicePeer.updateNextRevocation(testChannel)
|
err = alicePeer.updateNextRevocation(testChannel)
|
||||||
|
|
|
@ -412,8 +412,7 @@ func createTestPeer(t *testing.T, notifier chainntnfs.ChainNotifier,
|
||||||
alicePeer := NewBrontide(*cfg)
|
alicePeer := NewBrontide(*cfg)
|
||||||
alicePeer.remoteFeatures = lnwire.NewFeatureVector(nil, lnwire.Features)
|
alicePeer.remoteFeatures = lnwire.NewFeatureVector(nil, lnwire.Features)
|
||||||
|
|
||||||
chanPoint := channelAlice.ChannelPoint()
|
chanID := lnwire.NewChanIDFromOutPoint(channelAlice.ChannelPoint())
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
|
||||||
alicePeer.activeChannels.Store(chanID, channelAlice)
|
alicePeer.activeChannels.Store(chanID, channelAlice)
|
||||||
|
|
||||||
alicePeer.wg.Add(1)
|
alicePeer.wg.Add(1)
|
||||||
|
|
12
rpcserver.go
12
rpcserver.go
|
@ -2580,7 +2580,9 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||||
// * so only need to grab from database
|
// * so only need to grab from database
|
||||||
peer.WipeChannel(&channel.FundingOutpoint)
|
peer.WipeChannel(&channel.FundingOutpoint)
|
||||||
} else {
|
} else {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
|
channel.FundingOutpoint,
|
||||||
|
)
|
||||||
r.server.htlcSwitch.RemoveLink(chanID)
|
r.server.htlcSwitch.RemoveLink(chanID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2634,7 +2636,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||||
|
|
||||||
// If the link is not known by the switch, we cannot gracefully close
|
// If the link is not known by the switch, we cannot gracefully close
|
||||||
// the channel.
|
// the channel.
|
||||||
channelID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
channelID := lnwire.NewChanIDFromOutPoint(*chanPoint)
|
||||||
if _, err := r.server.htlcSwitch.GetLink(channelID); err != nil {
|
if _, err := r.server.htlcSwitch.GetLink(channelID); err != nil {
|
||||||
rpcsLog.Debugf("Trying to non-force close offline channel with "+
|
rpcsLog.Debugf("Trying to non-force close offline channel with "+
|
||||||
"chan_point=%v", chanPoint)
|
"chan_point=%v", chanPoint)
|
||||||
|
@ -2953,7 +2955,7 @@ func (r *rpcServer) GetInfo(_ context.Context,
|
||||||
|
|
||||||
var activeChannels uint32
|
var activeChannels uint32
|
||||||
for _, channel := range openChannels {
|
for _, channel := range openChannels {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(channel.FundingOutpoint)
|
||||||
if r.server.htlcSwitch.HasActiveLink(chanID) {
|
if r.server.htlcSwitch.HasActiveLink(chanID) {
|
||||||
activeChannels++
|
activeChannels++
|
||||||
}
|
}
|
||||||
|
@ -4221,7 +4223,7 @@ func (r *rpcServer) ListChannels(ctx context.Context,
|
||||||
peerOnline = true
|
peerOnline = true
|
||||||
}
|
}
|
||||||
|
|
||||||
channelID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
channelID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
var linkActive bool
|
var linkActive bool
|
||||||
if link, err := r.server.htlcSwitch.GetLink(channelID); err == nil {
|
if link, err := r.server.htlcSwitch.GetLink(channelID); err == nil {
|
||||||
// A channel is only considered active if it is known
|
// A channel is only considered active if it is known
|
||||||
|
@ -4313,7 +4315,7 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||||
nodePub := dbChannel.IdentityPub
|
nodePub := dbChannel.IdentityPub
|
||||||
nodeID := hex.EncodeToString(nodePub.SerializeCompressed())
|
nodeID := hex.EncodeToString(nodePub.SerializeCompressed())
|
||||||
chanPoint := dbChannel.FundingOutpoint
|
chanPoint := dbChannel.FundingOutpoint
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
// As this is required for display purposes, we'll calculate
|
// As this is required for display purposes, we'll calculate
|
||||||
// the weight of the commitment transaction. We also add on the
|
// the weight of the commitment transaction. We also add on the
|
||||||
|
|
|
@ -1164,7 +1164,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||||
FeeEstimator: cc.FeeEstimator,
|
FeeEstimator: cc.FeeEstimator,
|
||||||
ChainIO: cc.ChainIO,
|
ChainIO: cc.ChainIO,
|
||||||
MarkLinkInactive: func(chanPoint wire.OutPoint) error {
|
MarkLinkInactive: func(chanPoint wire.OutPoint) error {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
s.htlcSwitch.RemoveLink(chanID)
|
s.htlcSwitch.RemoveLink(chanID)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
@ -1421,7 +1421,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||||
return s.chainArb.WatchNewChannel(channel)
|
return s.chainArb.WatchNewChannel(channel)
|
||||||
},
|
},
|
||||||
ReportShortChanID: func(chanPoint wire.OutPoint) error {
|
ReportShortChanID: func(chanPoint wire.OutPoint) error {
|
||||||
cid := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
cid := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
return s.htlcSwitch.UpdateShortChanID(cid)
|
return s.htlcSwitch.UpdateShortChanID(cid)
|
||||||
},
|
},
|
||||||
RequiredRemoteChanReserve: func(chanAmt,
|
RequiredRemoteChanReserve: func(chanAmt,
|
||||||
|
@ -4633,7 +4633,7 @@ func (s *server) applyChannelUpdate(update *lnwire.ChannelUpdate,
|
||||||
defaultAlias lnwire.ShortChannelID
|
defaultAlias lnwire.ShortChannelID
|
||||||
)
|
)
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(op)
|
chanID := lnwire.NewChanIDFromOutPoint(*op)
|
||||||
|
|
||||||
// Fetch the peer's alias from the lnwire.ChannelID so it can be used
|
// Fetch the peer's alias from the lnwire.ChannelID so it can be used
|
||||||
// in the ChannelUpdate if it hasn't been announced yet.
|
// in the ChannelUpdate if it hasn't been announced yet.
|
||||||
|
|
|
@ -780,7 +780,7 @@ func (m *Manager) handleChannelCloses(chanSub subscribe.Subscription) {
|
||||||
}
|
}
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(
|
chanID := lnwire.NewChanIDFromOutPoint(
|
||||||
&event.CloseSummary.ChanPoint,
|
event.CloseSummary.ChanPoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debugf("Received ClosedChannelEvent for "+
|
log.Debugf("Received ClosedChannelEvent for "+
|
||||||
|
|
Loading…
Add table
Reference in a new issue