routerrpc: add SendToRouteV2 that returns an HTLCAttempt message

Unify data structure with SendPayment/ListPayments.
This commit is contained in:
Joost Jager
2020-04-03 10:59:44 +02:00
parent 674c199047
commit b6170788ea
5 changed files with 244 additions and 162 deletions

View File

@@ -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
}