multi: surface swap type on rpc

pull/433/head
carla 3 years ago
parent 25b8d20f75
commit 91a90968d0
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91

@ -168,6 +168,7 @@ func setRule(ctx *cli.Context) error {
newRule := &looprpc.LiquidityRule{ newRule := &looprpc.LiquidityRule{
ChannelId: chanID, ChannelId: chanID,
Type: looprpc.LiquidityRuleType_THRESHOLD, Type: looprpc.LiquidityRuleType_THRESHOLD,
SwapType: looprpc.SwapType_LOOP_OUT,
} }
if pubkeyRule { if pubkeyRule {

@ -752,13 +752,20 @@ func (s *swapClientServer) GetLiquidityParams(_ context.Context,
func newRPCRule(channelID uint64, peer []byte, func newRPCRule(channelID uint64, peer []byte,
rule *liquidity.SwapRule) *looprpc.LiquidityRule { rule *liquidity.SwapRule) *looprpc.LiquidityRule {
return &looprpc.LiquidityRule{ rpcRule := &looprpc.LiquidityRule{
ChannelId: channelID, ChannelId: channelID,
Pubkey: peer, Pubkey: peer,
Type: looprpc.LiquidityRuleType_THRESHOLD, Type: looprpc.LiquidityRuleType_THRESHOLD,
IncomingThreshold: uint32(rule.MinimumIncoming), IncomingThreshold: uint32(rule.MinimumIncoming),
OutgoingThreshold: uint32(rule.MinimumOutgoing), OutgoingThreshold: uint32(rule.MinimumOutgoing),
SwapType: looprpc.SwapType_LOOP_OUT,
} }
if rule.Type == swap.TypeIn {
rpcRule.SwapType = looprpc.SwapType_LOOP_IN
}
return rpcRule
} }
// SetLiquidityParams attempts to set our current liquidity manager's // SetLiquidityParams attempts to set our current liquidity manager's
@ -891,6 +898,11 @@ func rpcToFee(req *looprpc.LiquidityParameters) (liquidity.FeeLimit,
// rpcToRule switches on rpc rule type to convert to our rule interface. // rpcToRule switches on rpc rule type to convert to our rule interface.
func rpcToRule(rule *looprpc.LiquidityRule) (*liquidity.SwapRule, error) { func rpcToRule(rule *looprpc.LiquidityRule) (*liquidity.SwapRule, error) {
swapType := swap.TypeOut
if rule.SwapType == looprpc.SwapType_LOOP_IN {
swapType = swap.TypeIn
}
switch rule.Type { switch rule.Type {
case looprpc.LiquidityRuleType_UNKNOWN: case looprpc.LiquidityRuleType_UNKNOWN:
return nil, fmt.Errorf("rule type field must be set") return nil, fmt.Errorf("rule type field must be set")
@ -901,7 +913,7 @@ func rpcToRule(rule *looprpc.LiquidityRule) (*liquidity.SwapRule, error) {
int(rule.IncomingThreshold), int(rule.IncomingThreshold),
int(rule.OutgoingThreshold), int(rule.OutgoingThreshold),
), ),
Type: swap.TypeOut, Type: swapType,
}, nil }, nil
default: default:

@ -2299,6 +2299,8 @@ type LiquidityRule struct {
//The short channel ID of the channel that this rule should be applied to. //The short channel ID of the channel that this rule should be applied to.
//This field may not be set when the pubkey field is set. //This field may not be set when the pubkey field is set.
ChannelId uint64 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` ChannelId uint64 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
// The type of swap that will be dispatched for this rule.
SwapType SwapType `protobuf:"varint,6,opt,name=swap_type,json=swapType,proto3,enum=looprpc.SwapType" json:"swap_type,omitempty"`
// //
//The public key of the peer that this rule should be applied to. This field //The public key of the peer that this rule should be applied to. This field
//may not be set when the channel id field is set. //may not be set when the channel id field is set.
@ -2358,6 +2360,13 @@ func (x *LiquidityRule) GetChannelId() uint64 {
return 0 return 0
} }
func (x *LiquidityRule) GetSwapType() SwapType {
if x != nil {
return x.SwapType
}
return SwapType_LOOP_OUT
}
func (x *LiquidityRule) GetPubkey() []byte { func (x *LiquidityRule) GetPubkey() []byte {
if x != nil { if x != nil {
return x.Pubkey return x.Pubkey
@ -2905,10 +2914,13 @@ var file_client_proto_rawDesc = []byte{
0x6e, 0x53, 0x77, 0x61, 0x70, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x6d, 0x6e, 0x53, 0x77, 0x61, 0x70, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x6d,
0x61, 0x78, 0x5f, 0x73, 0x77, 0x61, 0x70, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0f, 0x61, 0x78, 0x5f, 0x73, 0x77, 0x61, 0x70, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0f,
0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x53, 0x77, 0x61, 0x70, 0x41, 0x6d, 0x6f, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x53, 0x77, 0x61, 0x70, 0x41, 0x6d, 0x6f,
0x75, 0x6e, 0x74, 0x22, 0xd4, 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74, 0x75, 0x6e, 0x74, 0x22, 0x84, 0x02, 0x0a, 0x0d, 0x4c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74,
0x79, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c,
0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e,
0x65, 0x6c, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x09, 0x73, 0x77, 0x61, 0x70, 0x5f, 0x74, 0x79, 0x70,
0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70,
0x63, 0x2e, 0x53, 0x77, 0x61, 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x73, 0x77, 0x61, 0x70,
0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x18, 0x05,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x12, 0x2e, 0x0a, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x12, 0x2e, 0x0a, 0x04,
0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x6c, 0x6f, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x6c, 0x6f, 0x6f,
0x70, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74, 0x79, 0x52, 0x75, 0x70, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74, 0x79, 0x52, 0x75,
@ -3122,44 +3134,45 @@ var file_client_proto_depIdxs = []int32{
32, // 5: looprpc.ProbeRequest.route_hints:type_name -> looprpc.RouteHint 32, // 5: looprpc.ProbeRequest.route_hints:type_name -> looprpc.RouteHint
23, // 6: looprpc.TokensResponse.tokens:type_name -> looprpc.LsatToken 23, // 6: looprpc.TokensResponse.tokens:type_name -> looprpc.LsatToken
26, // 7: looprpc.LiquidityParameters.rules:type_name -> looprpc.LiquidityRule 26, // 7: looprpc.LiquidityParameters.rules:type_name -> looprpc.LiquidityRule
3, // 8: looprpc.LiquidityRule.type:type_name -> looprpc.LiquidityRuleType 0, // 8: looprpc.LiquidityRule.swap_type:type_name -> looprpc.SwapType
25, // 9: looprpc.SetLiquidityParamsRequest.parameters:type_name -> looprpc.LiquidityParameters 3, // 9: looprpc.LiquidityRule.type:type_name -> looprpc.LiquidityRuleType
4, // 10: looprpc.Disqualified.reason:type_name -> looprpc.AutoReason 25, // 10: looprpc.SetLiquidityParamsRequest.parameters:type_name -> looprpc.LiquidityParameters
5, // 11: looprpc.SuggestSwapsResponse.loop_out:type_name -> looprpc.LoopOutRequest 4, // 11: looprpc.Disqualified.reason:type_name -> looprpc.AutoReason
30, // 12: looprpc.SuggestSwapsResponse.disqualified:type_name -> looprpc.Disqualified 5, // 12: looprpc.SuggestSwapsResponse.loop_out:type_name -> looprpc.LoopOutRequest
5, // 13: looprpc.SwapClient.LoopOut:input_type -> looprpc.LoopOutRequest 30, // 13: looprpc.SuggestSwapsResponse.disqualified:type_name -> looprpc.Disqualified
6, // 14: looprpc.SwapClient.LoopIn:input_type -> looprpc.LoopInRequest 5, // 14: looprpc.SwapClient.LoopOut:input_type -> looprpc.LoopOutRequest
8, // 15: looprpc.SwapClient.Monitor:input_type -> looprpc.MonitorRequest 6, // 15: looprpc.SwapClient.LoopIn:input_type -> looprpc.LoopInRequest
10, // 16: looprpc.SwapClient.ListSwaps:input_type -> looprpc.ListSwapsRequest 8, // 16: looprpc.SwapClient.Monitor:input_type -> looprpc.MonitorRequest
12, // 17: looprpc.SwapClient.SwapInfo:input_type -> looprpc.SwapInfoRequest 10, // 17: looprpc.SwapClient.ListSwaps:input_type -> looprpc.ListSwapsRequest
13, // 18: looprpc.SwapClient.LoopOutTerms:input_type -> looprpc.TermsRequest 12, // 18: looprpc.SwapClient.SwapInfo:input_type -> looprpc.SwapInfoRequest
16, // 19: looprpc.SwapClient.LoopOutQuote:input_type -> looprpc.QuoteRequest 13, // 19: looprpc.SwapClient.LoopOutTerms:input_type -> looprpc.TermsRequest
13, // 20: looprpc.SwapClient.GetLoopInTerms:input_type -> looprpc.TermsRequest 16, // 20: looprpc.SwapClient.LoopOutQuote:input_type -> looprpc.QuoteRequest
16, // 21: looprpc.SwapClient.GetLoopInQuote:input_type -> looprpc.QuoteRequest 13, // 21: looprpc.SwapClient.GetLoopInTerms:input_type -> looprpc.TermsRequest
19, // 22: looprpc.SwapClient.Probe:input_type -> looprpc.ProbeRequest 16, // 22: looprpc.SwapClient.GetLoopInQuote:input_type -> looprpc.QuoteRequest
21, // 23: looprpc.SwapClient.GetLsatTokens:input_type -> looprpc.TokensRequest 19, // 23: looprpc.SwapClient.Probe:input_type -> looprpc.ProbeRequest
24, // 24: looprpc.SwapClient.GetLiquidityParams:input_type -> looprpc.GetLiquidityParamsRequest 21, // 24: looprpc.SwapClient.GetLsatTokens:input_type -> looprpc.TokensRequest
27, // 25: looprpc.SwapClient.SetLiquidityParams:input_type -> looprpc.SetLiquidityParamsRequest 24, // 25: looprpc.SwapClient.GetLiquidityParams:input_type -> looprpc.GetLiquidityParamsRequest
29, // 26: looprpc.SwapClient.SuggestSwaps:input_type -> looprpc.SuggestSwapsRequest 27, // 26: looprpc.SwapClient.SetLiquidityParams:input_type -> looprpc.SetLiquidityParamsRequest
7, // 27: looprpc.SwapClient.LoopOut:output_type -> looprpc.SwapResponse 29, // 27: looprpc.SwapClient.SuggestSwaps:input_type -> looprpc.SuggestSwapsRequest
7, // 28: looprpc.SwapClient.LoopIn:output_type -> looprpc.SwapResponse 7, // 28: looprpc.SwapClient.LoopOut:output_type -> looprpc.SwapResponse
9, // 29: looprpc.SwapClient.Monitor:output_type -> looprpc.SwapStatus 7, // 29: looprpc.SwapClient.LoopIn:output_type -> looprpc.SwapResponse
11, // 30: looprpc.SwapClient.ListSwaps:output_type -> looprpc.ListSwapsResponse 9, // 30: looprpc.SwapClient.Monitor:output_type -> looprpc.SwapStatus
9, // 31: looprpc.SwapClient.SwapInfo:output_type -> looprpc.SwapStatus 11, // 31: looprpc.SwapClient.ListSwaps:output_type -> looprpc.ListSwapsResponse
15, // 32: looprpc.SwapClient.LoopOutTerms:output_type -> looprpc.OutTermsResponse 9, // 32: looprpc.SwapClient.SwapInfo:output_type -> looprpc.SwapStatus
18, // 33: looprpc.SwapClient.LoopOutQuote:output_type -> looprpc.OutQuoteResponse 15, // 33: looprpc.SwapClient.LoopOutTerms:output_type -> looprpc.OutTermsResponse
14, // 34: looprpc.SwapClient.GetLoopInTerms:output_type -> looprpc.InTermsResponse 18, // 34: looprpc.SwapClient.LoopOutQuote:output_type -> looprpc.OutQuoteResponse
17, // 35: looprpc.SwapClient.GetLoopInQuote:output_type -> looprpc.InQuoteResponse 14, // 35: looprpc.SwapClient.GetLoopInTerms:output_type -> looprpc.InTermsResponse
20, // 36: looprpc.SwapClient.Probe:output_type -> looprpc.ProbeResponse 17, // 36: looprpc.SwapClient.GetLoopInQuote:output_type -> looprpc.InQuoteResponse
22, // 37: looprpc.SwapClient.GetLsatTokens:output_type -> looprpc.TokensResponse 20, // 37: looprpc.SwapClient.Probe:output_type -> looprpc.ProbeResponse
25, // 38: looprpc.SwapClient.GetLiquidityParams:output_type -> looprpc.LiquidityParameters 22, // 38: looprpc.SwapClient.GetLsatTokens:output_type -> looprpc.TokensResponse
28, // 39: looprpc.SwapClient.SetLiquidityParams:output_type -> looprpc.SetLiquidityParamsResponse 25, // 39: looprpc.SwapClient.GetLiquidityParams:output_type -> looprpc.LiquidityParameters
31, // 40: looprpc.SwapClient.SuggestSwaps:output_type -> looprpc.SuggestSwapsResponse 28, // 40: looprpc.SwapClient.SetLiquidityParams:output_type -> looprpc.SetLiquidityParamsResponse
27, // [27:41] is the sub-list for method output_type 31, // 41: looprpc.SwapClient.SuggestSwaps:output_type -> looprpc.SuggestSwapsResponse
13, // [13:27] is the sub-list for method input_type 28, // [28:42] is the sub-list for method output_type
13, // [13:13] is the sub-list for extension type_name 14, // [14:28] is the sub-list for method input_type
13, // [13:13] is the sub-list for extension extendee 14, // [14:14] is the sub-list for extension type_name
0, // [0:13] is the sub-list for field type_name 14, // [14:14] is the sub-list for extension extendee
0, // [0:14] is the sub-list for field type_name
} }
func init() { file_client_proto_init() } func init() { file_client_proto_init() }

@ -843,6 +843,9 @@ message LiquidityRule {
*/ */
uint64 channel_id = 1; uint64 channel_id = 1;
// The type of swap that will be dispatched for this rule.
SwapType swap_type = 6;
/* /*
The public key of the peer that this rule should be applied to. This field The public key of the peer that this rule should be applied to. This field
may not be set when the channel id field is set. may not be set when the channel id field is set.

@ -672,6 +672,10 @@
"format": "uint64", "format": "uint64",
"description": "The short channel ID of the channel that this rule should be applied to.\nThis field may not be set when the pubkey field is set." "description": "The short channel ID of the channel that this rule should be applied to.\nThis field may not be set when the pubkey field is set."
}, },
"swap_type": {
"$ref": "#/definitions/looprpcSwapType",
"description": "The type of swap that will be dispatched for this rule."
},
"pubkey": { "pubkey": {
"type": "string", "type": "string",
"format": "byte", "format": "byte",

Loading…
Cancel
Save