6060 // value: time || rawSwapState
6161 contractKey = []byte ("contract" )
6262
63+ // labelKey is the key that stores an optional label for the swap. If
64+ // a swap was created before we started adding labels, or was created
65+ // without a label, this key will not be present.
66+ //
67+ // path: loopInBucket/loopOutBucket -> swapBucket[hash] -> labelKey
68+ //
69+ // value: string label
70+ labelKey = []byte ("label" )
71+
6372 // outgoingChanSetKey is the key that stores a list of channel ids that
6473 // restrict the loop out swap payment.
6574 //
@@ -207,6 +216,9 @@ func (s *boltSwapStore) FetchLoopOutSwaps() ([]*LoopOut, error) {
207216 return err
208217 }
209218
219+ // Get our label for this swap, if it is present.
220+ contract .Label = getLabel (swapBucket )
221+
210222 // Read the list of concatenated outgoing channel ids
211223 // that form the outgoing set.
212224 setBytes := swapBucket .Get (outgoingChanSetKey )
@@ -352,6 +364,9 @@ func (s *boltSwapStore) FetchLoopInSwaps() ([]*LoopIn, error) {
352364 return err
353365 }
354366
367+ // Get our label for this swap, if it is present.
368+ contract .Label = getLabel (swapBucket )
369+
355370 updates , err := deserializeUpdates (swapBucket )
356371 if err != nil {
357372 return err
@@ -434,6 +449,10 @@ func (s *boltSwapStore) CreateLoopOut(hash lntypes.Hash,
434449 return err
435450 }
436451
452+ if err := putLabel (swapBucket , swap .Label ); err != nil {
453+ return err
454+ }
455+
437456 // Write the outgoing channel set.
438457 var b bytes.Buffer
439458 for _ , chanID := range swap .OutgoingChanSet {
@@ -447,6 +466,11 @@ func (s *boltSwapStore) CreateLoopOut(hash lntypes.Hash,
447466 return err
448467 }
449468
469+ // Write label to disk if we have one.
470+ if err := putLabel (swapBucket , swap .Label ); err != nil {
471+ return err
472+ }
473+
450474 // Finally, we'll create an empty updates bucket for this swap
451475 // to track any future updates to the swap itself.
452476 _ , err = swapBucket .CreateBucket (updatesBucketKey )
@@ -485,6 +509,11 @@ func (s *boltSwapStore) CreateLoopIn(hash lntypes.Hash,
485509 return err
486510 }
487511
512+ // Write label to disk if we have one.
513+ if err := putLabel (swapBucket , swap .Label ); err != nil {
514+ return err
515+ }
516+
488517 // Finally, we'll create an empty updates bucket for this swap
489518 // to track any future updates to the swap itself.
490519 _ , err = swapBucket .CreateBucket (updatesBucketKey )
0 commit comments