@@ -1206,6 +1206,16 @@ func (b *Builder) processUpdate(msg interface{},
1206
1206
"chan_id=%v" , msg .ChannelID )
1207
1207
}
1208
1208
1209
+ // Look up the funding pk script so that we can register the
1210
+ // channel output in the UTXO filter.
1211
+ fundingPkScript , err := makeFundingScript (
1212
+ msg .BitcoinKey1Bytes [:], msg .BitcoinKey2Bytes [:],
1213
+ msg .Features , msg .TapscriptRoot ,
1214
+ )
1215
+ if err != nil {
1216
+ return err
1217
+ }
1218
+
1209
1219
// If AssumeChannelValid is present, then we are unable to
1210
1220
// perform any of the expensive checks below, so we'll
1211
1221
// short-circuit our path straight to adding the edge to our
@@ -1219,10 +1229,44 @@ func (b *Builder) processUpdate(msg interface{},
1219
1229
if err != nil {
1220
1230
return fmt .Errorf ("unable to add edge: %w" , err )
1221
1231
}
1222
- log .Tracef ("New channel discovered! Link " +
1223
- "connects %x and %x with ChannelID(%v)" ,
1224
- msg .NodeKey1Bytes , msg .NodeKey2Bytes ,
1225
- msg .ChannelID )
1232
+
1233
+ // Use different log levels based on channel type.
1234
+ if b .cfg .IsAlias (scid ) {
1235
+ log .Debugf ("New alias channel discovered! " +
1236
+ "Link connects %x and %x with " +
1237
+ "ChannelID(%v)" , msg .NodeKey1Bytes ,
1238
+ msg .NodeKey2Bytes ,
1239
+ msg .ChannelID )
1240
+
1241
+ // For alias channels, we make sure we add the
1242
+ // channel to the UTXO filter so that we are
1243
+ // notified if/when this channel is closed.
1244
+ // This is safe because for zeroconf we trust
1245
+ // the funding tx anyway. And for non-zeroconf
1246
+ // alias channel we would only reach this point
1247
+ // if the funding tx is confirmed.
1248
+ //
1249
+ //nolint:ll
1250
+ filterUpdate := []graphdb.EdgePoint {
1251
+ {
1252
+ FundingPkScript : fundingPkScript ,
1253
+ OutPoint : msg .ChannelPoint ,
1254
+ },
1255
+ }
1256
+ err = b .cfg .ChainView .UpdateFilter (
1257
+ filterUpdate , b .bestHeight .Load (),
1258
+ )
1259
+ if err != nil {
1260
+ return errors .Errorf ("unable to " +
1261
+ "update chain view: %v" , err )
1262
+ }
1263
+ } else {
1264
+ log .Tracef ("New channel discovered! Link " +
1265
+ "connects %x and %x with ChannelID(%v)" ,
1266
+ msg .NodeKey1Bytes , msg .NodeKey2Bytes ,
1267
+ msg .ChannelID )
1268
+ }
1269
+
1226
1270
b .stats .incNumEdgesDiscovered ()
1227
1271
1228
1272
break
@@ -1270,17 +1314,6 @@ func (b *Builder) processUpdate(msg interface{},
1270
1314
"locate funding tx: %v" , err )
1271
1315
}
1272
1316
1273
- // Recreate witness output to be sure that declared in channel
1274
- // edge bitcoin keys and channel value corresponds to the
1275
- // reality.
1276
- fundingPkScript , err := makeFundingScript (
1277
- msg .BitcoinKey1Bytes [:], msg .BitcoinKey2Bytes [:],
1278
- msg .Features , msg .TapscriptRoot ,
1279
- )
1280
- if err != nil {
1281
- return err
1282
- }
1283
-
1284
1317
// Next we'll validate that this channel is actually well
1285
1318
// formed. If this check fails, then this channel either
1286
1319
// doesn't exist, or isn't the one that was meant to be created
0 commit comments