mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: use reservation ids in instant out quote
This commit is contained in:
parent
e76321b425
commit
1ce9bdd0d3
3 changed files with 8 additions and 7 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue