mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-09 18:52:09 +02:00
routerrpc: add SendToRouteV2 that returns an HTLCAttempt message
Unify data structure with SendPayment/ListPayments.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package routerrpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -93,3 +94,27 @@ func (s *Server) SendPayment(request *SendPaymentRequest,
|
||||
}
|
||||
return s.SendPaymentV2(request, &legacyStream)
|
||||
}
|
||||
|
||||
// SendToRoute sends a payment through a predefined route. The response of this
|
||||
// call contains structured error information.
|
||||
func (s *Server) SendToRoute(ctx context.Context,
|
||||
req *SendToRouteRequest) (*SendToRouteResponse, error) {
|
||||
|
||||
resp, err := s.SendToRouteV2(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Need to convert to legacy response message because proto identifiers
|
||||
// don't line up.
|
||||
legacyResp := &SendToRouteResponse{
|
||||
Preimage: resp.Preimage,
|
||||
Failure: resp.Failure,
|
||||
}
|
||||
|
||||
return legacyResp, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user