Skip to content

Commit

Permalink
Merge pull request #601 from sputn1ck/expose_l402_id
Browse files Browse the repository at this point in the history
  • Loading branch information
sputn1ck authored Jun 22, 2023
2 parents eaad220 + ca032b1 commit 32d48d3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
10 changes: 2 additions & 8 deletions cmd/loop/lsat.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package main

import (
"bytes"
"context"
"encoding/hex"
"fmt"
"time"

"github.com/lightninglabs/aperture/lsat"
"github.com/lightninglabs/loop/looprpc"
"github.com/urfave/cli"
"gopkg.in/macaroon.v2"
Expand Down Expand Up @@ -55,13 +53,9 @@ func listAuth(ctx *cli.Context) error {
return fmt.Errorf("unable to unmarshal macaroon: %v",
err)
}
id, err := lsat.DecodeIdentifier(bytes.NewReader(mac.Id()))
if err != nil {
return fmt.Errorf("unable to decode macaroon ID: %v",
err)
}

tokens[i] = &printableToken{
ID: hex.EncodeToString(id.TokenID[:]),
ID: t.Id,
ValidUntil: "",
BaseMacaroon: hex.EncodeToString(t.BaseMacaroon),
PaymentHash: hex.EncodeToString(t.PaymentHash),
Expand Down
12 changes: 12 additions & 0 deletions loopd/swapclient_server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package loopd

import (
"bytes"
"context"
"encoding/hex"
"errors"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/lightninglabs/aperture/lsat"
"github.com/lightninglabs/lndclient"
"github.com/lightninglabs/loop"
"github.com/lightninglabs/loop/labels"
Expand Down Expand Up @@ -723,6 +725,13 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context,
if err != nil {
return nil, err
}

id, err := lsat.DecodeIdentifier(
bytes.NewReader(token.BaseMacaroon().Id()),
)
if err != nil {
return nil, err
}
rpcTokens[idx] = &clientrpc.LsatToken{
BaseMacaroon: macBytes,
PaymentHash: token.PaymentHash[:],
Expand All @@ -732,6 +741,9 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context,
TimeCreated: token.TimeCreated.Unix(),
Expired: !token.IsValid(),
StorageName: key,
Id: hex.EncodeToString(
id.TokenID[:],
),
}
idx++
}
Expand Down
15 changes: 13 additions & 2 deletions looprpc/client.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions looprpc/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,11 @@ message LsatToken {
file name of the token where it's stored on the file system.
*/
string storage_name = 8;

/*
The l402 ID of the token.
*/
string id = 9;
}

message LoopStats {
Expand Down
4 changes: 4 additions & 0 deletions looprpc/client.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,10 @@
"storage_name": {
"type": "string",
"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."
},
"id": {
"type": "string",
"description": "The l402 Id of the token."
}
}
},
Expand Down

0 comments on commit 32d48d3

Please sign in to comment.