Skip to content

Commit 2bc5df2

Browse files
authored
Merge pull request #918 from sputn1ck/reservations_quote
Use reservation ids in instant out quote
2 parents cb18240 + 1ce9bdd commit 2bc5df2

File tree

7 files changed

+598
-561
lines changed

7 files changed

+598
-561
lines changed

cmd/loop/instantout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ func instantOut(ctx *cli.Context) error {
157157
// fee-rates.
158158
quote, err := client.InstantOutQuote(
159159
context.Background(), &looprpc.InstantOutQuoteRequest{
160-
Amt: selectedAmt,
161-
NumReservations: int32(len(selectedReservations)),
160+
Amt: selectedAmt,
161+
ReservationIds: selectedReservations,
162162
},
163163
)
164164
if err != nil {

instantout/manager.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ type Quote struct {
218218

219219
// GetInstantOutQuote returns a quote for an instant out.
220220
func (m *Manager) GetInstantOutQuote(ctx context.Context,
221-
amt btcutil.Amount, numReservations int) (Quote, error) {
221+
amt btcutil.Amount, reservationIDs [][]byte) (Quote, error) {
222222

223-
if numReservations <= 0 {
223+
if len(reservationIDs) == 0 {
224224
return Quote{}, fmt.Errorf("no reservations selected")
225225
}
226226

@@ -231,7 +231,8 @@ func (m *Manager) GetInstantOutQuote(ctx context.Context,
231231
// Get the service fee.
232232
quoteRes, err := m.cfg.InstantOutClient.GetInstantOutQuote(
233233
ctx, &swapserverrpc.GetInstantOutQuoteRequest{
234-
Amount: uint64(amt),
234+
Amount: uint64(amt),
235+
ReservationIds: reservationIDs,
235236
},
236237
)
237238
if err != nil {
@@ -247,7 +248,7 @@ func (m *Manager) GetInstantOutQuote(ctx context.Context,
247248

248249
// The on chain chainFee is the chainFee rate times the estimated
249250
// sweepless sweep transaction size.
250-
chainFee := feeRate.FeeForWeight(sweeplessSweepWeight(numReservations))
251+
chainFee := feeRate.FeeForWeight(sweeplessSweepWeight(len(reservationIDs)))
251252

252253
return Quote{
253254
ServiceFee: btcutil.Amount(quoteRes.SwapFee),

loopd/swapclient_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ func (s *swapClientServer) InstantOutQuote(ctx context.Context,
14461446
*looprpc.InstantOutQuoteResponse, error) {
14471447

14481448
quote, err := s.instantOutManager.GetInstantOutQuote(
1449-
ctx, btcutil.Amount(req.Amt), int(req.NumReservations),
1449+
ctx, btcutil.Amount(req.Amt), req.ReservationIds,
14501450
)
14511451
if err != nil {
14521452
return nil, err

looprpc/client.pb.go

Lines changed: 516 additions & 500 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,9 +1532,15 @@ message InstantOutQuoteRequest {
15321532
uint64 amt = 1;
15331533

15341534
/*
1535+
Deprecated: use 'reservation_ids' instead.
15351536
The amount of reservations to use for the swap.
15361537
*/
1537-
int32 num_reservations = 2;
1538+
int32 num_reservations = 2 [deprecated = true];
1539+
1540+
/*
1541+
The reservations to use for the swap.
1542+
*/
1543+
repeated bytes reservation_ids = 3;
15381544
}
15391545

15401546
message InstantOutQuoteResponse {

swapserverrpc/instantout.pb.go

Lines changed: 64 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swapserverrpc/instantout.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ message CancelInstantSwapResponse {
141141
message GetInstantOutQuoteRequest {
142142
// The amount to swap in satoshis.
143143
uint64 amount = 1;
144+
145+
// The reservation ids that will be used for the swap.
146+
repeated bytes reservation_ids = 2;
144147
}
145148

146149
message GetInstantOutQuoteResponse {

0 commit comments

Comments
 (0)