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.
pull/601/head
sputn1ck 10 months ago
parent eaad220800
commit ca032b1f1d
No known key found for this signature in database
GPG Key ID: 671103D881A5F0E4

@ -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"
@ -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),

@ -1,6 +1,7 @@
package loopd
import (
"bytes"
"context"
"encoding/hex"
"errors"
@ -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"
@ -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[:],
@ -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++
}

@ -1984,6 +1984,9 @@ type LsatToken struct {
//Identifying attribute of this token in the store. Currently represents the
//file name of the token where it's stored on the file system.
StorageName string `protobuf:"bytes,8,opt,name=storage_name,json=storageName,proto3" json:"storage_name,omitempty"`
//
//The l402 Id of the token.
Id string `protobuf:"bytes,9,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *LsatToken) Reset() {
@ -2074,6 +2077,13 @@ func (x *LsatToken) GetStorageName() string {
return ""
}
func (x *LsatToken) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type LoopStats struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -3233,7 +3243,7 @@ var file_client_proto_rawDesc = []byte{
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x2e,
0x4c, 0x73, 0x61, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x06, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
0x73, 0x22, 0xbb, 0x02, 0x0a, 0x09, 0x4c, 0x73, 0x61, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12,
0x73, 0x22, 0xcb, 0x02, 0x0a, 0x09, 0x4c, 0x73, 0x61, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12,
0x23, 0x0a, 0x0d, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x4d, 0x61, 0x63, 0x61,
0x72, 0x6f, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f,
@ -3252,7 +3262,8 @@ var file_client_proto_rawDesc = []byte{
0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x18, 0x07, 0x20,
0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x12, 0x21, 0x0a, 0x0c,
0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22,
0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12,
0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22,
0xc8, 0x01, 0x0a, 0x09, 0x4c, 0x6f, 0x6f, 0x70, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x23, 0x0a,
0x0d, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01,
0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x75,

@ -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 {

@ -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."
}
}
},

Loading…
Cancel
Save