@@ -627,9 +627,26 @@ func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate1) error {
627627 return nil
628628}
629629
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+
630642func (ctx * testCtx ) createAnnouncementWithoutProof (blockHeight uint32 ,
631643 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+ }
633650
634651 a := & lnwire.ChannelAnnouncement1 {
635652 ShortChannelID : lnwire.ShortChannelID {
@@ -643,27 +660,25 @@ func (ctx *testCtx) createAnnouncementWithoutProof(blockHeight uint32,
643660 copy (a .NodeID2 [:], key2 .SerializeCompressed ())
644661 copy (a .BitcoinKey1 [:], bitcoinKeyPub1 .SerializeCompressed ())
645662 copy (a .BitcoinKey2 [:], bitcoinKeyPub2 .SerializeCompressed ())
646- if len (extraBytes ) == 1 {
647- a .ExtraOpaqueData = extraBytes [0 ]
648- }
663+ a .ExtraOpaqueData = opts .extraBytes
649664
650665 return a
651666}
652667
653668func (ctx * testCtx ) createRemoteChannelAnnouncement (blockHeight uint32 ,
654- extraBytes ... [] byte ) (* lnwire.ChannelAnnouncement1 , error ) {
669+ opts ... fundingTxOption ) (* lnwire.ChannelAnnouncement1 , error ) {
655670
656671 return ctx .createChannelAnnouncement (
657- blockHeight , remoteKeyPriv1 , remoteKeyPriv2 , extraBytes ... ,
672+ blockHeight , remoteKeyPriv1 , remoteKeyPriv2 , opts ... ,
658673 )
659674}
660675
661676func (ctx * testCtx ) createChannelAnnouncement (blockHeight uint32 , key1 ,
662677 key2 * btcec.PrivateKey ,
663- extraBytes ... [] byte ) (* lnwire.ChannelAnnouncement1 , error ) {
678+ opts ... fundingTxOption ) (* lnwire.ChannelAnnouncement1 , error ) {
664679
665680 a := ctx .createAnnouncementWithoutProof (
666- blockHeight , key1 .PubKey (), key2 .PubKey (), extraBytes ... ,
681+ blockHeight , key1 .PubKey (), key2 .PubKey (), opts ... ,
667682 )
668683
669684 signer := mock.SingleSigner {Privkey : key1 }
@@ -2610,7 +2625,9 @@ func TestExtraDataChannelAnnouncementValidation(t *testing.T) {
26102625 // that we don't know of ourselves, but should still include in the
26112626 // final signature check.
26122627 extraBytes := []byte ("gotta validate this still!" )
2613- ca , err := ctx .createRemoteChannelAnnouncement (0 , extraBytes )
2628+ ca , err := ctx .createRemoteChannelAnnouncement (
2629+ 0 , withExtraBytes (extraBytes ),
2630+ )
26142631 require .NoError (t , err , "can't create channel announcement" )
26152632
26162633 // We'll now send the announcement to the main gossiper. We should be
0 commit comments