looprpc: add ListStaticAddressWithdrawals for historic withdrawal information

This commit is contained in:
Slyghtning 2025-05-13 11:34:02 +02:00
parent 94aeae81ed
commit cd9bcdf6f7
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
6 changed files with 1048 additions and 617 deletions

File diff suppressed because it is too large Load diff

View file

@ -175,6 +175,12 @@ service SwapClient {
rpc ListStaticAddressDeposits (ListStaticAddressDepositsRequest)
returns (ListStaticAddressDepositsResponse);
/* loop:`listwithdrawals`
ListStaticAddressWithdrawals returns a list of static address withdrawals.
*/
rpc ListStaticAddressWithdrawals (ListStaticAddressWithdrawalRequest)
returns (ListStaticAddressWithdrawalResponse);
/* loop:`listswaps`
ListStaticAddressSwaps returns a list of filtered static address
swaps.
@ -1735,6 +1741,16 @@ message ListStaticAddressDepositsResponse {
repeated Deposit filtered_deposits = 1;
}
message ListStaticAddressWithdrawalRequest {
}
message ListStaticAddressWithdrawalResponse {
/*
A list of all static address withdrawals.
*/
repeated StaticAddressWithdrawal withdrawals = 1;
}
message ListStaticAddressSwapsRequest {
}
@ -1896,6 +1912,40 @@ message Deposit {
int64 blocks_until_expiry = 6;
}
message StaticAddressWithdrawal {
/*
The transaction id of the withdrawal transaction.
*/
string tx_id = 1;
/*
The selected deposits that is withdrawn from.
*/
repeated Deposit deposits = 2;
/*
The sum of the deposit values that was selected for withdrawal.
*/
int64 total_deposit_amount_satoshis = 3;
/*
The actual amount that was withdrawn from the selected deposits. This value
represents the sum of selected deposit values minus tx fees minus optional
change output.
*/
int64 withdrawn_amount_satoshis = 4;
/*
An optional change.
*/
int64 change_amount_satoshis = 5;
/*
The confirmation block height of the withdrawal transaction.
*/
uint32 confirmation_height = 6;
}
message StaticAddressLoopInSwap {
/*
The swap hash of the swap. It represents the unique identifier of the swap.

View file

@ -1392,6 +1392,18 @@
}
}
},
"looprpcListStaticAddressWithdrawalResponse": {
"type": "object",
"properties": {
"withdrawals": {
"type": "array",
"items": {
"$ref": "#/definitions/looprpcStaticAddressWithdrawal"
},
"description": "A list of all static address withdrawals."
}
}
},
"looprpcListSwapsFilter": {
"type": "object",
"properties": {
@ -1927,6 +1939,42 @@
}
}
},
"looprpcStaticAddressWithdrawal": {
"type": "object",
"properties": {
"tx_id": {
"type": "string",
"description": "The transaction id of the withdrawal transaction."
},
"deposits": {
"type": "array",
"items": {
"$ref": "#/definitions/looprpcDeposit"
},
"description": "The selected deposits that is withdrawn from."
},
"total_deposit_amount_satoshis": {
"type": "string",
"format": "int64",
"description": "The sum of the deposit values that was selected for withdrawal."
},
"withdrawn_amount_satoshis": {
"type": "string",
"format": "int64",
"description": "The actual amount that was withdrawn from the selected deposits. This value\nrepresents the sum of selected deposit values minus tx fees minus optional\nchange output."
},
"change_amount_satoshis": {
"type": "string",
"format": "int64",
"description": "An optional change."
},
"confirmation_height": {
"type": "integer",
"format": "int64",
"description": "The confirmation block height of the withdrawal transaction."
}
}
},
"looprpcSuggestSwapsResponse": {
"type": "object",
"properties": {

View file

@ -119,6 +119,9 @@ type SwapClientClient interface {
// ListStaticAddressDeposits returns a list of filtered static address
// deposits.
ListStaticAddressDeposits(ctx context.Context, in *ListStaticAddressDepositsRequest, opts ...grpc.CallOption) (*ListStaticAddressDepositsResponse, error)
// loop:`listwithdrawals`
// ListStaticAddressWithdrawals returns a list of static address withdrawals.
ListStaticAddressWithdrawals(ctx context.Context, in *ListStaticAddressWithdrawalRequest, opts ...grpc.CallOption) (*ListStaticAddressWithdrawalResponse, error)
// loop:`listswaps`
// ListStaticAddressSwaps returns a list of filtered static address
// swaps.
@ -397,6 +400,15 @@ func (c *swapClientClient) ListStaticAddressDeposits(ctx context.Context, in *Li
return out, nil
}
func (c *swapClientClient) ListStaticAddressWithdrawals(ctx context.Context, in *ListStaticAddressWithdrawalRequest, opts ...grpc.CallOption) (*ListStaticAddressWithdrawalResponse, error) {
out := new(ListStaticAddressWithdrawalResponse)
err := c.cc.Invoke(ctx, "/looprpc.SwapClient/ListStaticAddressWithdrawals", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *swapClientClient) ListStaticAddressSwaps(ctx context.Context, in *ListStaticAddressSwapsRequest, opts ...grpc.CallOption) (*ListStaticAddressSwapsResponse, error) {
out := new(ListStaticAddressSwapsResponse)
err := c.cc.Invoke(ctx, "/looprpc.SwapClient/ListStaticAddressSwaps", in, out, opts...)
@ -529,6 +541,9 @@ type SwapClientServer interface {
// ListStaticAddressDeposits returns a list of filtered static address
// deposits.
ListStaticAddressDeposits(context.Context, *ListStaticAddressDepositsRequest) (*ListStaticAddressDepositsResponse, error)
// loop:`listwithdrawals`
// ListStaticAddressWithdrawals returns a list of static address withdrawals.
ListStaticAddressWithdrawals(context.Context, *ListStaticAddressWithdrawalRequest) (*ListStaticAddressWithdrawalResponse, error)
// loop:`listswaps`
// ListStaticAddressSwaps returns a list of filtered static address
// swaps.
@ -625,6 +640,9 @@ func (UnimplementedSwapClientServer) WithdrawDeposits(context.Context, *Withdraw
func (UnimplementedSwapClientServer) ListStaticAddressDeposits(context.Context, *ListStaticAddressDepositsRequest) (*ListStaticAddressDepositsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListStaticAddressDeposits not implemented")
}
func (UnimplementedSwapClientServer) ListStaticAddressWithdrawals(context.Context, *ListStaticAddressWithdrawalRequest) (*ListStaticAddressWithdrawalResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListStaticAddressWithdrawals not implemented")
}
func (UnimplementedSwapClientServer) ListStaticAddressSwaps(context.Context, *ListStaticAddressSwapsRequest) (*ListStaticAddressSwapsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListStaticAddressSwaps not implemented")
}
@ -1118,6 +1136,24 @@ func _SwapClient_ListStaticAddressDeposits_Handler(srv interface{}, ctx context.
return interceptor(ctx, in, info, handler)
}
func _SwapClient_ListStaticAddressWithdrawals_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListStaticAddressWithdrawalRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SwapClientServer).ListStaticAddressWithdrawals(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/looprpc.SwapClient/ListStaticAddressWithdrawals",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SwapClientServer).ListStaticAddressWithdrawals(ctx, req.(*ListStaticAddressWithdrawalRequest))
}
return interceptor(ctx, in, info, handler)
}
func _SwapClient_ListStaticAddressSwaps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListStaticAddressSwapsRequest)
if err := dec(in); err != nil {
@ -1279,6 +1315,10 @@ var SwapClient_ServiceDesc = grpc.ServiceDesc{
MethodName: "ListStaticAddressDeposits",
Handler: _SwapClient_ListStaticAddressDeposits_Handler,
},
{
MethodName: "ListStaticAddressWithdrawals",
Handler: _SwapClient_ListStaticAddressWithdrawals_Handler,
},
{
MethodName: "ListStaticAddressSwaps",
Handler: _SwapClient_ListStaticAddressSwaps_Handler,

View file

@ -101,6 +101,13 @@ var RequiredPermissions = map[string][]bakery.Op{
Entity: "loop",
Action: "in",
}},
"/looprpc.SwapClient/ListStaticAddressWithdrawals": {{
Entity: "swap",
Action: "read",
}, {
Entity: "loop",
Action: "in",
}},
"/looprpc.SwapClient/ListStaticAddressSwaps": {{
Entity: "swap",
Action: "read",

View file

@ -688,6 +688,31 @@ func RegisterSwapClientJSONCallbacks(registry map[string]func(ctx context.Contex
callback(string(respBytes), nil)
}
registry["looprpc.SwapClient.ListStaticAddressWithdrawals"] = func(ctx context.Context,
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
req := &ListStaticAddressWithdrawalRequest{}
err := marshaler.Unmarshal([]byte(reqJSON), req)
if err != nil {
callback("", err)
return
}
client := NewSwapClientClient(conn)
resp, err := client.ListStaticAddressWithdrawals(ctx, req)
if err != nil {
callback("", err)
return
}
respBytes, err := marshaler.Marshal(resp)
if err != nil {
callback("", err)
return
}
callback(string(respBytes), nil)
}
registry["looprpc.SwapClient.ListStaticAddressSwaps"] = func(ctx context.Context,
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {