diff --git a/client.go b/client.go index 2422656..008f6c1 100644 --- a/client.go +++ b/client.go @@ -353,11 +353,14 @@ func (s *Client) LoopOutQuote(ctx context.Context, return nil, ErrSwapAmountTooHigh } - logger.Infof("Offchain swap destination: %x", terms.SwapPaymentDest) + quote, err := s.Server.GetLoopOutQuote(ctx, request.Amount) + if err != nil { + return nil, err + } - swapFee := swap.CalcFee( - request.Amount, terms.SwapFeeBase, terms.SwapFeeRate, - ) + logger.Infof("Offchain swap destination: %x", quote.SwapPaymentDest) + + swapFee := quote.SwapFee // Generate dummy p2wsh address for fee estimation. The p2wsh address // type is chosen because it adds the most weight of all output types @@ -379,9 +382,11 @@ func (s *Client) LoopOutQuote(ctx context.Context, } return &LoopOutQuote{ - SwapFee: swapFee, - MinerFee: minerFee, - PrepayAmount: btcutil.Amount(terms.PrepayAmt), + SwapFee: swapFee, + MinerFee: minerFee, + PrepayAmount: btcutil.Amount(quote.PrepayAmount), + SwapPaymentDest: quote.SwapPaymentDest, + CltvDelta: quote.CltvDelta, }, nil } @@ -465,10 +470,12 @@ func (s *Client) LoopInQuote(ctx context.Context, return nil, ErrSwapAmountTooHigh } - // Calculate swap fee. - swapFee := terms.SwapFeeBase + - request.Amount*btcutil.Amount(terms.SwapFeeRate)/ - btcutil.Amount(swap.FeeRateTotalParts) + quote, err := s.Server.GetLoopInQuote(ctx, request.Amount) + if err != nil { + return nil, err + } + + swapFee := quote.SwapFee // We don't calculate the on-chain fee if the HTLC is going to be // published externally. @@ -478,7 +485,7 @@ func (s *Client) LoopInQuote(ctx context.Context, MinerFee: 0, }, nil } - + // Get estimate for miner fee. minerFee, err := s.lndServices.Client.EstimateFeeToP2WSH( ctx, request.Amount, request.HtlcConfTarget, @@ -488,8 +495,9 @@ func (s *Client) LoopInQuote(ctx context.Context, } return &LoopInQuote{ - SwapFee: swapFee, - MinerFee: minerFee, + SwapFee: swapFee, + MinerFee: minerFee, + CltvDelta: quote.CltvDelta, }, nil } diff --git a/cmd/loop/terms.go b/cmd/loop/terms.go index 1aeacb9..feda2d4 100644 --- a/cmd/loop/terms.go +++ b/cmd/loop/terms.go @@ -8,7 +8,6 @@ import ( "github.com/btcsuite/btcutil" "github.com/lightninglabs/loop/looprpc" - "github.com/lightninglabs/loop/swap" ) var termsCommand = cli.Command{ @@ -29,13 +28,6 @@ func terms(ctx *cli.Context) error { btcutil.Amount(terms.MinSwapAmount), btcutil.Amount(terms.MaxSwapAmount), ) - fmt.Printf("Fee: %d + %.4f %% (%d prepaid)\n", - btcutil.Amount(terms.SwapFeeBase), - swap.FeeRateAsPercentage(terms.SwapFeeRate), - btcutil.Amount(terms.PrepayAmt), - ) - - fmt.Printf("Cltv delta: %v blocks\n", terms.CltvDelta) } fmt.Println("Loop Out") diff --git a/cmd/loopd/swapclient_server.go b/cmd/loopd/swapclient_server.go index 7579cb2..a05626a 100644 --- a/cmd/loopd/swapclient_server.go +++ b/cmd/loopd/swapclient_server.go @@ -244,10 +244,6 @@ func (s *swapClientServer) LoopOutTerms(ctx context.Context, return &looprpc.TermsResponse{ MinSwapAmount: int64(terms.MinSwapAmount), MaxSwapAmount: int64(terms.MaxSwapAmount), - PrepayAmt: int64(terms.PrepayAmt), - SwapFeeBase: int64(terms.SwapFeeBase), - SwapFeeRate: int64(terms.SwapFeeRate), - CltvDelta: int32(terms.CltvDelta), }, nil } @@ -269,10 +265,13 @@ func (s *swapClientServer) LoopOutQuote(ctx context.Context, if err != nil { return nil, err } + return &looprpc.QuoteResponse{ - MinerFee: int64(quote.MinerFee), - PrepayAmt: int64(quote.PrepayAmount), - SwapFee: int64(quote.SwapFee), + MinerFee: int64(quote.MinerFee), + PrepayAmt: int64(quote.PrepayAmount), + SwapFee: int64(quote.SwapFee), + SwapPaymentDest: quote.SwapPaymentDest[:], + CltvDelta: quote.CltvDelta, }, nil } @@ -291,9 +290,6 @@ func (s *swapClientServer) GetLoopInTerms(ctx context.Context, req *looprpc.Term return &looprpc.TermsResponse{ MinSwapAmount: int64(terms.MinSwapAmount), MaxSwapAmount: int64(terms.MaxSwapAmount), - SwapFeeBase: int64(terms.SwapFeeBase), - SwapFeeRate: int64(terms.SwapFeeRate), - CltvDelta: int32(terms.CltvDelta), }, nil } diff --git a/interface.go b/interface.go index fadc2b8..b3d646d 100644 --- a/interface.go +++ b/interface.go @@ -105,6 +105,17 @@ type LoopOutQuoteRequest struct { // final cltv delta values for the off-chain payments. } +// LoopOutTerms are the server terms on which it executes swaps. +type LoopOutTerms struct { + // MinSwapAmount is the minimum amount that the server requires for a + // swap. + MinSwapAmount btcutil.Amount + + // MaxSwapAmount is the maximum amount that the server accepts for a + // swap. + MaxSwapAmount btcutil.Amount +} + // LoopOutQuote contains estimates for the fees making up the total swap cost // for the client. type LoopOutQuote struct { @@ -118,27 +129,6 @@ type LoopOutQuote struct { // MinerFee is an estimate of the on-chain fee that needs to be paid to // sweep the htlc. MinerFee btcutil.Amount -} - -// LoopOutTerms are the server terms on which it executes swaps. -type LoopOutTerms struct { - // SwapFeeBase is the fixed per-swap base fee. - SwapFeeBase btcutil.Amount - - // SwapFeeRate is the variable fee in parts per million. - SwapFeeRate int64 - - // PrepayAmt is the fixed part of the swap fee that needs to be - // prepaid. - PrepayAmt btcutil.Amount - - // MinSwapAmount is the minimum amount that the server requires for a - // swap. - MinSwapAmount btcutil.Amount - - // MaxSwapAmount is the maximum amount that the server accepts for a - // swap. - MaxSwapAmount btcutil.Amount // Time lock delta relative to current block height that swap server // will accept on the swap initiation call. @@ -185,12 +175,6 @@ type LoopInRequest struct { // LoopInTerms are the server terms on which it executes charge swaps. type LoopInTerms struct { - // SwapFeeBase is the fixed per-swap base fee. - SwapFeeBase btcutil.Amount - - // SwapFeeRate is the variable fee in parts per million. - SwapFeeRate int64 - // MinSwapAmount is the minimum amount that the server requires for a // swap. MinSwapAmount btcutil.Amount @@ -198,10 +182,6 @@ type LoopInTerms struct { // MaxSwapAmount is the maximum amount that the server accepts for a // swap. MaxSwapAmount btcutil.Amount - - // Time lock delta relative to current block height that swap server - // will accept on the swap initiation call. - CltvDelta int32 } // In contains status information for a loop in swap. @@ -239,6 +219,10 @@ type LoopInQuote struct { // MinerFee is an estimate of the on-chain fee that needs to be paid to // sweep the htlc. MinerFee btcutil.Amount + + // Time lock delta relative to current block height that swap server + // will accept on the swap initiation call. + CltvDelta int32 } // SwapInfoKit contains common swap info fields. diff --git a/loopin.go b/loopin.go index e7874a1..229718f 100644 --- a/loopin.go +++ b/loopin.go @@ -60,14 +60,12 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig, // Request current server loop in terms and use these to calculate the // swap fee that we should subtract from the swap amount in the payment // request that we send to the server. - quote, err := cfg.server.GetLoopInTerms(globalCtx) + quote, err := cfg.server.GetLoopInQuote(globalCtx, request.Amount) if err != nil { return nil, fmt.Errorf("loop in terms: %v", err) } - swapFee := swap.CalcFee( - request.Amount, quote.SwapFeeBase, quote.SwapFeeRate, - ) + swapFee := quote.SwapFee if swapFee > request.MaxSwapFee { logger.Warnf("Swap fee %v exceeding maximum of %v", diff --git a/looprpc/client.pb.go b/looprpc/client.pb.go index bc4578e..10ab2dc 100644 --- a/looprpc/client.pb.go +++ b/looprpc/client.pb.go @@ -590,28 +590,12 @@ func (m *TermsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_TermsRequest proto.InternalMessageInfo type TermsResponse struct { - //* - //The node pubkey where the swap payment needs to be paid - //to. This can be used to test connectivity before initiating the swap. - SwapPaymentDest string `protobuf:"bytes,1,opt,name=swap_payment_dest,json=swapPaymentDest,proto3" json:"swap_payment_dest,omitempty"` - //* - //The base fee for a swap (sat) - SwapFeeBase int64 `protobuf:"varint,2,opt,name=swap_fee_base,json=swapFeeBase,proto3" json:"swap_fee_base,omitempty"` - //* - //The fee rate for a swap (parts per million) - SwapFeeRate int64 `protobuf:"varint,3,opt,name=swap_fee_rate,json=swapFeeRate,proto3" json:"swap_fee_rate,omitempty"` - //* - //Required prepay amount - PrepayAmt int64 `protobuf:"varint,4,opt,name=prepay_amt,json=prepayAmt,proto3" json:"prepay_amt,omitempty"` //* //Minimum swap amount (sat) MinSwapAmount int64 `protobuf:"varint,5,opt,name=min_swap_amount,json=minSwapAmount,proto3" json:"min_swap_amount,omitempty"` //* //Maximum swap amount (sat) - MaxSwapAmount int64 `protobuf:"varint,6,opt,name=max_swap_amount,json=maxSwapAmount,proto3" json:"max_swap_amount,omitempty"` - //* - //On-chain cltv expiry delta - CltvDelta int32 `protobuf:"varint,7,opt,name=cltv_delta,json=cltvDelta,proto3" json:"cltv_delta,omitempty"` + MaxSwapAmount int64 `protobuf:"varint,6,opt,name=max_swap_amount,json=maxSwapAmount,proto3" json:"max_swap_amount,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -642,34 +626,6 @@ func (m *TermsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_TermsResponse proto.InternalMessageInfo -func (m *TermsResponse) GetSwapPaymentDest() string { - if m != nil { - return m.SwapPaymentDest - } - return "" -} - -func (m *TermsResponse) GetSwapFeeBase() int64 { - if m != nil { - return m.SwapFeeBase - } - return 0 -} - -func (m *TermsResponse) GetSwapFeeRate() int64 { - if m != nil { - return m.SwapFeeRate - } - return 0 -} - -func (m *TermsResponse) GetPrepayAmt() int64 { - if m != nil { - return m.PrepayAmt - } - return 0 -} - func (m *TermsResponse) GetMinSwapAmount() int64 { if m != nil { return m.MinSwapAmount @@ -684,13 +640,6 @@ func (m *TermsResponse) GetMaxSwapAmount() int64 { return 0 } -func (m *TermsResponse) GetCltvDelta() int32 { - if m != nil { - return m.CltvDelta - } - return 0 -} - type QuoteRequest struct { //* //The amount to swap in satoshis. @@ -765,7 +714,14 @@ type QuoteResponse struct { PrepayAmt int64 `protobuf:"varint,2,opt,name=prepay_amt,json=prepayAmt,proto3" json:"prepay_amt,omitempty"` //* //An estimate of the on-chain fee that needs to be paid to sweep the HTLC. - MinerFee int64 `protobuf:"varint,3,opt,name=miner_fee,json=minerFee,proto3" json:"miner_fee,omitempty"` + MinerFee int64 `protobuf:"varint,3,opt,name=miner_fee,json=minerFee,proto3" json:"miner_fee,omitempty"` + //* + //The node pubkey where the swap payment needs to be paid + //to. This can be used to test connectivity before initiating the swap. + SwapPaymentDest []byte `protobuf:"bytes,4,opt,name=swap_payment_dest,json=swapPaymentDest,proto3" json:"swap_payment_dest,omitempty"` + //* + //On-chain cltv expiry delta + CltvDelta int32 `protobuf:"varint,5,opt,name=cltv_delta,json=cltvDelta,proto3" json:"cltv_delta,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -817,6 +773,20 @@ func (m *QuoteResponse) GetMinerFee() int64 { return 0 } +func (m *QuoteResponse) GetSwapPaymentDest() []byte { + if m != nil { + return m.SwapPaymentDest + } + return nil +} + +func (m *QuoteResponse) GetCltvDelta() int32 { + if m != nil { + return m.CltvDelta + } + return 0 +} + func init() { proto.RegisterEnum("looprpc.SwapType", SwapType_name, SwapType_value) proto.RegisterEnum("looprpc.SwapState", SwapState_name, SwapState_value) @@ -834,74 +804,74 @@ func init() { func init() { proto.RegisterFile("client.proto", fileDescriptor_014de31d7ac8c57c) } var fileDescriptor_014de31d7ac8c57c = []byte{ - // 1065 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x5f, 0x73, 0xda, 0xc6, - 0x17, 0x0d, 0x02, 0x1b, 0xb8, 0x08, 0x01, 0xeb, 0xc4, 0xc6, 0xfc, 0x7e, 0x99, 0x50, 0xb5, 0x49, - 0x19, 0x3f, 0x98, 0xd6, 0x79, 0x6a, 0xdf, 0x08, 0x26, 0x31, 0x33, 0xb6, 0x71, 0x05, 0xce, 0x4c, - 0xfb, 0xa2, 0x6e, 0x60, 0xb1, 0x35, 0x23, 0xed, 0x2a, 0xd2, 0xe2, 0x3f, 0xd3, 0xe9, 0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6e, 0xae, 0xcc, 0x06, 0x4a, 0x75, 0x2c, - 0xa9, 0x5c, 0xc4, 0x9f, 0x68, 0x84, 0x3e, 0xc5, 0x48, 0x4f, 0x79, 0x09, 0x05, 0x79, 0x1f, 0xea, - 0xdb, 0x5a, 0x47, 0x8d, 0xc3, 0xc4, 0xd3, 0x87, 0x4a, 0x64, 0x72, 0x1f, 0x32, 0x07, 0x97, 0x49, - 0x07, 0xb6, 0x62, 0x49, 0xa5, 0x76, 0x92, 0x75, 0x44, 0x56, 0x78, 0xea, 0x30, 0xe6, 0x68, 0x02, - 0xf9, 0x1a, 0x6a, 0x1e, 0xf7, 0xa4, 0x87, 0x19, 0x70, 0xa5, 0x17, 0x2c, 0x2d, 0x65, 0x3d, 0xc0, - 0x13, 0x2f, 0xd0, 0x66, 0xa0, 0xb1, 0x74, 0x17, 0xe1, 0x8c, 0x4a, 0xa6, 0x99, 0xda, 0x58, 0x96, - 0xc2, 0x2f, 0x11, 0x46, 0xe6, 0x7a, 0x27, 0x8a, 0x1b, 0x9d, 0x20, 0x2f, 0xa0, 0x32, 0x15, 0xb1, - 0x74, 0x63, 0x16, 0xdd, 0xb0, 0x08, 0x4d, 0x95, 0x77, 0x40, 0x41, 0x63, 0x44, 0x94, 0x06, 0x12, - 0x04, 0x9f, 0x5e, 0x53, 0x8f, 0xa3, 0x97, 0xf2, 0x0e, 0x6e, 0x1a, 0x69, 0x48, 0x4d, 0x4d, 0x53, - 0xe6, 0x73, 0xcd, 0x01, 0x6d, 0x73, 0xe4, 0x24, 0x98, 0x6d, 0x81, 0x39, 0x61, 0x51, 0x10, 0x2f, - 0x1b, 0xfe, 0xbb, 0x01, 0xd5, 0x04, 0x48, 0xe6, 0x88, 0xd6, 0xa5, 0xa1, 0x1b, 0xd2, 0xfb, 0x80, - 0x71, 0xe9, 0x62, 0xae, 0xf5, 0x58, 0x6b, 0x6a, 0xe1, 0x42, 0xe3, 0xc7, 0xca, 0xa8, 0x36, 0x54, - 0x97, 0x96,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b, 0x7a, 0x4a, - 0x48, 0xf6, 0x8e, 0x5d, 0x89, 0x52, 0x6e, 0x2a, 0x8d, 0xa6, 0xca, 0x48, 0x67, 0xcd, 0x9c, 0x91, - 0x5e, 0xf1, 0x9e, 0xdd, 0x46, 0xe9, 0x16, 0x69, 0xae, 0x48, 0x7f, 0x54, 0x9c, 0xee, 0x2f, 0x34, - 0x90, 0xbf, 0x92, 0x9f, 0xc0, 0x7a, 0xc7, 0xa4, 0xee, 0xdc, 0x67, 0x55, 0xbf, 0x8f, 0x47, 0xec, - 0x90, 0x46, 0xa6, 0x9f, 0x49, 0xf1, 0x3f, 0x67, 0xb4, 0x3f, 0xab, 0xfc, 0x17, 0xa8, 0xbd, 0x4f, - 0xf6, 0xb2, 0xda, 0x99, 0xea, 0x3f, 0x6c, 0xe3, 0x7f, 0x33, 0xaf, 0xff, 0x0b, 0x00, 0x00, 0xff, - 0xff, 0x71, 0xf8, 0xf7, 0x7c, 0x04, 0x09, 0x00, 0x00, + // 1061 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x73, 0xda, 0x46, + 0x1c, 0x8d, 0x40, 0x18, 0xf1, 0xb3, 0x90, 0xc5, 0x3a, 0x71, 0x08, 0x6d, 0x26, 0x94, 0x36, 0x29, + 0xe3, 0x83, 0x69, 0x9d, 0x53, 0x7b, 0xa3, 0x98, 0xc4, 0x78, 0x6c, 0xe3, 0x0a, 0x9c, 0x99, 0xf6, + 0xa2, 0x6e, 0x61, 0xb1, 0x35, 0x83, 0x76, 0x15, 0x69, 0xf1, 0x9f, 0xe9, 0xe4, 0xd2, 0xaf, 0xd0, + 0x4f, 0xd2, 0x99, 0x7e, 0x93, 0xde, 0x7b, 0xea, 0xf4, 0x73, 0x74, 0xf6, 0xb7, 0x42, 0x16, 0x26, + 0xbe, 0xe4, 0x66, 0x9e, 0xde, 0xbe, 0xdf, 0x1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x83, 0xd4, 0x57, 0xa4, 0xdf, 0x2b, 0x4e, 0xe7, 0x37, 0x1a, 0xca, 0x0f, 0xe4, 0x67, + 0x70, 0xde, 0x32, 0xa9, 0x37, 0xf7, 0x49, 0xdd, 0x3f, 0xc3, 0x12, 0xdb, 0xa4, 0x96, 0xdb, 0x67, + 0xda, 0xfc, 0x2f, 0x39, 0xed, 0x4f, 0x6a, 0xff, 0x05, 0x6a, 0x3f, 0x23, 0x4f, 0xf3, 0xda, 0xb9, + 0xee, 0x7f, 0xdd, 0xc0, 0x7f, 0x42, 0x5e, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x26, 0x06, 0x26, + 0x30, 0xbb, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/looprpc/client.proto b/looprpc/client.proto index 0d54f15..01e46b0 100644 --- a/looprpc/client.proto +++ b/looprpc/client.proto @@ -305,26 +305,8 @@ message TermsRequest { } message TermsResponse { - /** - The node pubkey where the swap payment needs to be paid - to. This can be used to test connectivity before initiating the swap. - */ - string swap_payment_dest = 1; - /** - The base fee for a swap (sat) - */ - int64 swap_fee_base = 2; - - /** - The fee rate for a swap (parts per million) - */ - int64 swap_fee_rate = 3; - - /** - Required prepay amount - */ - int64 prepay_amt = 4; + reserved 1,2,3,4,7; /** Minimum swap amount (sat) @@ -335,11 +317,6 @@ message TermsResponse { Maximum swap amount (sat) */ int64 max_swap_amount = 6; - - /** - On-chain cltv expiry delta - */ - int32 cltv_delta = 7; } message QuoteRequest { @@ -378,4 +355,15 @@ message QuoteResponse { An estimate of the on-chain fee that needs to be paid to sweep the HTLC. */ int64 miner_fee = 3; + + /** + The node pubkey where the swap payment needs to be paid + to. This can be used to test connectivity before initiating the swap. + */ + bytes swap_payment_dest = 4; + + /** + On-chain cltv expiry delta + */ + int32 cltv_delta = 5; } diff --git a/looprpc/client.swagger.json b/looprpc/client.swagger.json index 43d001b..0f76ba8 100644 --- a/looprpc/client.swagger.json +++ b/looprpc/client.swagger.json @@ -285,6 +285,16 @@ "type": "string", "format": "int64", "description": "*\nAn estimate of the on-chain fee that needs to be paid to sweep the HTLC." + }, + "swap_payment_dest": { + "type": "string", + "format": "byte", + "description": "*\nThe node pubkey where the swap payment needs to be paid\nto. This can be used to test connectivity before initiating the swap." + }, + "cltv_delta": { + "type": "integer", + "format": "int32", + "title": "*\nOn-chain cltv expiry delta" } } }, @@ -377,25 +387,6 @@ "looprpcTermsResponse": { "type": "object", "properties": { - "swap_payment_dest": { - "type": "string", - "description": "*\nThe node pubkey where the swap payment needs to be paid\nto. This can be used to test connectivity before initiating the swap." - }, - "swap_fee_base": { - "type": "string", - "format": "int64", - "title": "*\nThe base fee for a swap (sat)" - }, - "swap_fee_rate": { - "type": "string", - "format": "int64", - "title": "*\nThe fee rate for a swap (parts per million)" - }, - "prepay_amt": { - "type": "string", - "format": "int64", - "title": "*\nRequired prepay amount" - }, "min_swap_amount": { "type": "string", "format": "int64", @@ -405,11 +396,6 @@ "type": "string", "format": "int64", "title": "*\nMaximum swap amount (sat)" - }, - "cltv_delta": { - "type": "integer", - "format": "int32", - "title": "*\nOn-chain cltv expiry delta" } } } diff --git a/looprpc/server.pb.go b/looprpc/server.pb.go index e9914df..b084aaf 100644 --- a/looprpc/server.pb.go +++ b/looprpc/server.pb.go @@ -142,6 +142,8 @@ func (m *ServerLoopOutResponse) GetExpiry() int32 { } type ServerLoopOutQuoteRequest struct { + /// The swap amount. If zero, a quote for a maximum amt swap will be given. + Amt uint64 `protobuf:"varint,1,opt,name=amt,proto3" json:"amt,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -172,13 +174,22 @@ func (m *ServerLoopOutQuoteRequest) XXX_DiscardUnknown() { var xxx_messageInfo_ServerLoopOutQuoteRequest proto.InternalMessageInfo +func (m *ServerLoopOutQuoteRequest) GetAmt() uint64 { + if m != nil { + return m.Amt + } + return 0 +} + type ServerLoopOutQuote struct { - SwapPaymentDest string `protobuf:"bytes,1,opt,name=swap_payment_dest,json=swapPaymentDest,proto3" json:"swap_payment_dest,omitempty"` - SwapFeeBase int64 `protobuf:"varint,2,opt,name=swap_fee_base,json=swapFeeBase,proto3" json:"swap_fee_base,omitempty"` - SwapFeeRate int64 `protobuf:"varint,3,opt,name=swap_fee_rate,json=swapFeeRate,proto3" json:"swap_fee_rate,omitempty"` + SwapPaymentDest string `protobuf:"bytes,1,opt,name=swap_payment_dest,json=swapPaymentDest,proto3" json:"swap_payment_dest,omitempty"` + /// The total estimated swap fee given the quote amt. + SwapFee int64 `protobuf:"varint,2,opt,name=swap_fee,json=swapFee,proto3" json:"swap_fee,omitempty"` + /// Deprecated, total swap fee given quote amt is calculated in swap_fee. + SwapFeeRate int64 `protobuf:"varint,3,opt,name=swap_fee_rate,json=swapFeeRate,proto3" json:"swap_fee_rate,omitempty"` // Deprecated: Do not use. PrepayAmt uint64 `protobuf:"varint,4,opt,name=prepay_amt,json=prepayAmt,proto3" json:"prepay_amt,omitempty"` - MinSwapAmount uint64 `protobuf:"varint,5,opt,name=min_swap_amount,json=minSwapAmount,proto3" json:"min_swap_amount,omitempty"` - MaxSwapAmount uint64 `protobuf:"varint,6,opt,name=max_swap_amount,json=maxSwapAmount,proto3" json:"max_swap_amount,omitempty"` + MinSwapAmount uint64 `protobuf:"varint,5,opt,name=min_swap_amount,json=minSwapAmount,proto3" json:"min_swap_amount,omitempty"` // Deprecated: Do not use. + MaxSwapAmount uint64 `protobuf:"varint,6,opt,name=max_swap_amount,json=maxSwapAmount,proto3" json:"max_swap_amount,omitempty"` // Deprecated: Do not use. CltvDelta int32 `protobuf:"varint,7,opt,name=cltv_delta,json=cltvDelta,proto3" json:"cltv_delta,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -217,13 +228,14 @@ func (m *ServerLoopOutQuote) GetSwapPaymentDest() string { return "" } -func (m *ServerLoopOutQuote) GetSwapFeeBase() int64 { +func (m *ServerLoopOutQuote) GetSwapFee() int64 { if m != nil { - return m.SwapFeeBase + return m.SwapFee } return 0 } +// Deprecated: Do not use. func (m *ServerLoopOutQuote) GetSwapFeeRate() int64 { if m != nil { return m.SwapFeeRate @@ -238,6 +250,7 @@ func (m *ServerLoopOutQuote) GetPrepayAmt() uint64 { return 0 } +// Deprecated: Do not use. func (m *ServerLoopOutQuote) GetMinSwapAmount() uint64 { if m != nil { return m.MinSwapAmount @@ -245,6 +258,7 @@ func (m *ServerLoopOutQuote) GetMinSwapAmount() uint64 { return 0 } +// Deprecated: Do not use. func (m *ServerLoopOutQuote) GetMaxSwapAmount() uint64 { if m != nil { return m.MaxSwapAmount @@ -259,6 +273,84 @@ func (m *ServerLoopOutQuote) GetCltvDelta() int32 { return 0 } +type ServerLoopOutTermsRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServerLoopOutTermsRequest) Reset() { *m = ServerLoopOutTermsRequest{} } +func (m *ServerLoopOutTermsRequest) String() string { return proto.CompactTextString(m) } +func (*ServerLoopOutTermsRequest) ProtoMessage() {} +func (*ServerLoopOutTermsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_ad098daeda4239f7, []int{4} +} + +func (m *ServerLoopOutTermsRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServerLoopOutTermsRequest.Unmarshal(m, b) +} +func (m *ServerLoopOutTermsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServerLoopOutTermsRequest.Marshal(b, m, deterministic) +} +func (m *ServerLoopOutTermsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServerLoopOutTermsRequest.Merge(m, src) +} +func (m *ServerLoopOutTermsRequest) XXX_Size() int { + return xxx_messageInfo_ServerLoopOutTermsRequest.Size(m) +} +func (m *ServerLoopOutTermsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ServerLoopOutTermsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ServerLoopOutTermsRequest proto.InternalMessageInfo + +type ServerLoopOutTerms struct { + MinSwapAmount uint64 `protobuf:"varint,1,opt,name=min_swap_amount,json=minSwapAmount,proto3" json:"min_swap_amount,omitempty"` + MaxSwapAmount uint64 `protobuf:"varint,2,opt,name=max_swap_amount,json=maxSwapAmount,proto3" json:"max_swap_amount,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServerLoopOutTerms) Reset() { *m = ServerLoopOutTerms{} } +func (m *ServerLoopOutTerms) String() string { return proto.CompactTextString(m) } +func (*ServerLoopOutTerms) ProtoMessage() {} +func (*ServerLoopOutTerms) Descriptor() ([]byte, []int) { + return fileDescriptor_ad098daeda4239f7, []int{5} +} + +func (m *ServerLoopOutTerms) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServerLoopOutTerms.Unmarshal(m, b) +} +func (m *ServerLoopOutTerms) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServerLoopOutTerms.Marshal(b, m, deterministic) +} +func (m *ServerLoopOutTerms) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServerLoopOutTerms.Merge(m, src) +} +func (m *ServerLoopOutTerms) XXX_Size() int { + return xxx_messageInfo_ServerLoopOutTerms.Size(m) +} +func (m *ServerLoopOutTerms) XXX_DiscardUnknown() { + xxx_messageInfo_ServerLoopOutTerms.DiscardUnknown(m) +} + +var xxx_messageInfo_ServerLoopOutTerms proto.InternalMessageInfo + +func (m *ServerLoopOutTerms) GetMinSwapAmount() uint64 { + if m != nil { + return m.MinSwapAmount + } + return 0 +} + +func (m *ServerLoopOutTerms) GetMaxSwapAmount() uint64 { + if m != nil { + return m.MaxSwapAmount + } + return 0 +} + type ServerLoopInRequest struct { SenderKey []byte `protobuf:"bytes,1,opt,name=sender_key,json=senderKey,proto3" json:"sender_key,omitempty"` SwapHash []byte `protobuf:"bytes,2,opt,name=swap_hash,json=swapHash,proto3" json:"swap_hash,omitempty"` @@ -273,7 +365,7 @@ func (m *ServerLoopInRequest) Reset() { *m = ServerLoopInRequest{} } func (m *ServerLoopInRequest) String() string { return proto.CompactTextString(m) } func (*ServerLoopInRequest) ProtoMessage() {} func (*ServerLoopInRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_ad098daeda4239f7, []int{4} + return fileDescriptor_ad098daeda4239f7, []int{6} } func (m *ServerLoopInRequest) XXX_Unmarshal(b []byte) error { @@ -334,7 +426,7 @@ func (m *ServerLoopInResponse) Reset() { *m = ServerLoopInResponse{} } func (m *ServerLoopInResponse) String() string { return proto.CompactTextString(m) } func (*ServerLoopInResponse) ProtoMessage() {} func (*ServerLoopInResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad098daeda4239f7, []int{5} + return fileDescriptor_ad098daeda4239f7, []int{7} } func (m *ServerLoopInResponse) XXX_Unmarshal(b []byte) error { @@ -370,6 +462,8 @@ func (m *ServerLoopInResponse) GetExpiry() int32 { } type ServerLoopInQuoteRequest struct { + /// The swap amount. If zero, a quote for a maximum amt swap will be given. + Amt uint64 `protobuf:"varint,1,opt,name=amt,proto3" json:"amt,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -379,7 +473,7 @@ func (m *ServerLoopInQuoteRequest) Reset() { *m = ServerLoopInQuoteReque func (m *ServerLoopInQuoteRequest) String() string { return proto.CompactTextString(m) } func (*ServerLoopInQuoteRequest) ProtoMessage() {} func (*ServerLoopInQuoteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_ad098daeda4239f7, []int{6} + return fileDescriptor_ad098daeda4239f7, []int{8} } func (m *ServerLoopInQuoteRequest) XXX_Unmarshal(b []byte) error { @@ -400,11 +494,18 @@ func (m *ServerLoopInQuoteRequest) XXX_DiscardUnknown() { var xxx_messageInfo_ServerLoopInQuoteRequest proto.InternalMessageInfo +func (m *ServerLoopInQuoteRequest) GetAmt() uint64 { + if m != nil { + return m.Amt + } + return 0 +} + type ServerLoopInQuoteResponse struct { - SwapFeeBase int64 `protobuf:"varint,1,opt,name=swap_fee_base,json=swapFeeBase,proto3" json:"swap_fee_base,omitempty"` - SwapFeeRate int64 `protobuf:"varint,2,opt,name=swap_fee_rate,json=swapFeeRate,proto3" json:"swap_fee_rate,omitempty"` - MinSwapAmount uint64 `protobuf:"varint,4,opt,name=min_swap_amount,json=minSwapAmount,proto3" json:"min_swap_amount,omitempty"` - MaxSwapAmount uint64 `protobuf:"varint,5,opt,name=max_swap_amount,json=maxSwapAmount,proto3" json:"max_swap_amount,omitempty"` + SwapFee int64 `protobuf:"varint,1,opt,name=swap_fee,json=swapFee,proto3" json:"swap_fee,omitempty"` + SwapFeeRate int64 `protobuf:"varint,2,opt,name=swap_fee_rate,json=swapFeeRate,proto3" json:"swap_fee_rate,omitempty"` // Deprecated: Do not use. + MinSwapAmount uint64 `protobuf:"varint,4,opt,name=min_swap_amount,json=minSwapAmount,proto3" json:"min_swap_amount,omitempty"` // Deprecated: Do not use. + MaxSwapAmount uint64 `protobuf:"varint,5,opt,name=max_swap_amount,json=maxSwapAmount,proto3" json:"max_swap_amount,omitempty"` // Deprecated: Do not use. CltvDelta int32 `protobuf:"varint,6,opt,name=cltv_delta,json=cltvDelta,proto3" json:"cltv_delta,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -415,7 +516,7 @@ func (m *ServerLoopInQuoteResponse) Reset() { *m = ServerLoopInQuoteResp func (m *ServerLoopInQuoteResponse) String() string { return proto.CompactTextString(m) } func (*ServerLoopInQuoteResponse) ProtoMessage() {} func (*ServerLoopInQuoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad098daeda4239f7, []int{7} + return fileDescriptor_ad098daeda4239f7, []int{9} } func (m *ServerLoopInQuoteResponse) XXX_Unmarshal(b []byte) error { @@ -436,13 +537,14 @@ func (m *ServerLoopInQuoteResponse) XXX_DiscardUnknown() { var xxx_messageInfo_ServerLoopInQuoteResponse proto.InternalMessageInfo -func (m *ServerLoopInQuoteResponse) GetSwapFeeBase() int64 { +func (m *ServerLoopInQuoteResponse) GetSwapFee() int64 { if m != nil { - return m.SwapFeeBase + return m.SwapFee } return 0 } +// Deprecated: Do not use. func (m *ServerLoopInQuoteResponse) GetSwapFeeRate() int64 { if m != nil { return m.SwapFeeRate @@ -450,6 +552,7 @@ func (m *ServerLoopInQuoteResponse) GetSwapFeeRate() int64 { return 0 } +// Deprecated: Do not use. func (m *ServerLoopInQuoteResponse) GetMinSwapAmount() uint64 { if m != nil { return m.MinSwapAmount @@ -457,6 +560,7 @@ func (m *ServerLoopInQuoteResponse) GetMinSwapAmount() uint64 { return 0 } +// Deprecated: Do not use. func (m *ServerLoopInQuoteResponse) GetMaxSwapAmount() uint64 { if m != nil { return m.MaxSwapAmount @@ -471,58 +575,144 @@ func (m *ServerLoopInQuoteResponse) GetCltvDelta() int32 { return 0 } +type ServerLoopInTermsRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServerLoopInTermsRequest) Reset() { *m = ServerLoopInTermsRequest{} } +func (m *ServerLoopInTermsRequest) String() string { return proto.CompactTextString(m) } +func (*ServerLoopInTermsRequest) ProtoMessage() {} +func (*ServerLoopInTermsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_ad098daeda4239f7, []int{10} +} + +func (m *ServerLoopInTermsRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServerLoopInTermsRequest.Unmarshal(m, b) +} +func (m *ServerLoopInTermsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServerLoopInTermsRequest.Marshal(b, m, deterministic) +} +func (m *ServerLoopInTermsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServerLoopInTermsRequest.Merge(m, src) +} +func (m *ServerLoopInTermsRequest) XXX_Size() int { + return xxx_messageInfo_ServerLoopInTermsRequest.Size(m) +} +func (m *ServerLoopInTermsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ServerLoopInTermsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ServerLoopInTermsRequest proto.InternalMessageInfo + +type ServerLoopInTerms struct { + MinSwapAmount uint64 `protobuf:"varint,1,opt,name=min_swap_amount,json=minSwapAmount,proto3" json:"min_swap_amount,omitempty"` + MaxSwapAmount uint64 `protobuf:"varint,2,opt,name=max_swap_amount,json=maxSwapAmount,proto3" json:"max_swap_amount,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServerLoopInTerms) Reset() { *m = ServerLoopInTerms{} } +func (m *ServerLoopInTerms) String() string { return proto.CompactTextString(m) } +func (*ServerLoopInTerms) ProtoMessage() {} +func (*ServerLoopInTerms) Descriptor() ([]byte, []int) { + return fileDescriptor_ad098daeda4239f7, []int{11} +} + +func (m *ServerLoopInTerms) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServerLoopInTerms.Unmarshal(m, b) +} +func (m *ServerLoopInTerms) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServerLoopInTerms.Marshal(b, m, deterministic) +} +func (m *ServerLoopInTerms) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServerLoopInTerms.Merge(m, src) +} +func (m *ServerLoopInTerms) XXX_Size() int { + return xxx_messageInfo_ServerLoopInTerms.Size(m) +} +func (m *ServerLoopInTerms) XXX_DiscardUnknown() { + xxx_messageInfo_ServerLoopInTerms.DiscardUnknown(m) +} + +var xxx_messageInfo_ServerLoopInTerms proto.InternalMessageInfo + +func (m *ServerLoopInTerms) GetMinSwapAmount() uint64 { + if m != nil { + return m.MinSwapAmount + } + return 0 +} + +func (m *ServerLoopInTerms) GetMaxSwapAmount() uint64 { + if m != nil { + return m.MaxSwapAmount + } + return 0 +} + func init() { proto.RegisterType((*ServerLoopOutRequest)(nil), "looprpc.ServerLoopOutRequest") proto.RegisterType((*ServerLoopOutResponse)(nil), "looprpc.ServerLoopOutResponse") proto.RegisterType((*ServerLoopOutQuoteRequest)(nil), "looprpc.ServerLoopOutQuoteRequest") proto.RegisterType((*ServerLoopOutQuote)(nil), "looprpc.ServerLoopOutQuote") + proto.RegisterType((*ServerLoopOutTermsRequest)(nil), "looprpc.ServerLoopOutTermsRequest") + proto.RegisterType((*ServerLoopOutTerms)(nil), "looprpc.ServerLoopOutTerms") proto.RegisterType((*ServerLoopInRequest)(nil), "looprpc.ServerLoopInRequest") proto.RegisterType((*ServerLoopInResponse)(nil), "looprpc.ServerLoopInResponse") proto.RegisterType((*ServerLoopInQuoteRequest)(nil), "looprpc.ServerLoopInQuoteRequest") proto.RegisterType((*ServerLoopInQuoteResponse)(nil), "looprpc.ServerLoopInQuoteResponse") + proto.RegisterType((*ServerLoopInTermsRequest)(nil), "looprpc.ServerLoopInTermsRequest") + proto.RegisterType((*ServerLoopInTerms)(nil), "looprpc.ServerLoopInTerms") } func init() { proto.RegisterFile("server.proto", fileDescriptor_ad098daeda4239f7) } var fileDescriptor_ad098daeda4239f7 = []byte{ - // 589 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd, 0x6e, 0xd3, 0x4c, - 0x14, 0x94, 0x9d, 0x34, 0xfd, 0x72, 0x9a, 0xb4, 0x1f, 0xcb, 0x8f, 0x4c, 0xda, 0xa0, 0xd6, 0x52, - 0xa1, 0xe2, 0x22, 0x91, 0xe0, 0x09, 0x5a, 0x55, 0x88, 0x8a, 0x8a, 0x52, 0x97, 0x2b, 0x6e, 0xac, - 0x4d, 0x72, 0x88, 0x2d, 0xec, 0xdd, 0xc5, 0xbb, 0xf9, 0x7b, 0x01, 0x1e, 0x01, 0xf1, 0x5c, 0x7d, - 0x22, 0xb4, 0xeb, 0x4d, 0x62, 0x27, 0xe9, 0x0f, 0x77, 0xed, 0x9c, 0xf1, 0xd9, 0xd9, 0x99, 0xc9, - 0x42, 0x43, 0x62, 0x36, 0xc6, 0xac, 0x23, 0x32, 0xae, 0x38, 0xd9, 0x4e, 0x38, 0x17, 0x99, 0xe8, - 0xb7, 0x0e, 0x86, 0x9c, 0x0f, 0x13, 0xec, 0x52, 0x11, 0x77, 0x29, 0x63, 0x5c, 0x51, 0x15, 0x73, - 0x26, 0x73, 0x9a, 0x1f, 0xc1, 0xb3, 0x1b, 0xf3, 0xd9, 0x25, 0xe7, 0xe2, 0x6a, 0xa4, 0x02, 0xfc, - 0x39, 0x42, 0xa9, 0xc8, 0x11, 0x34, 0x32, 0xec, 0x63, 0x3c, 0xc6, 0x2c, 0xfc, 0x81, 0x33, 0xcf, - 0x39, 0x74, 0x4e, 0x1a, 0xc1, 0xce, 0x1c, 0xfb, 0x84, 0x33, 0xb2, 0x0f, 0x75, 0x39, 0xa1, 0x22, - 0x8c, 0xa8, 0x8c, 0x3c, 0xd7, 0xcc, 0xff, 0xd3, 0xc0, 0x47, 0x2a, 0x23, 0xf2, 0x3f, 0x54, 0x68, - 0xaa, 0xbc, 0xca, 0xa1, 0x73, 0x52, 0x0d, 0xf4, 0x9f, 0xfe, 0x1f, 0x07, 0x9e, 0xaf, 0x1c, 0x25, - 0x05, 0x67, 0x12, 0xf5, 0x59, 0x66, 0x51, 0xcc, 0xc6, 0x3c, 0xee, 0xa3, 0x39, 0xab, 0x1e, 0xec, - 0x68, 0xec, 0x22, 0x87, 0xc8, 0x31, 0xec, 0x8a, 0x0c, 0x05, 0x9d, 0x2d, 0x48, 0xae, 0x21, 0x35, - 0x73, 0x74, 0x4e, 0x6b, 0x03, 0x48, 0x64, 0x03, 0xab, 0xb9, 0x62, 0x34, 0xd5, 0x73, 0x44, 0x2b, - 0x7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 0xcb, 0x46, 0xb8, 0xa5, 0x46, 0xb4, 0xc0, 0x2b, 0xae, 0x2c, - 0x15, 0xe2, 0xd6, 0x29, 0xd6, 0x65, 0x31, 0xb4, 0x87, 0xae, 0x65, 0xed, 0x3c, 0x22, 0x6b, 0x77, - 0x3d, 0xeb, 0x0d, 0x61, 0x56, 0x1f, 0x19, 0xe6, 0xd6, 0xc3, 0x61, 0xd6, 0x56, 0xc2, 0x7c, 0x77, - 0xeb, 0x02, 0x68, 0x76, 0x7e, 0x31, 0x72, 0x05, 0xbb, 0x9f, 0x71, 0x62, 0x0b, 0xaf, 0x71, 0xd2, - 0xee, 0xd8, 0x07, 0xa5, 0xb3, 0xe9, 0xbd, 0x68, 0xbd, 0xba, 0x6b, 0x6c, 0x6d, 0xb9, 0x82, 0x46, - 0xe9, 0xe7, 0xe3, 0x6f, 0xe6, 0x17, 0x8d, 0x6e, 0xed, 0xdf, 0xc3, 0x21, 0x97, 0xd0, 0xb4, 0x0a, - 0x2f, 0x8c, 0x1d, 0xe4, 0x60, 0x03, 0x7b, 0x51, 0xca, 0x56, 0xfb, 0x8e, 0xa9, 0x95, 0xf7, 0x15, - 0x76, 0x0a, 0x61, 0x92, 0xa3, 0x8d, 0xec, 0x92, 0x38, 0xff, 0x3e, 0x4a, 0xbe, 0xf5, 0xec, 0xcd, - 0xb7, 0xe3, 0x61, 0xac, 0xa2, 0x51, 0xaf, 0xd3, 0xe7, 0x69, 0x37, 0x89, 0x87, 0x91, 0x62, 0x31, - 0x1b, 0x26, 0xb4, 0x27, 0xbb, 0xfa, 0xeb, 0xae, 0x5d, 0xd1, 0xab, 0x99, 0xc7, 0xf8, 0xfd, 0xdf, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x94, 0xad, 0x2a, 0x29, 0xc3, 0x05, 0x00, 0x00, + // 641 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x6b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x9a, + 0xca, 0xe6, 0xae, 0x17, 0x0a, 0xf5, 0xb7, 0xaa, 0x41, 0x61, 0x3e, 0x4f, 0x4d, 0x0a, 0x75, 0x83, + 0x33, 0x58, 0xc9, 0x1b, 0xbc, 0x53, 0xc3, 0x2d, 0x5e, 0x4c, 0xbf, 0xdf, 0x4c, 0x21, 0x67, 0xd0, + 0x33, 0xfb, 0x9e, 0xaa, 0xeb, 0x20, 0x5b, 0xb5, 0xe4, 0xac, 0xd5, 0xa0, 0xa1, 0x6a, 0x96, 0xbd, + 0xca, 0xb4, 0x69, 0xa9, 0xf5, 0xda, 0x0a, 0xab, 0x7a, 0xf7, 0x51, 0x74, 0xd7, 0xcf, 0x6d, 0xf5, + 0x83, 0xf9, 0xf6, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0xf9, 0x2f, 0x6f, 0x67, 0x07, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -537,8 +727,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type SwapServerClient interface { + LoopOutTerms(ctx context.Context, in *ServerLoopOutTermsRequest, opts ...grpc.CallOption) (*ServerLoopOutTerms, error) NewLoopOutSwap(ctx context.Context, in *ServerLoopOutRequest, opts ...grpc.CallOption) (*ServerLoopOutResponse, error) LoopOutQuote(ctx context.Context, in *ServerLoopOutQuoteRequest, opts ...grpc.CallOption) (*ServerLoopOutQuote, error) + LoopInTerms(ctx context.Context, in *ServerLoopInTermsRequest, opts ...grpc.CallOption) (*ServerLoopInTerms, error) NewLoopInSwap(ctx context.Context, in *ServerLoopInRequest, opts ...grpc.CallOption) (*ServerLoopInResponse, error) LoopInQuote(ctx context.Context, in *ServerLoopInQuoteRequest, opts ...grpc.CallOption) (*ServerLoopInQuoteResponse, error) } @@ -551,6 +743,15 @@ func NewSwapServerClient(cc *grpc.ClientConn) SwapServerClient { return &swapServerClient{cc} } +func (c *swapServerClient) LoopOutTerms(ctx context.Context, in *ServerLoopOutTermsRequest, opts ...grpc.CallOption) (*ServerLoopOutTerms, error) { + out := new(ServerLoopOutTerms) + err := c.cc.Invoke(ctx, "/looprpc.SwapServer/LoopOutTerms", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *swapServerClient) NewLoopOutSwap(ctx context.Context, in *ServerLoopOutRequest, opts ...grpc.CallOption) (*ServerLoopOutResponse, error) { out := new(ServerLoopOutResponse) err := c.cc.Invoke(ctx, "/looprpc.SwapServer/NewLoopOutSwap", in, out, opts...) @@ -569,6 +770,15 @@ func (c *swapServerClient) LoopOutQuote(ctx context.Context, in *ServerLoopOutQu return out, nil } +func (c *swapServerClient) LoopInTerms(ctx context.Context, in *ServerLoopInTermsRequest, opts ...grpc.CallOption) (*ServerLoopInTerms, error) { + out := new(ServerLoopInTerms) + err := c.cc.Invoke(ctx, "/looprpc.SwapServer/LoopInTerms", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *swapServerClient) NewLoopInSwap(ctx context.Context, in *ServerLoopInRequest, opts ...grpc.CallOption) (*ServerLoopInResponse, error) { out := new(ServerLoopInResponse) err := c.cc.Invoke(ctx, "/looprpc.SwapServer/NewLoopInSwap", in, out, opts...) @@ -589,8 +799,10 @@ func (c *swapServerClient) LoopInQuote(ctx context.Context, in *ServerLoopInQuot // SwapServerServer is the server API for SwapServer service. type SwapServerServer interface { + LoopOutTerms(context.Context, *ServerLoopOutTermsRequest) (*ServerLoopOutTerms, error) NewLoopOutSwap(context.Context, *ServerLoopOutRequest) (*ServerLoopOutResponse, error) LoopOutQuote(context.Context, *ServerLoopOutQuoteRequest) (*ServerLoopOutQuote, error) + LoopInTerms(context.Context, *ServerLoopInTermsRequest) (*ServerLoopInTerms, error) NewLoopInSwap(context.Context, *ServerLoopInRequest) (*ServerLoopInResponse, error) LoopInQuote(context.Context, *ServerLoopInQuoteRequest) (*ServerLoopInQuoteResponse, error) } @@ -599,6 +811,24 @@ func RegisterSwapServerServer(s *grpc.Server, srv SwapServerServer) { s.RegisterService(&_SwapServer_serviceDesc, srv) } +func _SwapServer_LoopOutTerms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ServerLoopOutTermsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwapServerServer).LoopOutTerms(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/looprpc.SwapServer/LoopOutTerms", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwapServerServer).LoopOutTerms(ctx, req.(*ServerLoopOutTermsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _SwapServer_NewLoopOutSwap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ServerLoopOutRequest) if err := dec(in); err != nil { @@ -635,6 +865,24 @@ func _SwapServer_LoopOutQuote_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _SwapServer_LoopInTerms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ServerLoopInTermsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwapServerServer).LoopInTerms(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/looprpc.SwapServer/LoopInTerms", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwapServerServer).LoopInTerms(ctx, req.(*ServerLoopInTermsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _SwapServer_NewLoopInSwap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ServerLoopInRequest) if err := dec(in); err != nil { @@ -675,6 +923,10 @@ var _SwapServer_serviceDesc = grpc.ServiceDesc{ ServiceName: "looprpc.SwapServer", HandlerType: (*SwapServerServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "LoopOutTerms", + Handler: _SwapServer_LoopOutTerms_Handler, + }, { MethodName: "NewLoopOutSwap", Handler: _SwapServer_NewLoopOutSwap_Handler, @@ -683,6 +935,10 @@ var _SwapServer_serviceDesc = grpc.ServiceDesc{ MethodName: "LoopOutQuote", Handler: _SwapServer_LoopOutQuote_Handler, }, + { + MethodName: "LoopInTerms", + Handler: _SwapServer_LoopInTerms_Handler, + }, { MethodName: "NewLoopInSwap", Handler: _SwapServer_NewLoopInSwap_Handler, diff --git a/looprpc/server.proto b/looprpc/server.proto index 7b1a73b..dd1ca10 100644 --- a/looprpc/server.proto +++ b/looprpc/server.proto @@ -4,13 +4,15 @@ import "google/api/annotations.proto"; package looprpc; -option go_package = "github.com/lightninglabs/loop/looprpc"; - service SwapServer { + rpc LoopOutTerms(ServerLoopOutTermsRequest) returns (ServerLoopOutTerms); + rpc NewLoopOutSwap(ServerLoopOutRequest) returns (ServerLoopOutResponse); - + rpc LoopOutQuote(ServerLoopOutQuoteRequest) returns (ServerLoopOutQuote); + rpc LoopInTerms(ServerLoopInTermsRequest) returns (ServerLoopInTerms); + rpc NewLoopInSwap(ServerLoopInRequest) returns (ServerLoopInResponse); rpc LoopInQuote(ServerLoopInQuoteRequest) returns (ServerLoopInQuoteResponse); @@ -35,24 +37,36 @@ message ServerLoopOutResponse { } message ServerLoopOutQuoteRequest { + /// The swap amount. If zero, a quote for a maximum amt swap will be given. + uint64 amt = 1; } message ServerLoopOutQuote { string swap_payment_dest = 1; - int64 swap_fee_base = 2; + /// The total estimated swap fee given the quote amt. + int64 swap_fee = 2; - int64 swap_fee_rate = 3; + /// Deprecated, total swap fee given quote amt is calculated in swap_fee. + int64 swap_fee_rate = 3 [deprecated = true]; uint64 prepay_amt = 4; - uint64 min_swap_amount = 5; + uint64 min_swap_amount = 5 [deprecated = true]; - uint64 max_swap_amount = 6; + uint64 max_swap_amount = 6 [deprecated = true]; int32 cltv_delta = 7; } +message ServerLoopOutTermsRequest { +} + +message ServerLoopOutTerms { + uint64 min_swap_amount = 1; + uint64 max_swap_amount = 2; +} + message ServerLoopInRequest { bytes sender_key = 1; bytes swap_hash = 2; @@ -66,12 +80,22 @@ message ServerLoopInResponse { } message ServerLoopInQuoteRequest { + /// The swap amount. If zero, a quote for a maximum amt swap will be given. + uint64 amt = 1; } message ServerLoopInQuoteResponse { - int64 swap_fee_base = 1; - int64 swap_fee_rate = 2; - uint64 min_swap_amount = 4; - uint64 max_swap_amount = 5; + int64 swap_fee = 1; + int64 swap_fee_rate = 2 [deprecated=true]; + uint64 min_swap_amount = 4 [deprecated=true]; + uint64 max_swap_amount = 5 [deprecated=true]; int32 cltv_delta = 6; -} \ No newline at end of file +} + +message ServerLoopInTermsRequest { +} + +message ServerLoopInTerms { + uint64 min_swap_amount = 1; + uint64 max_swap_amount = 2; +} diff --git a/server_mock_test.go b/server_mock_test.go index 9c59fe6..44cc555 100644 --- a/server_mock_test.go +++ b/server_mock_test.go @@ -21,8 +21,7 @@ var ( testLoopOutOnChainCltvDelta = int32(30) testChargeOnChainCltvDelta = int32(100) testCltvDelta = 50 - testSwapFeeBase = btcutil.Amount(21) - testSwapFeeRate = int64(100) + testSwapFee = btcutil.Amount(210) testInvoiceExpiry = 180 * time.Second testFixedPrepayAmount = btcutil.Amount(100) testMinSwapAmount = btcutil.Amount(10000) @@ -45,6 +44,8 @@ type serverMock struct { swapHash lntypes.Hash } +var _ swapServerClient = (*serverMock)(nil) + func newServerMock() *serverMock { return &serverMock{ expectedSwapAmt: 50000, @@ -94,16 +95,22 @@ func (s *serverMock) NewLoopOutSwap(ctx context.Context, func (s *serverMock) GetLoopOutTerms(ctx context.Context) ( *LoopOutTerms, error) { + return &LoopOutTerms{ + MinSwapAmount: testMinSwapAmount, + MaxSwapAmount: testMaxSwapAmount, + }, nil +} + +func (s *serverMock) GetLoopOutQuote(ctx context.Context, amt btcutil.Amount) ( + *LoopOutQuote, error) { + dest := [33]byte{1, 2, 3} - return &LoopOutTerms{ - SwapFeeBase: testSwapFeeBase, - SwapFeeRate: testSwapFeeRate, + return &LoopOutQuote{ + SwapFee: testSwapFee, SwapPaymentDest: dest, CltvDelta: testLoopOutOnChainCltvDelta, - MinSwapAmount: testMinSwapAmount, - MaxSwapAmount: testMaxSwapAmount, - PrepayAmt: testFixedPrepayAmount, + PrepayAmount: testFixedPrepayAmount, }, nil } @@ -154,10 +161,16 @@ func (s *serverMock) GetLoopInTerms(ctx context.Context) ( *LoopInTerms, error) { return &LoopInTerms{ - SwapFeeBase: testSwapFeeBase, - SwapFeeRate: testSwapFeeRate, - CltvDelta: testChargeOnChainCltvDelta, MinSwapAmount: testMinSwapAmount, MaxSwapAmount: testMaxSwapAmount, }, nil } + +func (s *serverMock) GetLoopInQuote(ctx context.Context, amt btcutil.Amount) ( + *LoopInQuote, error) { + + return &LoopInQuote{ + SwapFee: testSwapFee, + CltvDelta: testChargeOnChainCltvDelta, + }, nil +} diff --git a/swap_server_client.go b/swap_server_client.go index 466ea64..527cc0d 100644 --- a/swap_server_client.go +++ b/swap_server_client.go @@ -20,9 +20,15 @@ type swapServerClient interface { GetLoopOutTerms(ctx context.Context) ( *LoopOutTerms, error) + GetLoopOutQuote(ctx context.Context, amt btcutil.Amount) ( + *LoopOutQuote, error) + GetLoopInTerms(ctx context.Context) ( *LoopInTerms, error) + GetLoopInQuote(ctx context.Context, amt btcutil.Amount) ( + *LoopInQuote, error) + NewLoopOutSwap(ctx context.Context, swapHash lntypes.Hash, amount btcutil.Amount, receiverKey [33]byte) ( @@ -39,6 +45,8 @@ type grpcSwapServerClient struct { conn *grpc.ClientConn } +var _ swapServerClient = (*grpcSwapServerClient)(nil) + func newSwapServerClient(address string, insecure bool) (*grpcSwapServerClient, error) { @@ -58,10 +66,30 @@ func newSwapServerClient(address string, func (s *grpcSwapServerClient) GetLoopOutTerms(ctx context.Context) ( *LoopOutTerms, error) { + rpcCtx, rpcCancel := context.WithTimeout(ctx, serverRPCTimeout) + defer rpcCancel() + terms, err := s.server.LoopOutTerms(rpcCtx, + &looprpc.ServerLoopOutTermsRequest{}, + ) + if err != nil { + return nil, err + } + + return &LoopOutTerms{ + MinSwapAmount: btcutil.Amount(terms.MinSwapAmount), + MaxSwapAmount: btcutil.Amount(terms.MaxSwapAmount), + }, nil +} + +func (s *grpcSwapServerClient) GetLoopOutQuote(ctx context.Context, + amt btcutil.Amount) (*LoopOutQuote, error) { + rpcCtx, rpcCancel := context.WithTimeout(ctx, serverRPCTimeout) defer rpcCancel() quoteResp, err := s.server.LoopOutQuote(rpcCtx, - &looprpc.ServerLoopOutQuoteRequest{}, + &looprpc.ServerLoopOutQuoteRequest{ + Amt: uint64(amt), + }, ) if err != nil { return nil, err @@ -77,12 +105,9 @@ func (s *grpcSwapServerClient) GetLoopOutTerms(ctx context.Context) ( var destArray [33]byte copy(destArray[:], dest) - return &LoopOutTerms{ - MinSwapAmount: btcutil.Amount(quoteResp.MinSwapAmount), - MaxSwapAmount: btcutil.Amount(quoteResp.MaxSwapAmount), - PrepayAmt: btcutil.Amount(quoteResp.PrepayAmt), - SwapFeeBase: btcutil.Amount(quoteResp.SwapFeeBase), - SwapFeeRate: quoteResp.SwapFeeRate, + return &LoopOutQuote{ + PrepayAmount: btcutil.Amount(quoteResp.PrepayAmt), + SwapFee: btcutil.Amount(quoteResp.SwapFee), CltvDelta: quoteResp.CltvDelta, SwapPaymentDest: destArray, }, nil @@ -93,19 +118,36 @@ func (s *grpcSwapServerClient) GetLoopInTerms(ctx context.Context) ( rpcCtx, rpcCancel := context.WithTimeout(ctx, serverRPCTimeout) defer rpcCancel() - quoteResp, err := s.server.LoopInQuote(rpcCtx, - &looprpc.ServerLoopInQuoteRequest{}, + terms, err := s.server.LoopInTerms(rpcCtx, + &looprpc.ServerLoopInTermsRequest{}, ) if err != nil { return nil, err } return &LoopInTerms{ - MinSwapAmount: btcutil.Amount(quoteResp.MinSwapAmount), - MaxSwapAmount: btcutil.Amount(quoteResp.MaxSwapAmount), - SwapFeeBase: btcutil.Amount(quoteResp.SwapFeeBase), - SwapFeeRate: quoteResp.SwapFeeRate, - CltvDelta: quoteResp.CltvDelta, + MinSwapAmount: btcutil.Amount(terms.MinSwapAmount), + MaxSwapAmount: btcutil.Amount(terms.MaxSwapAmount), + }, nil +} + +func (s *grpcSwapServerClient) GetLoopInQuote(ctx context.Context, + amt btcutil.Amount) (*LoopInQuote, error) { + + rpcCtx, rpcCancel := context.WithTimeout(ctx, serverRPCTimeout) + defer rpcCancel() + quoteResp, err := s.server.LoopInQuote(rpcCtx, + &looprpc.ServerLoopInQuoteRequest{ + Amt: uint64(amt), + }, + ) + if err != nil { + return nil, err + } + + return &LoopInQuote{ + SwapFee: btcutil.Amount(quoteResp.SwapFee), + CltvDelta: quoteResp.CltvDelta, }, nil }