multi: use reservation ids in instant out quote

This commit is contained in:
sputn1ck 2025-04-08 09:51:16 +02:00
parent e76321b425
commit 1ce9bdd0d3
No known key found for this signature in database
GPG key ID: 671103D881A5F0E4
3 changed files with 8 additions and 7 deletions

View file

@ -157,8 +157,8 @@ func instantOut(ctx *cli.Context) error {
// fee-rates.
quote, err := client.InstantOutQuote(
context.Background(), &looprpc.InstantOutQuoteRequest{
Amt: selectedAmt,
NumReservations: int32(len(selectedReservations)),
Amt: selectedAmt,
ReservationIds: selectedReservations,
},
)
if err != nil {

View file

@ -218,9 +218,9 @@ type Quote struct {
// GetInstantOutQuote returns a quote for an instant out.
func (m *Manager) GetInstantOutQuote(ctx context.Context,
amt btcutil.Amount, numReservations int) (Quote, error) {
amt btcutil.Amount, reservationIDs [][]byte) (Quote, error) {
if numReservations <= 0 {
if len(reservationIDs) == 0 {
return Quote{}, fmt.Errorf("no reservations selected")
}
@ -231,7 +231,8 @@ func (m *Manager) GetInstantOutQuote(ctx context.Context,
// Get the service fee.
quoteRes, err := m.cfg.InstantOutClient.GetInstantOutQuote(
ctx, &swapserverrpc.GetInstantOutQuoteRequest{
Amount: uint64(amt),
Amount: uint64(amt),
ReservationIds: reservationIDs,
},
)
if err != nil {
@ -247,7 +248,7 @@ func (m *Manager) GetInstantOutQuote(ctx context.Context,
// The on chain chainFee is the chainFee rate times the estimated
// sweepless sweep transaction size.
chainFee := feeRate.FeeForWeight(sweeplessSweepWeight(numReservations))
chainFee := feeRate.FeeForWeight(sweeplessSweepWeight(len(reservationIDs)))
return Quote{
ServiceFee: btcutil.Amount(quoteRes.SwapFee),

View file

@ -1446,7 +1446,7 @@ func (s *swapClientServer) InstantOutQuote(ctx context.Context,
*looprpc.InstantOutQuoteResponse, error) {
quote, err := s.instantOutManager.GetInstantOutQuote(
ctx, btcutil.Amount(req.Amt), int(req.NumReservations),
ctx, btcutil.Amount(req.Amt), req.ReservationIds,
)
if err != nil {
return nil, err