walletrpc: add list sweeps to rpc and cli

This commit is contained in:
carla 2020-05-05 21:34:38 +02:00
parent 99a45e968a
commit f3212057dd
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91
6 changed files with 481 additions and 97 deletions

@ -27,6 +27,7 @@ func walletCommands() []cli.Command {
pendingSweepsCommand, pendingSweepsCommand,
bumpFeeCommand, bumpFeeCommand,
bumpCloseFeeCommand, bumpCloseFeeCommand,
listSweepsCommand,
}, },
}, },
} }
@ -300,3 +301,42 @@ func getWaitingCloseCommitments(client lnrpc.LightningClient,
return nil, errors.New("channel not found") return nil, errors.New("channel not found")
} }
var listSweepsCommand = cli.Command{
Name: "listsweeps",
Category: "On-chain",
Usage: "Lists all sweeps that have been published by our node.",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "verbose",
Usage: "lookup full transaction",
},
},
Description: `
Get a list of the hex-encoded transaction ids of every sweep that our
node has published. Note that these sweeps may not be confirmed on chain
yet, as we store them on transaction broadcast, not confirmation.
If the verbose flag is set, the full set of transactions will be
returned, otherwise only the sweep transaction ids will be returned.
`,
Action: actionDecorator(listSweeps),
}
func listSweeps(ctx *cli.Context) error {
client, cleanUp := getWalletClient(ctx)
defer cleanUp()
resp, err := client.ListSweeps(
context.Background(), &walletrpc.ListSweepsRequest{
Verbose: ctx.IsSet("verbose"),
},
)
if err != nil {
return err
}
printJSON(resp)
return nil
}

53
lnrpc/rpc_utils.go Normal file

@ -0,0 +1,53 @@
package lnrpc
import (
"encoding/hex"
"sort"
"github.com/lightningnetwork/lnd/lnwallet"
)
// RPCTransactionDetails returns a set of rpc transaction details.
func RPCTransactionDetails(txns []*lnwallet.TransactionDetail) *TransactionDetails {
txDetails := &TransactionDetails{
Transactions: make([]*Transaction, len(txns)),
}
for i, tx := range txns {
var destAddresses []string
for _, destAddress := range tx.DestAddresses {
destAddresses = append(destAddresses, destAddress.EncodeAddress())
}
// We also get unconfirmed transactions, so BlockHash can be
// nil.
blockHash := ""
if tx.BlockHash != nil {
blockHash = tx.BlockHash.String()
}
txDetails.Transactions[i] = &Transaction{
TxHash: tx.Hash.String(),
Amount: int64(tx.Value),
NumConfirmations: tx.NumConfirmations,
BlockHash: blockHash,
BlockHeight: tx.BlockHeight,
TimeStamp: tx.Timestamp,
TotalFees: tx.TotalFees,
DestAddresses: destAddresses,
RawTxHex: hex.EncodeToString(tx.RawTx),
}
}
// Sort transactions by number of confirmations rather than height so
// that unconfirmed transactions (height =0; confirmations =-1) will
// follow the most recently set of confirmed transactions. If we sort
// by height, unconfirmed transactions will follow our oldest
// transactions, because they have lower block heights.
sort.Slice(txDetails.Transactions, func(i, j int) bool {
return txDetails.Transactions[i].NumConfirmations <
txDetails.Transactions[j].NumConfirmations
})
return txDetails
}

