@@ -340,6 +340,59 @@ func (m *Manager) DeleteSixConfs(baseScid lnwire.ShortChannelID) error {
340340 return nil
341341}
342342
343+ // DeleteLocalAlias removes a mapping from the database and the Manager's maps.
344+ func (m * Manager ) DeleteLocalAlias (alias ,
345+ baseScid lnwire.ShortChannelID ) error {
346+
347+ m .Lock ()
348+ defer m .Unlock ()
349+
350+ err := kvdb .Update (m .backend , func (tx kvdb.RwTx ) error {
351+ aliasToBaseBucket , err := tx .CreateTopLevelBucket (aliasBucket )
352+ if err != nil {
353+ return err
354+ }
355+
356+ var aliasBytes [8 ]byte
357+ byteOrder .PutUint64 (aliasBytes [:], alias .ToUint64 ())
358+
359+ return aliasToBaseBucket .Delete (aliasBytes [:])
360+ }, func () {})
361+ if err != nil {
362+ return err
363+ }
364+
365+ // Now that the database state has been updated, we'll delete the
366+ // mapping from the Manager's maps.
367+ aliasSet , ok := m .baseToSet [baseScid ]
368+ if ! ok {
369+ return nil
370+ }
371+
372+ // We'll iterate through the alias set and remove the alias from the
373+ // set.
374+ for i , a := range aliasSet {
375+ if a .ToUint64 () == alias .ToUint64 () {
376+ aliasSet = append (aliasSet [:i ], aliasSet [i + 1 :]... )
377+ break
378+ }
379+ }
380+
381+ // If the alias set is empty, we'll delete the base SCID from the
382+ // baseToSet map.
383+ if len (aliasSet ) == 0 {
384+ delete (m .baseToSet , baseScid )
385+ } else {
386+ m .baseToSet [baseScid ] = aliasSet
387+ }
388+
389+ // Finally, we'll delete the aliasToBase mapping from the Manager's
390+ // cache.
391+ delete (m .aliasToBase , alias )
392+
393+ return nil
394+ }
395+
343396// PutPeerAlias stores the peer's alias SCID once we learn of it in the
344397// channel_ready message.
345398func (m * Manager ) PutPeerAlias (chanID lnwire.ChannelID ,
0 commit comments