@@ -1996,10 +1996,14 @@ func (d *AuthenticatedGossiper) processRejectedEdge(_ context.Context,
19961996 return nil , nil
19971997 }
19981998
1999+ // Attach the proof to the channel info before creating the
2000+ // announcement.
2001+ chanInfo .AuthProof = proof
2002+
19992003 // We'll then create then validate the new fully assembled
20002004 // announcement.
20012005 chanAnn , e1Ann , e2Ann , err := netann .CreateChanAnnouncement (
2002- proof , chanInfo , e1 , e2 ,
2006+ chanInfo , e1 , e2 ,
20032007 )
20042008 if err != nil {
20052009 return nil , err
@@ -2392,44 +2396,13 @@ func (d *AuthenticatedGossiper) updateChannel(ctx context.Context,
23922396 // have a full channel announcement for this channel.
23932397 var chanAnn * lnwire.ChannelAnnouncement1
23942398 if info .AuthProof != nil {
2395- chanID := lnwire .NewShortChanIDFromInt (info .ChannelID )
2396- chanAnn = & lnwire.ChannelAnnouncement1 {
2397- ShortChannelID : chanID ,
2398- NodeID1 : info .NodeKey1Bytes ,
2399- NodeID2 : info .NodeKey2Bytes ,
2400- ChainHash : info .ChainHash ,
2401- BitcoinKey1 : info .BitcoinKey1Bytes ,
2402- Features : lnwire .NewRawFeatureVector (),
2403- BitcoinKey2 : info .BitcoinKey2Bytes ,
2404- ExtraOpaqueData : info .ExtraOpaqueData ,
2405- }
2406- chanAnn .NodeSig1 , err = lnwire .NewSigFromECDSARawSignature (
2407- info .AuthProof .NodeSig1Bytes ,
2408- )
2409- if err != nil {
2410- return nil , nil , err
2411- }
2412- chanAnn .NodeSig2 , err = lnwire .NewSigFromECDSARawSignature (
2413- info .AuthProof .NodeSig2Bytes ,
2414- )
2415- if err != nil {
2416- return nil , nil , err
2417- }
2418- chanAnn .BitcoinSig1 , err = lnwire .NewSigFromECDSARawSignature (
2419- info .AuthProof .BitcoinSig1Bytes ,
2420- )
2421- if err != nil {
2422- return nil , nil , err
2423- }
2424- chanAnn .BitcoinSig2 , err = lnwire .NewSigFromECDSARawSignature (
2425- info .AuthProof .BitcoinSig2Bytes ,
2426- )
2399+ chanAnn , err = info .ToChannelAnnouncement ()
24272400 if err != nil {
24282401 return nil , nil , err
24292402 }
24302403 }
24312404
2432- return chanAnn , chanUpdate , err
2405+ return chanAnn , chanUpdate , nil
24332406}
24342407
24352408// SyncManager returns the gossiper's SyncManager instance.
@@ -2692,28 +2665,36 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
26922665 // If the proof checks out, then we'll save the proof itself to
26932666 // the database so we can fetch it later when gossiping with
26942667 // other nodes.
2695- proof = & models.ChannelAuthProof {
2696- NodeSig1Bytes : ann .NodeSig1 .ToSignatureBytes (),
2697- NodeSig2Bytes : ann .NodeSig2 .ToSignatureBytes (),
2698- BitcoinSig1Bytes : ann .BitcoinSig1 .ToSignatureBytes (),
2699- BitcoinSig2Bytes : ann .BitcoinSig2 .ToSignatureBytes (),
2700- }
2668+ proof = models .NewV1ChannelAuthProof (
2669+ ann .NodeSig1 .ToSignatureBytes (),
2670+ ann .NodeSig2 .ToSignatureBytes (),
2671+ ann .BitcoinSig1 .ToSignatureBytes (),
2672+ ann .BitcoinSig2 .ToSignatureBytes (),
2673+ )
27012674 }
27022675
27032676 // With the proof validated (if necessary), we can now store it within
27042677 // the database for our path finding and syncing needs.
2705- edge := & models.ChannelEdgeInfo {
2706- ChannelID : scid .ToUint64 (),
2707- ChainHash : ann .ChainHash ,
2708- NodeKey1Bytes : ann .NodeID1 ,
2709- NodeKey2Bytes : ann .NodeID2 ,
2710- BitcoinKey1Bytes : ann .BitcoinKey1 ,
2711- BitcoinKey2Bytes : ann .BitcoinKey2 ,
2712- AuthProof : proof ,
2713- Features : lnwire .NewFeatureVector (
2714- ann .Features , lnwire .Features ,
2715- ),
2716- ExtraOpaqueData : ann .ExtraOpaqueData ,
2678+ edge , err := models .NewV1Channel (
2679+ scid .ToUint64 (), ann .ChainHash , ann .NodeID1 , ann .NodeID2 ,
2680+ & models.ChannelV1Fields {
2681+ BitcoinKey1Bytes : ann .BitcoinKey1 ,
2682+ BitcoinKey2Bytes : ann .BitcoinKey2 ,
2683+ ExtraOpaqueData : ann .ExtraOpaqueData ,
2684+ },
2685+ models .WithChanProof (proof ), models .WithFeatures (ann .Features ),
2686+ )
2687+ if err != nil {
2688+ key := newRejectCacheKey (
2689+ ann .GossipVersion (),
2690+ scid .ToUint64 (),
2691+ sourceToPub (nMsg .source ),
2692+ )
2693+ _ , _ = d .recentRejects .Put (key , & cachedReject {})
2694+
2695+ log .Errorf ("unable to create channel edge: %v" , err )
2696+ nMsg .err <- err
2697+ return nil , false
27172698 }
27182699
27192700 // If there were any optional message fields provided, we'll include
@@ -3558,7 +3539,7 @@ func (d *AuthenticatedGossiper) handleAnnSig(ctx context.Context,
35583539 ann .ChannelID , peerID )
35593540
35603541 ca , _ , _ , err := netann .CreateChanAnnouncement (
3561- chanInfo . AuthProof , chanInfo , e1 , e2 ,
3542+ chanInfo , e1 , e2 ,
35623543 )
35633544 if err != nil {
35643545 log .Errorf ("unable to gen ann: %v" ,
@@ -3620,21 +3601,29 @@ func (d *AuthenticatedGossiper) handleAnnSig(ctx context.Context,
36203601 // We now have both halves of the channel announcement proof, then
36213602 // we'll reconstruct the initial announcement so we can validate it
36223603 // shortly below.
3623- var dbProof models.ChannelAuthProof
3604+ var dbProof * models.ChannelAuthProof
36243605 if isFirstNode {
3625- dbProof .NodeSig1Bytes = ann .NodeSignature .ToSignatureBytes ()
3626- dbProof .NodeSig2Bytes = oppProof .NodeSignature .ToSignatureBytes ()
3627- dbProof .BitcoinSig1Bytes = ann .BitcoinSignature .ToSignatureBytes ()
3628- dbProof .BitcoinSig2Bytes = oppProof .BitcoinSignature .ToSignatureBytes ()
3606+ dbProof = models .NewV1ChannelAuthProof (
3607+ ann .NodeSignature .ToSignatureBytes (),
3608+ oppProof .NodeSignature .ToSignatureBytes (),
3609+ ann .BitcoinSignature .ToSignatureBytes (),
3610+ oppProof .BitcoinSignature .ToSignatureBytes (),
3611+ )
36293612 } else {
3630- dbProof .NodeSig1Bytes = oppProof .NodeSignature .ToSignatureBytes ()
3631- dbProof .NodeSig2Bytes = ann .NodeSignature .ToSignatureBytes ()
3632- dbProof .BitcoinSig1Bytes = oppProof .BitcoinSignature .ToSignatureBytes ()
3633- dbProof .BitcoinSig2Bytes = ann .BitcoinSignature .ToSignatureBytes ()
3613+ dbProof = models .NewV1ChannelAuthProof (
3614+ oppProof .NodeSignature .ToSignatureBytes (),
3615+ ann .NodeSignature .ToSignatureBytes (),
3616+ oppProof .BitcoinSignature .ToSignatureBytes (),
3617+ ann .BitcoinSignature .ToSignatureBytes (),
3618+ )
36343619 }
36353620
3621+ // Attach the proof to the channel info before creating the
3622+ // announcement.
3623+ chanInfo .AuthProof = dbProof
3624+
36363625 chanAnn , e1Ann , e2Ann , err := netann .CreateChanAnnouncement (
3637- & dbProof , chanInfo , e1 , e2 ,
3626+ chanInfo , e1 , e2 ,
36383627 )
36393628 if err != nil {
36403629 log .Error (err )
@@ -3660,7 +3649,7 @@ func (d *AuthenticatedGossiper) handleAnnSig(ctx context.Context,
36603649 // attest to the bitcoin keys by validating the signatures of
36613650 // announcement. If proof is valid then we'll populate the channel edge
36623651 // with it, so we can announce it on peer connect.
3663- err = d .cfg .Graph .AddProof (ann .ShortChannelID , & dbProof )
3652+ err = d .cfg .Graph .AddProof (ann .ShortChannelID , dbProof )
36643653 if err != nil {
36653654 err := fmt .Errorf ("unable add proof to the channel chanID=%v:" +
36663655 " %v" , ann .ChannelID , err )
0 commit comments