@ -813,6 +813,171 @@ func (m *BumpFeeResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_BumpFeeResponse proto.InternalMessageInfo var xxx_messageInfo_BumpFeeResponse proto.InternalMessageInfo
type ListSweepsRequest struct {
//
//Retrieve the full sweep transaction details. If false, only the sweep txids
//will be returned.
Verbose bool `protobuf:"varint,1,opt,name=verbose,proto3" json:"verbose,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ListSweepsRequest) Reset() { *m = ListSweepsRequest{} }
func (m *ListSweepsRequest) String() string { return proto.CompactTextString(m) }
func (*ListSweepsRequest) ProtoMessage() {}
func (*ListSweepsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_6cc6942ac78249e5, []int{14}
}
func (m *ListSweepsRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ListSweepsRequest.Unmarshal(m, b)
}
func (m *ListSweepsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ListSweepsRequest.Marshal(b, m, deterministic)
}
func (m *ListSweepsRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListSweepsRequest.Merge(m, src)
}
func (m *ListSweepsRequest) XXX_Size() int {
return xxx_messageInfo_ListSweepsRequest.Size(m)
}
func (m *ListSweepsRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ListSweepsRequest.DiscardUnknown(m)
}
var xxx_messageInfo_ListSweepsRequest proto.InternalMessageInfo
func (m *ListSweepsRequest) GetVerbose() bool {
if m != nil {
return m.Verbose
}
return false
}
type ListSweepsResponse struct {
// Types that are valid to be assigned to Sweeps:
// *ListSweepsResponse_TransactionDetails
// *ListSweepsResponse_TransactionIds
Sweeps isListSweepsResponse_Sweeps `protobuf_oneof:"sweeps"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ListSweepsResponse) Reset() { *m = ListSweepsResponse{} }
func (m *ListSweepsResponse) String() string { return proto.CompactTextString(m) }
func (*ListSweepsResponse) ProtoMessage() {}
func (*ListSweepsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_6cc6942ac78249e5, []int{15}
}
func (m *ListSweepsResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ListSweepsResponse.Unmarshal(m, b)
}
func (m *ListSweepsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ListSweepsResponse.Marshal(b, m, deterministic)
}
func (m *ListSweepsResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListSweepsResponse.Merge(m, src)
}
func (m *ListSweepsResponse) XXX_Size() int {
return xxx_messageInfo_ListSweepsResponse.Size(m)
}
func (m *ListSweepsResponse) XXX_DiscardUnknown() {
xxx_messageInfo_ListSweepsResponse.DiscardUnknown(m)
}
var xxx_messageInfo_ListSweepsResponse proto.InternalMessageInfo
type isListSweepsResponse_Sweeps interface {
isListSweepsResponse_Sweeps()
}
type ListSweepsResponse_TransactionDetails struct {
TransactionDetails *lnrpc.TransactionDetails `protobuf:"bytes,1,opt,name=transaction_details,json=transactionDetails,proto3,oneof"`
}
type ListSweepsResponse_TransactionIds struct {
TransactionIds *ListSweepsResponse_TransactionIDs `protobuf:"bytes,2,opt,name=transaction_ids,json=transactionIds,proto3,oneof"`
}
func (*ListSweepsResponse_TransactionDetails) isListSweepsResponse_Sweeps() {}
func (*ListSweepsResponse_TransactionIds) isListSweepsResponse_Sweeps() {}
func (m *ListSweepsResponse) GetSweeps() isListSweepsResponse_Sweeps {
if m != nil {
return m.Sweeps
}
return nil
}
func (m *ListSweepsResponse) GetTransactionDetails() *lnrpc.TransactionDetails {
if x, ok := m.GetSweeps().(*ListSweepsResponse_TransactionDetails); ok {
return x.TransactionDetails
}
return nil
}
func (m *ListSweepsResponse) GetTransactionIds() *ListSweepsResponse_TransactionIDs {
if x, ok := m.GetSweeps().(*ListSweepsResponse_TransactionIds); ok {
return x.TransactionIds
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*ListSweepsResponse) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*ListSweepsResponse_TransactionDetails)(nil),
(*ListSweepsResponse_TransactionIds)(nil),
}
}
type ListSweepsResponse_TransactionIDs struct {
//
//Reversed, hex-encoded string representing the transaction ids of the
//sweeps that our node has broadcast. Note that these transactions may
//not have confirmed yet, we record sweeps on broadcast, not confirmation.
TransactionIds []string `protobuf:"bytes,1,rep,name=transaction_ids,json=transactionIds,proto3" json:"transaction_ids,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ListSweepsResponse_TransactionIDs) Reset() { *m = ListSweepsResponse_TransactionIDs{} }
func (m *ListSweepsResponse_TransactionIDs) String() string { return proto.CompactTextString(m) }
func (*ListSweepsResponse_TransactionIDs) ProtoMessage() {}
func (*ListSweepsResponse_TransactionIDs) Descriptor() ([]byte, []int) {
return fileDescriptor_6cc6942ac78249e5, []int{15, 0}
}
func (m *ListSweepsResponse_TransactionIDs) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ListSweepsResponse_TransactionIDs.Unmarshal(m, b)
}
func (m *ListSweepsResponse_TransactionIDs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ListSweepsResponse_TransactionIDs.Marshal(b, m, deterministic)
}
func (m *ListSweepsResponse_TransactionIDs) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListSweepsResponse_TransactionIDs.Merge(m, src)
}
func (m *ListSweepsResponse_TransactionIDs) XXX_Size() int {
return xxx_messageInfo_ListSweepsResponse_TransactionIDs.Size(m)
}
func (m *ListSweepsResponse_TransactionIDs) XXX_DiscardUnknown() {
xxx_messageInfo_ListSweepsResponse_TransactionIDs.DiscardUnknown(m)
}
var xxx_messageInfo_ListSweepsResponse_TransactionIDs proto.InternalMessageInfo
func (m *ListSweepsResponse_TransactionIDs) GetTransactionIds() []string {
if m != nil {
return m.TransactionIds
}
return nil
}
func init() { func init() {
proto.RegisterEnum("walletrpc.WitnessType", WitnessType_name, WitnessType_value) proto.RegisterEnum("walletrpc.WitnessType", WitnessType_name, WitnessType_value)
proto.RegisterType((*KeyReq)(nil), "walletrpc.KeyReq") proto.RegisterType((*KeyReq)(nil), "walletrpc.KeyReq")
@ -829,78 +994,89 @@ func init() {
proto.RegisterType((*PendingSweepsResponse)(nil), "walletrpc.PendingSweepsResponse") proto.RegisterType((*PendingSweepsResponse)(nil), "walletrpc.PendingSweepsResponse")
proto.RegisterType((*BumpFeeRequest)(nil), "walletrpc.BumpFeeRequest") proto.RegisterType((*BumpFeeRequest)(nil), "walletrpc.BumpFeeRequest")
proto.RegisterType((*BumpFeeResponse)(nil), "walletrpc.BumpFeeResponse") proto.RegisterType((*BumpFeeResponse)(nil), "walletrpc.BumpFeeResponse")
proto.RegisterType((*ListSweepsRequest)(nil), "walletrpc.ListSweepsRequest")
proto.RegisterType((*ListSweepsResponse)(nil), "walletrpc.ListSweepsResponse")
proto.RegisterType((*ListSweepsResponse_TransactionIDs)(nil), "walletrpc.ListSweepsResponse.TransactionIDs")
} }
func init() { proto.RegisterFile("walletrpc/walletkit.proto", fileDescriptor_6cc6942ac78249e5) } func init() { proto.RegisterFile("walletrpc/walletkit.proto", fileDescriptor_6cc6942ac78249e5) }
var fileDescriptor_6cc6942ac78249e5 = []byte{ var fileDescriptor_6cc6942ac78249e5 = []byte{
// 1055 bytes of a gzipped FileDescriptorProto // 1180 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x6b, 0x6f, 0xe2, 0x46, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x6d, 0x6f, 0xe2, 0x46,
0x14, 0x2d, 0x21, 0x21, 0x70, 0x81, 0xc4, 0x19, 0xf2, 0xf0, 0xb2, 0xd9, 0x86, 0xba, 0x0f, 0xa1, 0x10, 0x3e, 0x42, 0x42, 0x60, 0x78, 0x09, 0x59, 0xf2, 0xe2, 0xe3, 0x72, 0x0d, 0x75, 0xdf, 0xa2,
0x3e, 0x40, 0x4d, 0xd4, 0xaa, 0x0f, 0xa9, 0x2a, 0x21, 0x8e, 0x88, 0x20, 0x98, 0xda, 0xce, 0x46, 0xf6, 0x8e, 0xa8, 0x39, 0xb5, 0xea, 0xb5, 0x52, 0xd5, 0x04, 0x1c, 0x11, 0x41, 0x70, 0x6a, 0xfb,
0x5b, 0x55, 0x1a, 0x39, 0x30, 0x21, 0x56, 0xc0, 0xf6, 0x8e, 0x87, 0x02, 0x7f, 0xa4, 0xd2, 0xfe, 0x2e, 0xba, 0xaa, 0xd2, 0xca, 0xe0, 0x0d, 0xb1, 0x02, 0xb6, 0x6f, 0xbd, 0x1c, 0xf0, 0xad, 0xdf,
0x95, 0xfe, 0xba, 0xca, 0xe3, 0x07, 0x63, 0x68, 0x2a, 0xf5, 0x53, 0xf0, 0x39, 0xe7, 0x1e, 0xdf, 0xfa, 0x0f, 0x2a, 0xdd, 0xbf, 0xad, 0xbc, 0x7e, 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 0x24, 0x3f, 0xb9, 0xf8, 0xfe, 0x8f, 0xd3, 0x91, 0xcd, 0xee, 0xa7, 0x83, 0xe6,
0xd0, 0x9d, 0x9c, 0x8e, 0x83, 0x3d, 0xe8, 0xd8, 0xce, 0xc8, 0x21, 0x6c, 0xe6, 0xd2, 0x87, 0xd3,
0xb1, 0x63, 0x9d, 0xf2, 0xa9, 0x78, 0x9a, 0xe8, 0x0c, 0x72, 0xfc, 0xdf, 0xc4, 0x57, 0xff, 0x06,
0x00, 0x00, 0xff, 0xff, 0xe6, 0xc9, 0x1c, 0x56, 0x6f, 0x0a, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
@ -980,6 +1156,11 @@ type WalletKitClient interface {
//fee preference being provided. For now, the responsibility of ensuring that //fee preference being provided. For now, the responsibility of ensuring that
//the new fee preference is sufficient is delegated to the user. //the new fee preference is sufficient is delegated to the user.
BumpFee(ctx context.Context, in *BumpFeeRequest, opts ...grpc.CallOption) (*BumpFeeResponse, error) BumpFee(ctx context.Context, in *BumpFeeRequest, opts ...grpc.CallOption) (*BumpFeeResponse, error)
//*
//ListSweeps returns a list of the sweep transactions our node has produced.
//Note that these sweeps may not be confirmed yet, as we record sweeps on
//broadcast, not confirmation.
ListSweeps(ctx context.Context, in *ListSweepsRequest, opts ...grpc.CallOption) (*ListSweepsResponse, error)
} }
type walletKitClient struct { type walletKitClient struct {
@ -1062,6 +1243,15 @@ func (c *walletKitClient) BumpFee(ctx context.Context, in *BumpFeeRequest, opts
return out, nil return out, nil
} }
func (c *walletKitClient) ListSweeps(ctx context.Context, in *ListSweepsRequest, opts ...grpc.CallOption) (*ListSweepsResponse, error) {
out := new(ListSweepsResponse)
err := c.cc.Invoke(ctx, "/walletrpc.WalletKit/ListSweeps", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// WalletKitServer is the server API for WalletKit service. // WalletKitServer is the server API for WalletKit service.
type WalletKitServer interface { type WalletKitServer interface {
//* //*
@ -1129,6 +1319,11 @@ type WalletKitServer interface {
//fee preference being provided. For now, the responsibility of ensuring that //fee preference being provided. For now, the responsibility of ensuring that
//the new fee preference is sufficient is delegated to the user. //the new fee preference is sufficient is delegated to the user.
BumpFee(context.Context, *BumpFeeRequest) (*BumpFeeResponse, error) BumpFee(context.Context, *BumpFeeRequest) (*BumpFeeResponse, error)
//*
//ListSweeps returns a list of the sweep transactions our node has produced.
//Note that these sweeps may not be confirmed yet, as we record sweeps on
//broadcast, not confirmation.
ListSweeps(context.Context, *ListSweepsRequest) (*ListSweepsResponse, error)
} }
func RegisterWalletKitServer(s *grpc.Server, srv WalletKitServer) { func RegisterWalletKitServer(s *grpc.Server, srv WalletKitServer) {
@ -1279,6 +1474,24 @@ func _WalletKit_BumpFee_Handler(srv interface{}, ctx context.Context, dec func(i
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _WalletKit_ListSweeps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListSweepsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WalletKitServer).ListSweeps(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/walletrpc.WalletKit/ListSweeps",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WalletKitServer).ListSweeps(ctx, req.(*ListSweepsRequest))
}
return interceptor(ctx, in, info, handler)
}
var _WalletKit_serviceDesc = grpc.ServiceDesc{ var _WalletKit_serviceDesc = grpc.ServiceDesc{
ServiceName: "walletrpc.WalletKit", ServiceName: "walletrpc.WalletKit",
HandlerType: (*WalletKitServer)(nil), HandlerType: (*WalletKitServer)(nil),
@ -1315,6 +1528,10 @@ var _WalletKit_serviceDesc = grpc.ServiceDesc{
MethodName: "BumpFee", MethodName: "BumpFee",
Handler: _WalletKit_BumpFee_Handler, Handler: _WalletKit_BumpFee_Handler,
}, },
{
MethodName: "ListSweeps",
Handler: _WalletKit_ListSweeps_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "walletrpc/walletkit.proto", Metadata: "walletrpc/walletkit.proto",

@ -244,6 +244,31 @@ message BumpFeeRequest {
message BumpFeeResponse { message BumpFeeResponse {
} }
message ListSweepsRequest {
/*
Retrieve the full sweep transaction details. If false, only the sweep txids
will be returned.
*/
bool verbose = 1;
}
message ListSweepsResponse {
message TransactionIDs {
/*
Reversed, hex-encoded string representing the transaction ids of the
sweeps that our node has broadcast. Note that these transactions may
not have confirmed yet, we record sweeps on broadcast, not confirmation.
*/
repeated string transaction_ids = 1;
}
oneof sweeps {
lnrpc.TransactionDetails transaction_details = 1;
TransactionIDs transaction_ids = 2;
}
}
service WalletKit { service WalletKit {
/** /**
DeriveNextKey attempts to derive the *next* key within the key family DeriveNextKey attempts to derive the *next* key within the key family
@ -325,4 +350,13 @@ service WalletKit {
the new fee preference is sufficient is delegated to the user. the new fee preference is sufficient is delegated to the user.
*/ */
rpc BumpFee (BumpFeeRequest) returns (BumpFeeResponse); rpc BumpFee (BumpFeeRequest) returns (BumpFeeResponse);
/**
ListSweeps returns a list of the sweep transactions our node has produced.
Note that these sweeps may not be confirmed yet, as we record sweeps on
broadcast, not confirmation.
*/
rpc ListSweeps (ListSweepsRequest) returns (ListSweepsResponse) {}
} }

@ -19,6 +19,7 @@ import (
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/signrpc" "github.com/lightningnetwork/lnd/lnrpc/signrpc"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/sweep" "github.com/lightningnetwork/lnd/sweep"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -88,6 +89,10 @@ var (
Entity: "onchain", Entity: "onchain",
Action: "write", Action: "write",
}}, }},
"/walletrpc.WalletKit/ListSweeps": {{
Entity: "onchain",
Action: "read",
}},
} }
// DefaultWalletKitMacFilename is the default name of the wallet kit // DefaultWalletKitMacFilename is the default name of the wallet kit
@ -555,3 +560,67 @@ func (w *WalletKit) BumpFee(ctx context.Context,
return &BumpFeeResponse{}, nil return &BumpFeeResponse{}, nil
} }
// ListSweeps returns a list of the sweeps that our node has published.
func (w *WalletKit) ListSweeps(ctx context.Context,
in *ListSweepsRequest) (*ListSweepsResponse, error) {
sweeps, err := w.cfg.Sweeper.ListSweeps()
if err != nil {
return nil, err
}
sweepTxns := make(map[string]bool)
txids := make([]string, len(sweeps))
for i, sweep := range sweeps {
sweepTxns[sweep.String()] = true
txids[i] = sweep.String()
}
// If the caller does not want verbose output, just return the set of
// sweep txids.
if !in.Verbose {
txidResp := &ListSweepsResponse_TransactionIDs{
TransactionIds: txids,
}
return &ListSweepsResponse{
Sweeps: &ListSweepsResponse_TransactionIds{
TransactionIds: txidResp,
},
}, nil
}
// If the caller does want full transaction lookups, query our wallet
// for all transactions, including unconfirmed transactions.
transactions, err := w.cfg.Wallet.ListTransactionDetails(
0, btcwallet.UnconfirmedHeight,
)
if err != nil {
return nil, err
}
var sweepTxDetails []*lnwallet.TransactionDetail
for _, tx := range transactions {
_, ok := sweepTxns[tx.Hash.String()]
if !ok {
continue
}
sweepTxDetails = append(sweepTxDetails, tx)
}
// Fail if we have not retrieved all of our sweep transactions from the
// wallet.
if len(sweepTxDetails) != len(txids) {
return nil, fmt.Errorf("not all sweeps found by list "+
"transactions: %v, %v", len(sweepTxDetails), len(txids))
}
return &ListSweepsResponse{
Sweeps: &ListSweepsResponse_TransactionDetails{
TransactionDetails: lnrpc.RPCTransactionDetails(transactions),
},
}, nil
}

@ -4568,36 +4568,7 @@ func (r *rpcServer) GetTransactions(ctx context.Context,
return nil, err return nil, err
} }
txDetails := &lnrpc.TransactionDetails{ return lnrpc.RPCTransactionDetails(transactions), nil
Transactions: make([]*lnrpc.Transaction, len(transactions)),
}
for i, tx := range transactions {
var destAddresses []string
for _, destAddress := range tx.DestAddresses {
destAddresses = append(destAddresses, destAddress.EncodeAddress())
}
// We also get unconfirmed transactions, so BlockHash can be
// nil.
blockHash := ""
if tx.BlockHash != nil {
blockHash = tx.BlockHash.String()
}
txDetails.Transactions[i] = &lnrpc.Transaction{
TxHash: tx.Hash.String(),
Amount: int64(tx.Value),
NumConfirmations: tx.NumConfirmations,
BlockHash: blockHash,
BlockHeight: tx.BlockHeight,
TimeStamp: tx.Timestamp,
TotalFees: tx.TotalFees,
DestAddresses: destAddresses,
RawTxHex: hex.EncodeToString(tx.RawTx),
}
}
return txDetails, nil
} }
// DescribeGraph returns a description of the latest graph state from the PoV // DescribeGraph returns a description of the latest graph state from the PoV