Skip to content

Commit ca032b1

Browse files
committed
multi: expose l402 id in grpc interface
This commit adds an additional field to the tokens in order to fetch the relevant l402 ids for the users tokens.
1 parent eaad220 commit ca032b1

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

cmd/loop/lsat.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package main
22

33
import (
4-
"bytes"
54
"context"
65
"encoding/hex"
76
"fmt"
87
"time"
98

10-
"github.com/lightninglabs/aperture/lsat"
119
"github.com/lightninglabs/loop/looprpc"
1210
"github.com/urfave/cli"
1311
"gopkg.in/macaroon.v2"
@@ -55,13 +53,9 @@ func listAuth(ctx *cli.Context) error {
5553
return fmt.Errorf("unable to unmarshal macaroon: %v",
5654
err)
5755
}
58-
id, err := lsat.DecodeIdentifier(bytes.NewReader(mac.Id()))
59-
if err != nil {
60-
return fmt.Errorf("unable to decode macaroon ID: %v",
61-
err)
62-
}
56+
6357
tokens[i] = &printableToken{
64-
ID: hex.EncodeToString(id.TokenID[:]),
58+
ID: t.Id,
6559
ValidUntil: "",
6660
BaseMacaroon: hex.EncodeToString(t.BaseMacaroon),
6761
PaymentHash: hex.EncodeToString(t.PaymentHash),

loopd/swapclient_server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package loopd
22

33
import (
4+
"bytes"
45
"context"
56
"encoding/hex"
67
"errors"
@@ -12,6 +13,7 @@ import (
1213
"github.com/btcsuite/btcd/btcec/v2"
1314
"github.com/btcsuite/btcd/btcutil"
1415
"github.com/btcsuite/btcd/chaincfg"
16+
"github.com/lightninglabs/aperture/lsat"
1517
"github.com/lightninglabs/lndclient"
1618
"github.com/lightninglabs/loop"
1719
"github.com/lightninglabs/loop/labels"
@@ -723,6 +725,13 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context,
723725
if err != nil {
724726
return nil, err
725727
}
728+
729+
id, err := lsat.DecodeIdentifier(
730+
bytes.NewReader(token.BaseMacaroon().Id()),
731+
)
732+
if err != nil {
733+
return nil, err
734+
}
726735
rpcTokens[idx] = &clientrpc.LsatToken{
727736
BaseMacaroon: macBytes,
728737
PaymentHash: token.PaymentHash[:],
@@ -732,6 +741,9 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context,
732741
TimeCreated: token.TimeCreated.Unix(),
733742
Expired: !token.IsValid(),
734743
StorageName: key,
744+
Id: hex.EncodeToString(
745+
id.TokenID[:],
746+
),
735747
}
736748
idx++
737749
}

looprpc/client.pb.go

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,11 @@ message LsatToken {
743743
file name of the token where it's stored on the file system.
744744
*/
745745
string storage_name = 8;
746+
747+
/*
748+
The l402 ID of the token.
749+
*/
750+
string id = 9;
746751
}
747752

748753
message LoopStats {

looprpc/client.swagger.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,10 @@
10171017
"storage_name": {
10181018
"type": "string",
10191019
"description": "Identifying attribute of this token in the store. Currently represents the\nfile name of the token where it's stored on the file system."
1020+
},
1021+
"id": {
1022+
"type": "string",
1023+
"description": "The l402 Id of the token."
10201024
}
10211025
}
10221026
},

0 commit comments

Comments
 (0)