@@ -627,9 +627,26 @@ func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate1) error {
627
627
return nil
628
628
}
629
629
630
+ type fundingTxOpts struct {
631
+ extraBytes []byte
632
+ }
633
+
634
+ type fundingTxOption func (* fundingTxOpts )
635
+
636
+ func withExtraBytes (extraBytes []byte ) fundingTxOption {
637
+ return func (opts * fundingTxOpts ) {
638
+ opts .extraBytes = extraBytes
639
+ }
640
+ }
641
+
630
642
func (ctx * testCtx ) createAnnouncementWithoutProof (blockHeight uint32 ,
631
643
key1 , key2 * btcec.PublicKey ,
632
- extraBytes ... []byte ) * lnwire.ChannelAnnouncement1 {
644
+ options ... fundingTxOption ) * lnwire.ChannelAnnouncement1 {
645
+
646
+ var opts fundingTxOpts
647
+ for _ , opt := range options {
648
+ opt (& opts )
649
+ }
633
650
634
651
a := & lnwire.ChannelAnnouncement1 {
635
652
ShortChannelID : lnwire.ShortChannelID {
@@ -643,27 +660,25 @@ func (ctx *testCtx) createAnnouncementWithoutProof(blockHeight uint32,
643
660
copy (a .NodeID2 [:], key2 .SerializeCompressed ())
644
661
copy (a .BitcoinKey1 [:], bitcoinKeyPub1 .SerializeCompressed ())
645
662
copy (a .BitcoinKey2 [:], bitcoinKeyPub2 .SerializeCompressed ())
646
- if len (extraBytes ) == 1 {
647
- a .ExtraOpaqueData = extraBytes [0 ]
648
- }
663
+ a .ExtraOpaqueData = opts .extraBytes
649
664
650
665
return a
651
666
}
652
667
653
668
func (ctx * testCtx ) createRemoteChannelAnnouncement (blockHeight uint32 ,
654
- extraBytes ... [] byte ) (* lnwire.ChannelAnnouncement1 , error ) {
669
+ opts ... fundingTxOption ) (* lnwire.ChannelAnnouncement1 , error ) {
655
670
656
671
return ctx .createChannelAnnouncement (
657
- blockHeight , remoteKeyPriv1 , remoteKeyPriv2 , extraBytes ... ,
672
+ blockHeight , remoteKeyPriv1 , remoteKeyPriv2 , opts ... ,
658
673
)
659
674
}
660
675
661
676
func (ctx * testCtx ) createChannelAnnouncement (blockHeight uint32 , key1 ,
662
677
key2 * btcec.PrivateKey ,
663
- extraBytes ... [] byte ) (* lnwire.ChannelAnnouncement1 , error ) {
678
+ opts ... fundingTxOption ) (* lnwire.ChannelAnnouncement1 , error ) {
664
679
665
680
a := ctx .createAnnouncementWithoutProof (
666
- blockHeight , key1 .PubKey (), key2 .PubKey (), extraBytes ... ,
681
+ blockHeight , key1 .PubKey (), key2 .PubKey (), opts ... ,
667
682
)
668
683
669
684
signer := mock.SingleSigner {Privkey : key1 }
@@ -2610,7 +2625,9 @@ func TestExtraDataChannelAnnouncementValidation(t *testing.T) {
2610
2625
// that we don't know of ourselves, but should still include in the
2611
2626
// final signature check.
2612
2627
extraBytes := []byte ("gotta validate this still!" )
2613
- ca , err := ctx .createRemoteChannelAnnouncement (0 , extraBytes )
2628
+ ca , err := ctx .createRemoteChannelAnnouncement (
2629
+ 0 , withExtraBytes (extraBytes ),
2630
+ )
2614
2631
require .NoError (t , err , "can't create channel announcement" )
2615
2632
2616
2633
// We'll now send the announcement to the main gossiper. We should be
0 commit comments