mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
looprpc: static address summary
This commit is contained in:
parent
ab10ee972a
commit
aa7afa7f73
5 changed files with 1025 additions and 321 deletions
1064
looprpc/client.pb.go
1064
looprpc/client.pb.go
File diff suppressed because it is too large
Load diff
|
|
@ -167,6 +167,13 @@ service SwapClient {
|
|||
*/
|
||||
rpc WithdrawDeposits (WithdrawDepositsRequest)
|
||||
returns (WithdrawDepositsResponse);
|
||||
|
||||
/* loop:`static summary`
|
||||
GetStaticAddressSummary returns a summary of static address related
|
||||
statistics.
|
||||
*/
|
||||
rpc GetStaticAddressSummary (StaticAddressSummaryRequest)
|
||||
returns (StaticAddressSummaryResponse);
|
||||
}
|
||||
|
||||
message LoopOutRequest {
|
||||
|
|
@ -1569,3 +1576,127 @@ message OutPoint {
|
|||
*/
|
||||
uint32 output_index = 3;
|
||||
}
|
||||
|
||||
message StaticAddressSummaryRequest {
|
||||
/*
|
||||
Filters the list of all stored deposits by deposit state.
|
||||
*/
|
||||
DepositState state_filter = 1;
|
||||
|
||||
/*
|
||||
Filters the list of all stored deposits by the outpoint.
|
||||
*/
|
||||
repeated string outpoints = 2;
|
||||
}
|
||||
|
||||
message StaticAddressSummaryResponse {
|
||||
/*
|
||||
The static address of the client.
|
||||
*/
|
||||
string static_address = 1;
|
||||
|
||||
/*
|
||||
The total number of deposits.
|
||||
*/
|
||||
uint32 total_num_deposits = 2;
|
||||
|
||||
/*
|
||||
The total value of unconfirmed deposits.
|
||||
*/
|
||||
int64 value_unconfirmed = 3;
|
||||
|
||||
/*
|
||||
The total value of confirmed deposits.
|
||||
*/
|
||||
int64 value_deposited = 4;
|
||||
|
||||
/*
|
||||
The total value of all expired deposits.
|
||||
*/
|
||||
int64 value_expired = 5;
|
||||
|
||||
/*
|
||||
The total value of all deposits that have been withdrawn.
|
||||
*/
|
||||
int64 value_withdrawn = 6;
|
||||
|
||||
/*
|
||||
A list of all deposits that match the filtered state.
|
||||
*/
|
||||
repeated Deposit filtered_deposits = 7;
|
||||
}
|
||||
|
||||
enum DepositState {
|
||||
/*
|
||||
UNKNOWN_STATE is the default state of a deposit.
|
||||
*/
|
||||
UNKNOWN_STATE = 0;
|
||||
|
||||
/*
|
||||
DEPOSITED indicates that the deposit has been sufficiently confirmed on
|
||||
chain.
|
||||
*/
|
||||
DEPOSITED = 1;
|
||||
|
||||
/*
|
||||
WITHDRAWING indicates that the deposit is currently being withdrawn. It
|
||||
flips to WITHDRAWN once the withdrawal transaction has been sufficiently
|
||||
confirmed.
|
||||
*/
|
||||
WITHDRAWING = 2;
|
||||
|
||||
/*
|
||||
WITHDRAWN indicates that the deposit has been withdrawn.
|
||||
*/
|
||||
WITHDRAWN = 3;
|
||||
|
||||
/*
|
||||
PUBLISH_EXPIRED indicates that the deposit has expired and the sweep
|
||||
transaction has been published.
|
||||
*/
|
||||
PUBLISH_EXPIRED = 4;
|
||||
|
||||
/*
|
||||
WAIT_FOR_EXPIRY_SWEEP indicates that the deposit has expired and the sweep
|
||||
transaction has not yet been sufficiently confirmed.
|
||||
*/
|
||||
WAIT_FOR_EXPIRY_SWEEP = 5;
|
||||
|
||||
/*
|
||||
EXPIRED indicates that the deposit has expired and the sweep transaction
|
||||
has been sufficiently confirmed.
|
||||
*/
|
||||
EXPIRED = 6;
|
||||
|
||||
/*
|
||||
FAILED_STATE indicates that the deposit has failed.
|
||||
*/
|
||||
FAILED_STATE = 7;
|
||||
}
|
||||
|
||||
message Deposit {
|
||||
/*
|
||||
The identifier of the deposit.
|
||||
*/
|
||||
bytes id = 1;
|
||||
|
||||
/*
|
||||
The state of the deposit.
|
||||
*/
|
||||
DepositState state = 2;
|
||||
|
||||
/*
|
||||
The outpoint of the deposit in format txid:index.
|
||||
*/
|
||||
string outpoint = 3;
|
||||
|
||||
/*
|
||||
The value of the deposit in satoshis.
|
||||
*/
|
||||
int64 value = 4;
|
||||
|
||||
/*
|
||||
The block height at which the deposit was confirmed.
|
||||
*/
|
||||
int64 confirmation_height = 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -641,6 +641,49 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"looprpcDeposit": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "byte",
|
||||
"description": "The identifier of the deposit."
|
||||
},
|
||||
"state": {
|
||||
"$ref": "#/definitions/looprpcDepositState",
|
||||
"description": "The state of the deposit."
|
||||
},
|
||||
"outpoint": {
|
||||
"type": "string",
|
||||
"description": "The outpoint of the deposit in format txid:index."
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "The value of the deposit in satoshis."
|
||||
},
|
||||
"confirmation_height": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "The block height at which the deposit was confirmed."
|
||||
}
|
||||
}
|
||||
},
|
||||
"looprpcDepositState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UNKNOWN_STATE",
|
||||
"DEPOSITED",
|
||||
"WITHDRAWING",
|
||||
"WITHDRAWN",
|
||||
"PUBLISH_EXPIRED",
|
||||
"WAIT_FOR_EXPIRY_SWEEP",
|
||||
"EXPIRED",
|
||||
"FAILED_STATE"
|
||||
],
|
||||
"default": "UNKNOWN_STATE",
|
||||
"description": " - UNKNOWN_STATE: UNKNOWN_STATE is the default state of a deposit.\n - DEPOSITED: DEPOSITED indicates that the deposit has been sufficiently confirmed on\nchain.\n - WITHDRAWING: WITHDRAWING indicates that the deposit is currently being withdrawn. It\nflips to WITHDRAWN once the withdrawal transaction has been sufficiently\nconfirmed.\n - WITHDRAWN: WITHDRAWN indicates that the deposit has been withdrawn.\n - PUBLISH_EXPIRED: PUBLISH_EXPIRED indicates that the deposit has expired and the sweep\ntransaction has been published.\n - WAIT_FOR_EXPIRY_SWEEP: WAIT_FOR_EXPIRY_SWEEP indicates that the deposit has expired and the sweep\ntransaction has not yet been sufficiently confirmed.\n - EXPIRED: EXPIRED indicates that the deposit has expired and the sweep transaction\nhas been sufficiently confirmed.\n - FAILED_STATE: FAILED_STATE indicates that the deposit has failed."
|
||||
},
|
||||
"looprpcDisqualified": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
@ -1441,6 +1484,47 @@
|
|||
"looprpcSetLiquidityParamsResponse": {
|
||||
"type": "object"
|
||||
},
|
||||
"looprpcStaticAddressSummaryResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"static_address": {
|
||||
"type": "string",
|
||||
"description": "The static address of the client."
|
||||
},
|
||||
"total_num_deposits": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "The total number of deposits."
|
||||
},
|
||||
"value_unconfirmed": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "The total value of unconfirmed deposits."
|
||||
},
|
||||
"value_deposited": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "The total value of confirmed deposits."
|
||||
},
|
||||
"value_expired": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "The total value of all expired deposits."
|
||||
},
|
||||
"value_withdrawn": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "The total value of all deposits that have been withdrawn."
|
||||
},
|
||||
"filtered_deposits": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/looprpcDeposit"
|
||||
},
|
||||
"description": "A list of all deposits that match the filtered state."
|
||||
}
|
||||
}
|
||||
},
|
||||
"looprpcSuggestSwapsResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,10 @@ type SwapClientClient interface {
|
|||
// loop:`static withdraw`
|
||||
// WithdrawDeposits withdraws a selection or all deposits of a static address.
|
||||
WithdrawDeposits(ctx context.Context, in *WithdrawDepositsRequest, opts ...grpc.CallOption) (*WithdrawDepositsResponse, error)
|
||||
// loop:`static summary`
|
||||
// GetStaticAddressSummary returns a summary of static address related
|
||||
// statistics.
|
||||
GetStaticAddressSummary(ctx context.Context, in *StaticAddressSummaryRequest, opts ...grpc.CallOption) (*StaticAddressSummaryResponse, error)
|
||||
}
|
||||
|
||||
type swapClientClient struct {
|
||||
|
|
@ -373,6 +377,15 @@ func (c *swapClientClient) WithdrawDeposits(ctx context.Context, in *WithdrawDep
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *swapClientClient) GetStaticAddressSummary(ctx context.Context, in *StaticAddressSummaryRequest, opts ...grpc.CallOption) (*StaticAddressSummaryResponse, error) {
|
||||
out := new(StaticAddressSummaryResponse)
|
||||
err := c.cc.Invoke(ctx, "/looprpc.SwapClient/GetStaticAddressSummary", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SwapClientServer is the server API for SwapClient service.
|
||||
// All implementations must embed UnimplementedSwapClientServer
|
||||
// for forward compatibility
|
||||
|
|
@ -474,6 +487,10 @@ type SwapClientServer interface {
|
|||
// loop:`static withdraw`
|
||||
// WithdrawDeposits withdraws a selection or all deposits of a static address.
|
||||
WithdrawDeposits(context.Context, *WithdrawDepositsRequest) (*WithdrawDepositsResponse, error)
|
||||
// loop:`static summary`
|
||||
// GetStaticAddressSummary returns a summary of static address related
|
||||
// statistics.
|
||||
GetStaticAddressSummary(context.Context, *StaticAddressSummaryRequest) (*StaticAddressSummaryResponse, error)
|
||||
mustEmbedUnimplementedSwapClientServer()
|
||||
}
|
||||
|
||||
|
|
@ -556,6 +573,9 @@ func (UnimplementedSwapClientServer) ListUnspentDeposits(context.Context, *ListU
|
|||
func (UnimplementedSwapClientServer) WithdrawDeposits(context.Context, *WithdrawDepositsRequest) (*WithdrawDepositsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method WithdrawDeposits not implemented")
|
||||
}
|
||||
func (UnimplementedSwapClientServer) GetStaticAddressSummary(context.Context, *StaticAddressSummaryRequest) (*StaticAddressSummaryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetStaticAddressSummary not implemented")
|
||||
}
|
||||
func (UnimplementedSwapClientServer) mustEmbedUnimplementedSwapClientServer() {}
|
||||
|
||||
// UnsafeSwapClientServer may be embedded to opt out of forward compatibility for this service.
|
||||
|
|
@ -1022,6 +1042,24 @@ func _SwapClient_WithdrawDeposits_Handler(srv interface{}, ctx context.Context,
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SwapClient_GetStaticAddressSummary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(StaticAddressSummaryRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SwapClientServer).GetStaticAddressSummary(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/looprpc.SwapClient/GetStaticAddressSummary",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SwapClientServer).GetStaticAddressSummary(ctx, req.(*StaticAddressSummaryRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// SwapClient_ServiceDesc is the grpc.ServiceDesc for SwapClient service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
|
|
@ -1125,6 +1163,10 @@ var SwapClient_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "WithdrawDeposits",
|
||||
Handler: _SwapClient_WithdrawDeposits_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetStaticAddressSummary",
|
||||
Handler: _SwapClient_GetStaticAddressSummary_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -662,4 +662,29 @@ func RegisterSwapClientJSONCallbacks(registry map[string]func(ctx context.Contex
|
|||
}
|
||||
callback(string(respBytes), nil)
|
||||
}
|
||||
|
||||
registry["looprpc.SwapClient.GetStaticAddressSummary"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &StaticAddressSummaryRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewSwapClientClient(conn)
|
||||
resp, err := client.GetStaticAddressSummary(ctx, req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
respBytes, err := marshaler.Marshal(resp)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
callback(string(respBytes), nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue