mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: do not rename swapserverrpc to looprpc
Many imports renamed it, but it was not needed.
This commit is contained in:
parent
6db2a39331
commit
8447f58ff9
10 changed files with 196 additions and 195 deletions
|
|
@ -15,7 +15,7 @@ import (
|
|||
"github.com/lightninglabs/loop/instantout/reservation"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/swap"
|
||||
loop_rpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
|
|
@ -137,7 +137,7 @@ func (f *FSM) InitInstantOutAction(eventCtx fsm.EventContext) fsm.EventType {
|
|||
// Send the instantout request to the server.
|
||||
instantOutResponse, err := f.cfg.InstantOutClient.RequestInstantLoopOut(
|
||||
f.ctx,
|
||||
&loop_rpc.InstantLoopOutRequest{
|
||||
&swapserverrpc.InstantLoopOutRequest{
|
||||
ReceiverKey: keyRes.PubKey.SerializeCompressed(),
|
||||
SwapHash: swapHash[:],
|
||||
Expiry: initCtx.cltvExpiry,
|
||||
|
|
@ -259,7 +259,8 @@ func (f *FSM) PollPaymentAcceptedAction(_ fsm.EventContext) fsm.EventType {
|
|||
|
||||
case <-timer.C:
|
||||
res, err := f.cfg.InstantOutClient.PollPaymentAccepted(
|
||||
f.ctx, &loop_rpc.PollPaymentAcceptedRequest{
|
||||
f.ctx,
|
||||
&swapserverrpc.PollPaymentAcceptedRequest{
|
||||
SwapHash: f.InstantOut.SwapHash[:],
|
||||
},
|
||||
)
|
||||
|
|
@ -292,7 +293,7 @@ func (f *FSM) BuildHTLCAction(eventCtx fsm.EventContext) fsm.EventType {
|
|||
// Send the server the client nonces.
|
||||
htlcInitRes, err := f.cfg.InstantOutClient.InitHtlcSig(
|
||||
f.ctx,
|
||||
&loop_rpc.InitHtlcSigRequest{
|
||||
&swapserverrpc.InitHtlcSigRequest{
|
||||
SwapHash: f.InstantOut.SwapHash[:],
|
||||
HtlcClientNonces: htlcClientNonces,
|
||||
},
|
||||
|
|
@ -331,7 +332,7 @@ func (f *FSM) BuildHTLCAction(eventCtx fsm.EventContext) fsm.EventType {
|
|||
// Send the server the htlc signatures.
|
||||
htlcRes, err := f.cfg.InstantOutClient.PushHtlcSig(
|
||||
f.ctx,
|
||||
&loop_rpc.PushHtlcSigRequest{
|
||||
&swapserverrpc.PushHtlcSigRequest{
|
||||
SwapHash: f.InstantOut.SwapHash[:],
|
||||
ClientSigs: htlcSigs,
|
||||
},
|
||||
|
|
@ -377,7 +378,7 @@ func (f *FSM) PushPreimageAction(eventCtx fsm.EventContext) fsm.EventType {
|
|||
|
||||
pushPreImageRes, err := f.cfg.InstantOutClient.PushPreimage(
|
||||
f.ctx,
|
||||
&loop_rpc.PushPreimageRequest{
|
||||
&swapserverrpc.PushPreimageRequest{
|
||||
Preimage: f.InstantOut.swapPreimage[:],
|
||||
ClientNonces: coopClientNonces,
|
||||
ClientSweepAddr: f.InstantOut.sweepAddress.String(),
|
||||
|
|
@ -615,7 +616,7 @@ func (f *FSM) handleErrorAndUnlockReservations(err error) fsm.EventType {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
||||
defer cancel()
|
||||
_, cancelErr := f.cfg.InstantOutClient.CancelInstantSwap(
|
||||
ctx, &loop_rpc.CancelInstantSwapRequest{
|
||||
ctx, &swapserverrpc.CancelInstantSwapRequest{
|
||||
SwapHash: f.InstantOut.SwapHash[:],
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop/fsm"
|
||||
loop_rpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
)
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ func CurrentProtocolVersion() ProtocolVersion {
|
|||
}
|
||||
|
||||
// CurrentRpcProtocolVersion returns the current rpc protocol version.
|
||||
func CurrentRpcProtocolVersion() loop_rpc.InstantOutProtocolVersion {
|
||||
return loop_rpc.InstantOutProtocolVersion(CurrentProtocolVersion())
|
||||
func CurrentRpcProtocolVersion() swapserverrpc.InstantOutProtocolVersion {
|
||||
return swapserverrpc.InstantOutProtocolVersion(CurrentProtocolVersion())
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
@ -163,7 +163,7 @@ type Config struct {
|
|||
Wallet lndclient.WalletKitClient
|
||||
|
||||
// InstantOutClient is used to communicate with the swap server.
|
||||
InstantOutClient loop_rpc.InstantSwapServerClient
|
||||
InstantOutClient swapserverrpc.InstantSwapServerClient
|
||||
|
||||
// ReservationManager is used to get the reservations and lock them.
|
||||
ReservationManager ReservationManager
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightninglabs/loop/fsm"
|
||||
"github.com/lightninglabs/loop/instantout/reservation"
|
||||
looprpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
)
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ func (m *Manager) GetInstantOutQuote(ctx context.Context,
|
|||
|
||||
// Get the service fee.
|
||||
quoteRes, err := m.cfg.InstantOutClient.GetInstantOutQuote(
|
||||
ctx, &looprpc.GetInstantOutQuoteRequest{
|
||||
ctx, &swapserverrpc.GetInstantOutQuoteRequest{
|
||||
Amount: uint64(amt),
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightninglabs/loop/fsm"
|
||||
looprpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
)
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ func (f *FSM) InitAction(eventCtx fsm.EventContext) fsm.EventType {
|
|||
log.Debugf("Dispatching reservation to server: %x",
|
||||
reservationRequest.reservationID)
|
||||
|
||||
request := &looprpc.ServerOpenReservationRequest{
|
||||
request := &swapserverrpc.ServerOpenReservationRequest{
|
||||
ReservationId: reservationRequest.reservationID[:],
|
||||
ClientKey: keyRes.PubKey.SerializeCompressed(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop/fsm"
|
||||
looprpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -26,7 +26,7 @@ type Config struct {
|
|||
|
||||
// ReservationClient is the client used to communicate with the
|
||||
// swap server.
|
||||
ReservationClient looprpc.ReservationServiceClient
|
||||
ReservationClient swapserverrpc.ReservationServiceClient
|
||||
|
||||
// FetchL402 is the function used to fetch the l402 token.
|
||||
FetchL402 func(context.Context) error
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ import (
|
|||
"github.com/lightninglabs/loop/labels"
|
||||
"github.com/lightninglabs/loop/liquidity"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
clientrpc "github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/lightninglabs/loop/swap"
|
||||
looprpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/queue"
|
||||
|
|
@ -73,8 +73,8 @@ var (
|
|||
// swapClientServer implements the grpc service exposed by loopd.
|
||||
type swapClientServer struct {
|
||||
// Required by the grpc-gateway/v2 library for forward compatibility.
|
||||
clientrpc.UnimplementedSwapClientServer
|
||||
clientrpc.UnimplementedDebugServer
|
||||
looprpc.UnimplementedSwapClientServer
|
||||
looprpc.UnimplementedDebugServer
|
||||
|
||||
config *Config
|
||||
network lndclient.Network
|
||||
|
|
@ -96,8 +96,8 @@ type swapClientServer struct {
|
|||
// progress can be tracked via the LoopOutStatus stream that is returned from
|
||||
// Monitor().
|
||||
func (s *swapClientServer) LoopOut(ctx context.Context,
|
||||
in *clientrpc.LoopOutRequest) (
|
||||
*clientrpc.SwapResponse, error) {
|
||||
in *looprpc.LoopOutRequest) (
|
||||
*looprpc.SwapResponse, error) {
|
||||
|
||||
log.Infof("Loop out request received")
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
|
|||
|
||||
isExternalAddr = true
|
||||
|
||||
case in.Account != "" && in.AccountAddrType == clientrpc.AddressType_ADDRESS_TYPE_UNKNOWN:
|
||||
case in.Account != "" && in.AccountAddrType == looprpc.AddressType_ADDRESS_TYPE_UNKNOWN:
|
||||
return nil, liquidity.ErrAccountAndAddrType
|
||||
|
||||
case in.Account != "":
|
||||
|
|
@ -217,7 +217,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
|
|||
}
|
||||
|
||||
htlcAddress := info.HtlcAddress.String()
|
||||
resp := &clientrpc.SwapResponse{
|
||||
resp := &looprpc.SwapResponse{
|
||||
Id: info.SwapHash.String(),
|
||||
IdBytes: info.SwapHash[:],
|
||||
HtlcAddress: htlcAddress,
|
||||
|
|
@ -252,11 +252,11 @@ func (s *swapClientServer) accountExists(ctx context.Context, account string,
|
|||
return false
|
||||
}
|
||||
|
||||
func toWalletAddrType(addrType clientrpc.AddressType) (walletrpc.AddressType,
|
||||
func toWalletAddrType(addrType looprpc.AddressType) (walletrpc.AddressType,
|
||||
error) {
|
||||
|
||||
switch addrType {
|
||||
case clientrpc.AddressType_TAPROOT_PUBKEY:
|
||||
case looprpc.AddressType_TAPROOT_PUBKEY:
|
||||
return walletrpc.AddressType_TAPROOT_PUBKEY, nil
|
||||
|
||||
default:
|
||||
|
|
@ -266,11 +266,11 @@ func toWalletAddrType(addrType clientrpc.AddressType) (walletrpc.AddressType,
|
|||
}
|
||||
|
||||
func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
|
||||
*clientrpc.SwapStatus, error) {
|
||||
*looprpc.SwapStatus, error) {
|
||||
|
||||
var (
|
||||
state clientrpc.SwapState
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_NONE
|
||||
state looprpc.SwapState
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_NONE
|
||||
)
|
||||
|
||||
// Set our state var for non-failure states. If we get a failure, we
|
||||
|
|
@ -280,46 +280,46 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
|
|||
// states, and set our failed state for all of them.
|
||||
switch loopSwap.State {
|
||||
case loopdb.StateInitiated:
|
||||
state = clientrpc.SwapState_INITIATED
|
||||
state = looprpc.SwapState_INITIATED
|
||||
|
||||
case loopdb.StatePreimageRevealed:
|
||||
state = clientrpc.SwapState_PREIMAGE_REVEALED
|
||||
state = looprpc.SwapState_PREIMAGE_REVEALED
|
||||
|
||||
case loopdb.StateHtlcPublished:
|
||||
state = clientrpc.SwapState_HTLC_PUBLISHED
|
||||
state = looprpc.SwapState_HTLC_PUBLISHED
|
||||
|
||||
case loopdb.StateInvoiceSettled:
|
||||
state = clientrpc.SwapState_INVOICE_SETTLED
|
||||
state = looprpc.SwapState_INVOICE_SETTLED
|
||||
|
||||
case loopdb.StateSuccess:
|
||||
state = clientrpc.SwapState_SUCCESS
|
||||
state = looprpc.SwapState_SUCCESS
|
||||
|
||||
case loopdb.StateFailOffchainPayments:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_OFFCHAIN
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_OFFCHAIN
|
||||
|
||||
case loopdb.StateFailTimeout:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_TIMEOUT
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_TIMEOUT
|
||||
|
||||
case loopdb.StateFailSweepTimeout:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_SWEEP_TIMEOUT
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_SWEEP_TIMEOUT
|
||||
|
||||
case loopdb.StateFailInsufficientValue:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_INSUFFICIENT_VALUE
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_INSUFFICIENT_VALUE
|
||||
|
||||
case loopdb.StateFailTemporary:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_TEMPORARY
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_TEMPORARY
|
||||
|
||||
case loopdb.StateFailIncorrectHtlcAmt:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_INCORRECT_AMOUNT
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_INCORRECT_AMOUNT
|
||||
|
||||
case loopdb.StateFailAbandoned:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_ABANDONED
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_ABANDONED
|
||||
|
||||
case loopdb.StateFailInsufficientConfirmedBalance:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_INSUFFICIENT_CONFIRMED_BALANCE
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_INSUFFICIENT_CONFIRMED_BALANCE
|
||||
|
||||
case loopdb.StateFailIncorrectHtlcAmtSwept:
|
||||
failureReason = clientrpc.FailureReason_FAILURE_REASON_INCORRECT_HTLC_AMT_SWEPT
|
||||
failureReason = looprpc.FailureReason_FAILURE_REASON_INCORRECT_HTLC_AMT_SWEPT
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown swap state: %v", loopSwap.State)
|
||||
|
|
@ -327,11 +327,11 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
|
|||
|
||||
// If we have a failure reason, we have a failure state, so should use
|
||||
// our catchall failed state.
|
||||
if failureReason != clientrpc.FailureReason_FAILURE_REASON_NONE {
|
||||
state = clientrpc.SwapState_FAILED
|
||||
if failureReason != looprpc.FailureReason_FAILURE_REASON_NONE {
|
||||
state = looprpc.SwapState_FAILED
|
||||
}
|
||||
|
||||
var swapType clientrpc.SwapType
|
||||
var swapType looprpc.SwapType
|
||||
var (
|
||||
htlcAddress string
|
||||
htlcAddressP2TR string
|
||||
|
|
@ -342,7 +342,7 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
|
|||
|
||||
switch loopSwap.SwapType {
|
||||
case swap.TypeIn:
|
||||
swapType = clientrpc.SwapType_LOOP_IN
|
||||
swapType = looprpc.SwapType_LOOP_IN
|
||||
|
||||
if loopSwap.HtlcAddressP2TR != nil {
|
||||
htlcAddressP2TR = loopSwap.HtlcAddressP2TR.EncodeAddress()
|
||||
|
|
@ -358,7 +358,7 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
|
|||
}
|
||||
|
||||
case swap.TypeOut:
|
||||
swapType = clientrpc.SwapType_LOOP_OUT
|
||||
swapType = looprpc.SwapType_LOOP_OUT
|
||||
if loopSwap.HtlcAddressP2WSH != nil {
|
||||
htlcAddressP2WSH = loopSwap.HtlcAddressP2WSH.EncodeAddress()
|
||||
htlcAddress = htlcAddressP2WSH
|
||||
|
|
@ -373,7 +373,7 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
|
|||
return nil, errors.New("unknown swap type")
|
||||
}
|
||||
|
||||
return &clientrpc.SwapStatus{
|
||||
return &looprpc.SwapStatus{
|
||||
Amt: int64(loopSwap.AmountRequested),
|
||||
Id: loopSwap.SwapHash.String(),
|
||||
IdBytes: loopSwap.SwapHash[:],
|
||||
|
|
@ -395,8 +395,8 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
|
|||
}
|
||||
|
||||
// Monitor will return a stream of swap updates for currently active swaps.
|
||||
func (s *swapClientServer) Monitor(in *clientrpc.MonitorRequest,
|
||||
server clientrpc.SwapClient_MonitorServer) error {
|
||||
func (s *swapClientServer) Monitor(in *looprpc.MonitorRequest,
|
||||
server looprpc.SwapClient_MonitorServer) error {
|
||||
|
||||
log.Infof("Monitor request received")
|
||||
|
||||
|
|
@ -497,10 +497,10 @@ func (s *swapClientServer) Monitor(in *clientrpc.MonitorRequest,
|
|||
// ListSwaps returns a list of all currently known swaps and their current
|
||||
// status.
|
||||
func (s *swapClientServer) ListSwaps(_ context.Context,
|
||||
req *clientrpc.ListSwapsRequest) (*clientrpc.ListSwapsResponse, error) {
|
||||
req *looprpc.ListSwapsRequest) (*looprpc.ListSwapsResponse, error) {
|
||||
|
||||
var (
|
||||
rpcSwaps = []*clientrpc.SwapStatus{}
|
||||
rpcSwaps = []*looprpc.SwapStatus{}
|
||||
idx = 0
|
||||
)
|
||||
|
||||
|
|
@ -526,25 +526,25 @@ func (s *swapClientServer) ListSwaps(_ context.Context,
|
|||
rpcSwaps = append(rpcSwaps, rpcSwap)
|
||||
idx++
|
||||
}
|
||||
return &clientrpc.ListSwapsResponse{Swaps: rpcSwaps}, nil
|
||||
return &looprpc.ListSwapsResponse{Swaps: rpcSwaps}, nil
|
||||
}
|
||||
|
||||
// filterSwap filters the given swap based on the provided filter.
|
||||
func filterSwap(swapInfo *loop.SwapInfo, filter *clientrpc.ListSwapsFilter) bool {
|
||||
func filterSwap(swapInfo *loop.SwapInfo, filter *looprpc.ListSwapsFilter) bool {
|
||||
if filter == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
// If the swap type filter is set, we only return swaps that match the
|
||||
// filter.
|
||||
if filter.SwapType != clientrpc.ListSwapsFilter_ANY {
|
||||
if filter.SwapType != looprpc.ListSwapsFilter_ANY {
|
||||
switch filter.SwapType {
|
||||
case clientrpc.ListSwapsFilter_LOOP_IN:
|
||||
case looprpc.ListSwapsFilter_LOOP_IN:
|
||||
if swapInfo.SwapType != swap.TypeIn {
|
||||
return false
|
||||
}
|
||||
|
||||
case clientrpc.ListSwapsFilter_LOOP_OUT:
|
||||
case looprpc.ListSwapsFilter_LOOP_OUT:
|
||||
if swapInfo.SwapType != swap.TypeOut {
|
||||
return false
|
||||
}
|
||||
|
|
@ -602,7 +602,7 @@ func filterSwap(swapInfo *loop.SwapInfo, filter *clientrpc.ListSwapsFilter) bool
|
|||
|
||||
// SwapInfo returns all known details about a single swap.
|
||||
func (s *swapClientServer) SwapInfo(_ context.Context,
|
||||
req *clientrpc.SwapInfoRequest) (*clientrpc.SwapStatus, error) {
|
||||
req *looprpc.SwapInfoRequest) (*looprpc.SwapStatus, error) {
|
||||
|
||||
swapHash, err := lntypes.MakeHash(req.Id)
|
||||
if err != nil {
|
||||
|
|
@ -620,7 +620,7 @@ func (s *swapClientServer) SwapInfo(_ context.Context,
|
|||
|
||||
// AbandonSwap requests the server to abandon a swap with the given hash.
|
||||
func (s *swapClientServer) AbandonSwap(ctx context.Context,
|
||||
req *clientrpc.AbandonSwapRequest) (*clientrpc.AbandonSwapResponse,
|
||||
req *looprpc.AbandonSwapRequest) (*looprpc.AbandonSwapResponse,
|
||||
error) {
|
||||
|
||||
if !req.IKnowWhatIAmDoing {
|
||||
|
|
@ -658,12 +658,12 @@ func (s *swapClientServer) AbandonSwap(ctx context.Context,
|
|||
return nil, fmt.Errorf("error abandoning swap: %v", err)
|
||||
}
|
||||
|
||||
return &clientrpc.AbandonSwapResponse{}, nil
|
||||
return &looprpc.AbandonSwapResponse{}, nil
|
||||
}
|
||||
|
||||
// LoopOutTerms returns the terms that the server enforces for loop out swaps.
|
||||
func (s *swapClientServer) LoopOutTerms(ctx context.Context,
|
||||
_ *clientrpc.TermsRequest) (*clientrpc.OutTermsResponse, error) {
|
||||
_ *looprpc.TermsRequest) (*looprpc.OutTermsResponse, error) {
|
||||
|
||||
log.Infof("Loop out terms request received")
|
||||
|
||||
|
|
@ -673,7 +673,7 @@ func (s *swapClientServer) LoopOutTerms(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clientrpc.OutTermsResponse{
|
||||
return &looprpc.OutTermsResponse{
|
||||
MinSwapAmount: int64(terms.MinSwapAmount),
|
||||
MaxSwapAmount: int64(terms.MaxSwapAmount),
|
||||
MinCltvDelta: terms.MinCltvDelta,
|
||||
|
|
@ -684,7 +684,7 @@ func (s *swapClientServer) LoopOutTerms(ctx context.Context,
|
|||
// LoopOutQuote returns a quote for a loop out swap with the provided
|
||||
// parameters.
|
||||
func (s *swapClientServer) LoopOutQuote(ctx context.Context,
|
||||
req *clientrpc.QuoteRequest) (*clientrpc.OutQuoteResponse, error) {
|
||||
req *looprpc.QuoteRequest) (*looprpc.OutQuoteResponse, error) {
|
||||
|
||||
confTarget, err := validateConfTarget(
|
||||
req.ConfTarget, loop.DefaultSweepConfTarget,
|
||||
|
|
@ -707,7 +707,7 @@ func (s *swapClientServer) LoopOutQuote(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clientrpc.OutQuoteResponse{
|
||||
return &looprpc.OutQuoteResponse{
|
||||
HtlcSweepFeeSat: int64(quote.MinerFee),
|
||||
PrepayAmtSat: int64(quote.PrepayAmount),
|
||||
SwapFeeSat: int64(quote.SwapFee),
|
||||
|
|
@ -718,7 +718,7 @@ func (s *swapClientServer) LoopOutQuote(ctx context.Context,
|
|||
|
||||
// GetLoopInTerms returns the terms that the server enforces for swaps.
|
||||
func (s *swapClientServer) GetLoopInTerms(ctx context.Context,
|
||||
_ *clientrpc.TermsRequest) (*clientrpc.InTermsResponse, error) {
|
||||
_ *looprpc.TermsRequest) (*looprpc.InTermsResponse, error) {
|
||||
|
||||
log.Infof("Loop in terms request received")
|
||||
|
||||
|
|
@ -728,7 +728,7 @@ func (s *swapClientServer) GetLoopInTerms(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clientrpc.InTermsResponse{
|
||||
return &looprpc.InTermsResponse{
|
||||
MinSwapAmount: int64(terms.MinSwapAmount),
|
||||
MaxSwapAmount: int64(terms.MaxSwapAmount),
|
||||
}, nil
|
||||
|
|
@ -736,7 +736,7 @@ func (s *swapClientServer) GetLoopInTerms(ctx context.Context,
|
|||
|
||||
// GetLoopInQuote returns a quote for a swap with the provided parameters.
|
||||
func (s *swapClientServer) GetLoopInQuote(ctx context.Context,
|
||||
req *clientrpc.QuoteRequest) (*clientrpc.InQuoteResponse, error) {
|
||||
req *looprpc.QuoteRequest) (*looprpc.InQuoteResponse, error) {
|
||||
|
||||
log.Infof("Loop in quote request received")
|
||||
|
||||
|
|
@ -782,7 +782,7 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clientrpc.InQuoteResponse{
|
||||
return &looprpc.InQuoteResponse{
|
||||
HtlcPublishFeeSat: int64(quote.MinerFee),
|
||||
SwapFeeSat: int64(quote.SwapFee),
|
||||
ConfTarget: htlcConfTarget,
|
||||
|
|
@ -790,7 +790,7 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context,
|
|||
}
|
||||
|
||||
// unmarshallRouteHints unmarshalls a list of route hints.
|
||||
func unmarshallRouteHints(rpcRouteHints []*looprpc.RouteHint) (
|
||||
func unmarshallRouteHints(rpcRouteHints []*swapserverrpc.RouteHint) (
|
||||
[][]zpay32.HopHint, error) {
|
||||
|
||||
routeHints := make([][]zpay32.HopHint, 0, len(rpcRouteHints))
|
||||
|
|
@ -813,7 +813,7 @@ func unmarshallRouteHints(rpcRouteHints []*looprpc.RouteHint) (
|
|||
}
|
||||
|
||||
// unmarshallHopHint unmarshalls a single hop hint.
|
||||
func unmarshallHopHint(rpcHint *looprpc.HopHint) (zpay32.HopHint, error) {
|
||||
func unmarshallHopHint(rpcHint *swapserverrpc.HopHint) (zpay32.HopHint, error) {
|
||||
pubBytes, err := hex.DecodeString(rpcHint.NodeId)
|
||||
if err != nil {
|
||||
return zpay32.HopHint{}, err
|
||||
|
|
@ -836,7 +836,7 @@ func unmarshallHopHint(rpcHint *looprpc.HopHint) (zpay32.HopHint, error) {
|
|||
// Probe requests the server to probe the client's node to test inbound
|
||||
// liquidity.
|
||||
func (s *swapClientServer) Probe(ctx context.Context,
|
||||
req *clientrpc.ProbeRequest) (*clientrpc.ProbeResponse, error) {
|
||||
req *looprpc.ProbeRequest) (*looprpc.ProbeResponse, error) {
|
||||
|
||||
log.Infof("Probe request received")
|
||||
|
||||
|
|
@ -864,11 +864,11 @@ func (s *swapClientServer) Probe(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clientrpc.ProbeResponse{}, nil
|
||||
return &looprpc.ProbeResponse{}, nil
|
||||
}
|
||||
|
||||
func (s *swapClientServer) LoopIn(ctx context.Context,
|
||||
in *clientrpc.LoopInRequest) (*clientrpc.SwapResponse, error) {
|
||||
in *looprpc.LoopInRequest) (*looprpc.SwapResponse, error) {
|
||||
|
||||
log.Infof("Loop in request received")
|
||||
|
||||
|
|
@ -913,7 +913,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
response := &clientrpc.SwapResponse{
|
||||
response := &looprpc.SwapResponse{
|
||||
Id: swapInfo.SwapHash.String(),
|
||||
IdBytes: swapInfo.SwapHash[:],
|
||||
ServerMessage: swapInfo.ServerMessage,
|
||||
|
|
@ -934,7 +934,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
|
|||
|
||||
// GetL402Tokens returns all tokens that are contained in the L402 token store.
|
||||
func (s *swapClientServer) GetL402Tokens(ctx context.Context,
|
||||
_ *clientrpc.TokensRequest) (*clientrpc.TokensResponse, error) {
|
||||
_ *looprpc.TokensRequest) (*looprpc.TokensResponse, error) {
|
||||
|
||||
log.Infof("Get L402 tokens request received")
|
||||
|
||||
|
|
@ -943,7 +943,7 @@ func (s *swapClientServer) GetL402Tokens(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
rpcTokens := make([]*clientrpc.L402Token, len(tokens))
|
||||
rpcTokens := make([]*looprpc.L402Token, len(tokens))
|
||||
idx := 0
|
||||
for key, token := range tokens {
|
||||
macBytes, err := token.BaseMacaroon().MarshalBinary()
|
||||
|
|
@ -957,7 +957,7 @@ func (s *swapClientServer) GetL402Tokens(ctx context.Context,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rpcTokens[idx] = &clientrpc.L402Token{
|
||||
rpcTokens[idx] = &looprpc.L402Token{
|
||||
BaseMacaroon: macBytes,
|
||||
PaymentHash: token.PaymentHash[:],
|
||||
PaymentPreimage: token.Preimage[:],
|
||||
|
|
@ -973,7 +973,7 @@ func (s *swapClientServer) GetL402Tokens(ctx context.Context,
|
|||
idx++
|
||||
}
|
||||
|
||||
return &clientrpc.TokensResponse{Tokens: rpcTokens}, nil
|
||||
return &looprpc.TokensResponse{Tokens: rpcTokens}, nil
|
||||
}
|
||||
|
||||
// GetLsatTokens returns all tokens that are contained in the L402 token store.
|
||||
|
|
@ -983,7 +983,7 @@ func (s *swapClientServer) GetL402Tokens(ctx context.Context,
|
|||
// Type LsatToken used by GetLsatTokens in the past was renamed to L402Token,
|
||||
// but this does not affect binary encoding, so we can use type L402Token here.
|
||||
func (s *swapClientServer) GetLsatTokens(ctx context.Context,
|
||||
req *clientrpc.TokensRequest) (*clientrpc.TokensResponse, error) {
|
||||
req *looprpc.TokensRequest) (*looprpc.TokensResponse, error) {
|
||||
|
||||
log.Warnf("Received deprecated call GetLsatTokens. Please update the " +
|
||||
"client software. Calling GetL402Tokens now.")
|
||||
|
|
@ -994,7 +994,7 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context,
|
|||
// GetInfo returns basic information about the loop daemon and details to swaps
|
||||
// from the swap store.
|
||||
func (s *swapClientServer) GetInfo(ctx context.Context,
|
||||
_ *clientrpc.GetInfoRequest) (*clientrpc.GetInfoResponse, error) {
|
||||
_ *looprpc.GetInfoRequest) (*looprpc.GetInfoResponse, error) {
|
||||
|
||||
// Fetch loop-outs from the loop db.
|
||||
outSwaps, err := s.impl.Store.FetchLoopOutSwaps(ctx)
|
||||
|
|
@ -1003,7 +1003,7 @@ func (s *swapClientServer) GetInfo(ctx context.Context,
|
|||
}
|
||||
|
||||
// Collect loop-out stats.
|
||||
loopOutStats := &clientrpc.LoopStats{}
|
||||
loopOutStats := &looprpc.LoopStats{}
|
||||
for _, out := range outSwaps {
|
||||
switch out.State().State.Type() {
|
||||
case loopdb.StateTypeSuccess:
|
||||
|
|
@ -1030,7 +1030,7 @@ func (s *swapClientServer) GetInfo(ctx context.Context,
|
|||
}
|
||||
|
||||
// Collect loop-in stats.
|
||||
loopInStats := &clientrpc.LoopStats{}
|
||||
loopInStats := &looprpc.LoopStats{}
|
||||
for _, in := range inSwaps {
|
||||
switch in.State().State.Type() {
|
||||
case loopdb.StateTypeSuccess:
|
||||
|
|
@ -1050,7 +1050,7 @@ func (s *swapClientServer) GetInfo(ctx context.Context,
|
|||
}
|
||||
}
|
||||
|
||||
return &clientrpc.GetInfoResponse{
|
||||
return &looprpc.GetInfoResponse{
|
||||
Version: loop.Version(),
|
||||
Network: s.config.Network,
|
||||
RpcListen: s.config.RPCListen,
|
||||
|
|
@ -1064,7 +1064,7 @@ func (s *swapClientServer) GetInfo(ctx context.Context,
|
|||
|
||||
// GetLiquidityParams gets our current liquidity manager's parameters.
|
||||
func (s *swapClientServer) GetLiquidityParams(_ context.Context,
|
||||
_ *clientrpc.GetLiquidityParamsRequest) (*clientrpc.LiquidityParameters,
|
||||
_ *looprpc.GetLiquidityParamsRequest) (*looprpc.LiquidityParameters,
|
||||
error) {
|
||||
|
||||
cfg := s.liquidityMgr.GetParameters()
|
||||
|
|
@ -1080,7 +1080,7 @@ func (s *swapClientServer) GetLiquidityParams(_ context.Context,
|
|||
// SetLiquidityParams attempts to set our current liquidity manager's
|
||||
// parameters.
|
||||
func (s *swapClientServer) SetLiquidityParams(ctx context.Context,
|
||||
in *clientrpc.SetLiquidityParamsRequest) (*clientrpc.SetLiquidityParamsResponse,
|
||||
in *looprpc.SetLiquidityParamsRequest) (*looprpc.SetLiquidityParamsResponse,
|
||||
error) {
|
||||
|
||||
err := s.liquidityMgr.SetParameters(ctx, in.Parameters)
|
||||
|
|
@ -1088,13 +1088,13 @@ func (s *swapClientServer) SetLiquidityParams(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clientrpc.SetLiquidityParamsResponse{}, nil
|
||||
return &looprpc.SetLiquidityParamsResponse{}, nil
|
||||
}
|
||||
|
||||
// SuggestSwaps provides a list of suggested swaps based on lnd's current
|
||||
// channel balances and rules set by the liquidity manager.
|
||||
func (s *swapClientServer) SuggestSwaps(ctx context.Context,
|
||||
_ *clientrpc.SuggestSwapsRequest) (*clientrpc.SuggestSwapsResponse, error) {
|
||||
_ *looprpc.SuggestSwapsRequest) (*looprpc.SuggestSwapsResponse, error) {
|
||||
|
||||
suggestions, err := s.liquidityMgr.SuggestSwaps(ctx)
|
||||
switch err {
|
||||
|
|
@ -1107,17 +1107,17 @@ func (s *swapClientServer) SuggestSwaps(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
resp := &clientrpc.SuggestSwapsResponse{
|
||||
resp := &looprpc.SuggestSwapsResponse{
|
||||
LoopOut: make(
|
||||
[]*clientrpc.LoopOutRequest, len(suggestions.OutSwaps),
|
||||
[]*looprpc.LoopOutRequest, len(suggestions.OutSwaps),
|
||||
),
|
||||
LoopIn: make(
|
||||
[]*clientrpc.LoopInRequest, len(suggestions.InSwaps),
|
||||
[]*looprpc.LoopInRequest, len(suggestions.InSwaps),
|
||||
),
|
||||
}
|
||||
|
||||
for i, swap := range suggestions.OutSwaps {
|
||||
resp.LoopOut[i] = &clientrpc.LoopOutRequest{
|
||||
resp.LoopOut[i] = &looprpc.LoopOutRequest{
|
||||
Amt: int64(swap.Amount),
|
||||
OutgoingChanSet: swap.OutgoingChanSet,
|
||||
MaxSwapFee: int64(swap.MaxSwapFee),
|
||||
|
|
@ -1130,7 +1130,7 @@ func (s *swapClientServer) SuggestSwaps(ctx context.Context,
|
|||
}
|
||||
|
||||
for i, swap := range suggestions.InSwaps {
|
||||
loopIn := &clientrpc.LoopInRequest{
|
||||
loopIn := &looprpc.LoopInRequest{
|
||||
Amt: int64(swap.Amount),
|
||||
MaxSwapFee: int64(swap.MaxSwapFee),
|
||||
MaxMinerFee: int64(swap.MaxMinerFee),
|
||||
|
|
@ -1150,7 +1150,7 @@ func (s *swapClientServer) SuggestSwaps(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
exclChan := &clientrpc.Disqualified{
|
||||
exclChan := &looprpc.Disqualified{
|
||||
Reason: autoloopReason,
|
||||
ChannelId: id.ToUint64(),
|
||||
}
|
||||
|
|
@ -1167,7 +1167,7 @@ func (s *swapClientServer) SuggestSwaps(ctx context.Context,
|
|||
clonedPubkey := route.Vertex{}
|
||||
copy(clonedPubkey[:], pubkey[:])
|
||||
|
||||
exclChan := &clientrpc.Disqualified{
|
||||
exclChan := &looprpc.Disqualified{
|
||||
Reason: autoloopReason,
|
||||
Pubkey: clonedPubkey[:],
|
||||
}
|
||||
|
|
@ -1180,8 +1180,8 @@ func (s *swapClientServer) SuggestSwaps(ctx context.Context,
|
|||
|
||||
// ListReservations lists all existing reservations the client has ever made.
|
||||
func (s *swapClientServer) ListReservations(ctx context.Context,
|
||||
_ *clientrpc.ListReservationsRequest) (
|
||||
*clientrpc.ListReservationsResponse, error) {
|
||||
_ *looprpc.ListReservationsRequest) (
|
||||
*looprpc.ListReservationsResponse, error) {
|
||||
|
||||
if s.reservationManager == nil {
|
||||
return nil, status.Error(codes.Unimplemented,
|
||||
|
|
@ -1194,7 +1194,7 @@ func (s *swapClientServer) ListReservations(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clientrpc.ListReservationsResponse{
|
||||
return &looprpc.ListReservationsResponse{
|
||||
Reservations: ToClientReservations(
|
||||
reservations,
|
||||
),
|
||||
|
|
@ -1203,7 +1203,7 @@ func (s *swapClientServer) ListReservations(ctx context.Context,
|
|||
|
||||
// InstantOut initiates an instant out swap.
|
||||
func (s *swapClientServer) InstantOut(ctx context.Context,
|
||||
req *clientrpc.InstantOutRequest) (*clientrpc.InstantOutResponse,
|
||||
req *looprpc.InstantOutRequest) (*looprpc.InstantOutResponse,
|
||||
error) {
|
||||
|
||||
reservationIds := make([]reservation.ID, len(req.ReservationIds))
|
||||
|
|
@ -1227,7 +1227,7 @@ func (s *swapClientServer) InstantOut(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res := &clientrpc.InstantOutResponse{
|
||||
res := &looprpc.InstantOutResponse{
|
||||
InstantOutHash: instantOutFsm.InstantOut.SwapHash[:],
|
||||
State: string(instantOutFsm.InstantOut.State),
|
||||
}
|
||||
|
|
@ -1242,8 +1242,8 @@ func (s *swapClientServer) InstantOut(ctx context.Context,
|
|||
// InstantOutQuote returns a quote for an instant out swap with the provided
|
||||
// parameters.
|
||||
func (s *swapClientServer) InstantOutQuote(ctx context.Context,
|
||||
req *clientrpc.InstantOutQuoteRequest) (
|
||||
*clientrpc.InstantOutQuoteResponse, error) {
|
||||
req *looprpc.InstantOutQuoteRequest) (
|
||||
*looprpc.InstantOutQuoteResponse, error) {
|
||||
|
||||
quote, err := s.instantOutManager.GetInstantOutQuote(
|
||||
ctx, btcutil.Amount(req.Amt), int(req.NumReservations),
|
||||
|
|
@ -1252,7 +1252,7 @@ func (s *swapClientServer) InstantOutQuote(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clientrpc.InstantOutQuoteResponse{
|
||||
return &looprpc.InstantOutQuoteResponse{
|
||||
ServiceFeeSat: int64(quote.ServiceFee),
|
||||
SweepFeeSat: int64(quote.OnChainFee),
|
||||
}, nil
|
||||
|
|
@ -1261,25 +1261,25 @@ func (s *swapClientServer) InstantOutQuote(ctx context.Context,
|
|||
// ListInstantOuts returns a list of all currently known instant out swaps and
|
||||
// their current status.
|
||||
func (s *swapClientServer) ListInstantOuts(ctx context.Context,
|
||||
_ *clientrpc.ListInstantOutsRequest) (
|
||||
*clientrpc.ListInstantOutsResponse, error) {
|
||||
_ *looprpc.ListInstantOutsRequest) (
|
||||
*looprpc.ListInstantOutsResponse, error) {
|
||||
|
||||
instantOuts, err := s.instantOutManager.ListInstantOuts(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rpcSwaps := make([]*clientrpc.InstantOut, 0, len(instantOuts))
|
||||
rpcSwaps := make([]*looprpc.InstantOut, 0, len(instantOuts))
|
||||
for _, instantOut := range instantOuts {
|
||||
rpcSwaps = append(rpcSwaps, rpcInstantOut(instantOut))
|
||||
}
|
||||
|
||||
return &clientrpc.ListInstantOutsResponse{
|
||||
return &looprpc.ListInstantOutsResponse{
|
||||
Swaps: rpcSwaps,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func rpcInstantOut(instantOut *instantout.InstantOut) *clientrpc.InstantOut {
|
||||
func rpcInstantOut(instantOut *instantout.InstantOut) *looprpc.InstantOut {
|
||||
var sweepTxId string
|
||||
if instantOut.SweepTxHash != nil {
|
||||
sweepTxId = instantOut.SweepTxHash.String()
|
||||
|
|
@ -1290,7 +1290,7 @@ func rpcInstantOut(instantOut *instantout.InstantOut) *clientrpc.InstantOut {
|
|||
reservations[i] = res.ID[:]
|
||||
}
|
||||
|
||||
return &clientrpc.InstantOut{
|
||||
return &looprpc.InstantOut{
|
||||
SwapHash: instantOut.SwapHash[:],
|
||||
State: string(instantOut.State),
|
||||
Amount: uint64(instantOut.Value),
|
||||
|
|
@ -1299,49 +1299,49 @@ func rpcInstantOut(instantOut *instantout.InstantOut) *clientrpc.InstantOut {
|
|||
}
|
||||
}
|
||||
|
||||
func rpcAutoloopReason(reason liquidity.Reason) (clientrpc.AutoReason, error) {
|
||||
func rpcAutoloopReason(reason liquidity.Reason) (looprpc.AutoReason, error) {
|
||||
switch reason {
|
||||
case liquidity.ReasonNone:
|
||||
return clientrpc.AutoReason_AUTO_REASON_UNKNOWN, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_UNKNOWN, nil
|
||||
|
||||
case liquidity.ReasonBudgetNotStarted:
|
||||
return clientrpc.AutoReason_AUTO_REASON_BUDGET_NOT_STARTED, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_BUDGET_NOT_STARTED, nil
|
||||
|
||||
case liquidity.ReasonSweepFees:
|
||||
return clientrpc.AutoReason_AUTO_REASON_SWEEP_FEES, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_SWEEP_FEES, nil
|
||||
|
||||
case liquidity.ReasonBudgetElapsed:
|
||||
return clientrpc.AutoReason_AUTO_REASON_BUDGET_ELAPSED, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_BUDGET_ELAPSED, nil
|
||||
|
||||
case liquidity.ReasonInFlight:
|
||||
return clientrpc.AutoReason_AUTO_REASON_IN_FLIGHT, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_IN_FLIGHT, nil
|
||||
|
||||
case liquidity.ReasonSwapFee:
|
||||
return clientrpc.AutoReason_AUTO_REASON_SWAP_FEE, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_SWAP_FEE, nil
|
||||
|
||||
case liquidity.ReasonMinerFee:
|
||||
return clientrpc.AutoReason_AUTO_REASON_MINER_FEE, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_MINER_FEE, nil
|
||||
|
||||
case liquidity.ReasonPrepay:
|
||||
return clientrpc.AutoReason_AUTO_REASON_PREPAY, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_PREPAY, nil
|
||||
|
||||
case liquidity.ReasonFailureBackoff:
|
||||
return clientrpc.AutoReason_AUTO_REASON_FAILURE_BACKOFF, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_FAILURE_BACKOFF, nil
|
||||
|
||||
case liquidity.ReasonLoopOut:
|
||||
return clientrpc.AutoReason_AUTO_REASON_LOOP_OUT, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_LOOP_OUT, nil
|
||||
|
||||
case liquidity.ReasonLoopIn:
|
||||
return clientrpc.AutoReason_AUTO_REASON_LOOP_IN, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_LOOP_IN, nil
|
||||
|
||||
case liquidity.ReasonLiquidityOk:
|
||||
return clientrpc.AutoReason_AUTO_REASON_LIQUIDITY_OK, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_LIQUIDITY_OK, nil
|
||||
|
||||
case liquidity.ReasonBudgetInsufficient:
|
||||
return clientrpc.AutoReason_AUTO_REASON_BUDGET_INSUFFICIENT, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_BUDGET_INSUFFICIENT, nil
|
||||
|
||||
case liquidity.ReasonFeePPMInsufficient:
|
||||
return clientrpc.AutoReason_AUTO_REASON_SWAP_FEE, nil
|
||||
return looprpc.AutoReason_AUTO_REASON_SWAP_FEE, nil
|
||||
|
||||
default:
|
||||
return 0, fmt.Errorf("unknown autoloop reason: %v", reason)
|
||||
|
|
@ -1420,7 +1420,7 @@ func validateLoopInRequest(htlcConfTarget int32, external bool) (int32, error) {
|
|||
// address and label of the loop out request. It also checks that the requested
|
||||
// loop amount is valid given the available balance.
|
||||
func validateLoopOutRequest(ctx context.Context, lnd lndclient.LightningClient,
|
||||
chainParams *chaincfg.Params, req *clientrpc.LoopOutRequest,
|
||||
chainParams *chaincfg.Params, req *looprpc.LoopOutRequest,
|
||||
sweepAddr btcutil.Address, maxParts uint32) (int32, error) {
|
||||
|
||||
// Check that the provided destination address has the correct format
|
||||
|
|
@ -1562,9 +1562,9 @@ func getPublicationDeadline(unixTimestamp uint64) time.Time {
|
|||
// ToClientReservations converts a slice of server
|
||||
// reservations to a slice of client reservations.
|
||||
func ToClientReservations(
|
||||
res []*reservation.Reservation) []*clientrpc.ClientReservation {
|
||||
res []*reservation.Reservation) []*looprpc.ClientReservation {
|
||||
|
||||
var result []*clientrpc.ClientReservation
|
||||
var result []*looprpc.ClientReservation
|
||||
for _, r := range res {
|
||||
result = append(result, toClientReservation(r))
|
||||
}
|
||||
|
|
@ -1575,7 +1575,7 @@ func ToClientReservations(
|
|||
// toClientReservation converts a server reservation to a
|
||||
// client reservation.
|
||||
func toClientReservation(
|
||||
res *reservation.Reservation) *clientrpc.ClientReservation {
|
||||
res *reservation.Reservation) *looprpc.ClientReservation {
|
||||
|
||||
var (
|
||||
txid string
|
||||
|
|
@ -1586,7 +1586,7 @@ func toClientReservation(
|
|||
vout = res.Outpoint.Index
|
||||
}
|
||||
|
||||
return &clientrpc.ClientReservation{
|
||||
return &looprpc.ClientReservation{
|
||||
ReservationId: res.ID[:],
|
||||
State: string(res.State),
|
||||
Amount: uint64(res.Value),
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package loopdb
|
|||
import (
|
||||
"math"
|
||||
|
||||
looprpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
)
|
||||
|
||||
// ProtocolVersion represents the protocol version (declared on rpc level) that
|
||||
|
|
@ -64,7 +64,7 @@ const (
|
|||
|
||||
// stableRPCProtocolVersion defines the current stable RPC protocol
|
||||
// version.
|
||||
stableRPCProtocolVersion = looprpc.ProtocolVersion_MUSIG2
|
||||
stableRPCProtocolVersion = swapserverrpc.ProtocolVersion_MUSIG2
|
||||
|
||||
// experimentalRPCProtocolVersion defines the RPC protocol version that
|
||||
// includes all currently experimentally released features.
|
||||
|
|
@ -80,7 +80,7 @@ var (
|
|||
|
||||
// CurrentRPCProtocolVersion returns the RPC protocol version selected to be
|
||||
// used for new swaps.
|
||||
func CurrentRPCProtocolVersion() looprpc.ProtocolVersion {
|
||||
func CurrentRPCProtocolVersion() swapserverrpc.ProtocolVersion {
|
||||
return currentRPCProtocolVersion
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package loopdb
|
|||
import (
|
||||
"testing"
|
||||
|
||||
looprpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
|
@ -28,19 +28,19 @@ func TestProtocolVersionSanity(t *testing.T) {
|
|||
ProtocolVersionMuSig2,
|
||||
}
|
||||
|
||||
rpcVersions := [...]looprpc.ProtocolVersion{
|
||||
looprpc.ProtocolVersion_LEGACY,
|
||||
looprpc.ProtocolVersion_MULTI_LOOP_OUT,
|
||||
looprpc.ProtocolVersion_NATIVE_SEGWIT_LOOP_IN,
|
||||
looprpc.ProtocolVersion_PREIMAGE_PUSH_LOOP_OUT,
|
||||
looprpc.ProtocolVersion_USER_EXPIRY_LOOP_OUT,
|
||||
looprpc.ProtocolVersion_HTLC_V2,
|
||||
looprpc.ProtocolVersion_MULTI_LOOP_IN,
|
||||
looprpc.ProtocolVersion_LOOP_OUT_CANCEL,
|
||||
looprpc.ProtocolVersion_PROBE,
|
||||
looprpc.ProtocolVersion_ROUTING_PLUGIN,
|
||||
looprpc.ProtocolVersion_HTLC_V3,
|
||||
looprpc.ProtocolVersion_MUSIG2,
|
||||
rpcVersions := [...]swapserverrpc.ProtocolVersion{
|
||||
swapserverrpc.ProtocolVersion_LEGACY,
|
||||
swapserverrpc.ProtocolVersion_MULTI_LOOP_OUT,
|
||||
swapserverrpc.ProtocolVersion_NATIVE_SEGWIT_LOOP_IN,
|
||||
swapserverrpc.ProtocolVersion_PREIMAGE_PUSH_LOOP_OUT,
|
||||
swapserverrpc.ProtocolVersion_USER_EXPIRY_LOOP_OUT,
|
||||
swapserverrpc.ProtocolVersion_HTLC_V2,
|
||||
swapserverrpc.ProtocolVersion_MULTI_LOOP_IN,
|
||||
swapserverrpc.ProtocolVersion_LOOP_OUT_CANCEL,
|
||||
swapserverrpc.ProtocolVersion_PROBE,
|
||||
swapserverrpc.ProtocolVersion_ROUTING_PLUGIN,
|
||||
swapserverrpc.ProtocolVersion_HTLC_V3,
|
||||
swapserverrpc.ProtocolVersion_MUSIG2,
|
||||
}
|
||||
|
||||
require.Equal(t, len(versions), len(rpcVersions))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
looprpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
)
|
||||
|
||||
// AddressProtocolVersion represents the protocol version (declared on rpc
|
||||
|
|
@ -15,7 +15,7 @@ const (
|
|||
|
||||
// stableRPCProtocolVersion defines the current stable RPC protocol
|
||||
// version.
|
||||
stableRPCProtocolVersion = looprpc.StaticAddressProtocolVersion_V0
|
||||
stableRPCProtocolVersion = swapserverrpc.StaticAddressProtocolVersion_V0
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -27,7 +27,7 @@ var (
|
|||
|
||||
// CurrentRPCProtocolVersion returns the RPC protocol version selected to be
|
||||
// used for new swaps.
|
||||
func CurrentRPCProtocolVersion() looprpc.StaticAddressProtocolVersion {
|
||||
func CurrentRPCProtocolVersion() swapserverrpc.StaticAddressProtocolVersion {
|
||||
return currentRPCProtocolVersion
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/aperture/l402"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
looprpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
|
|
@ -143,7 +143,7 @@ type swapServerClient interface {
|
|||
}
|
||||
|
||||
type grpcSwapServerClient struct {
|
||||
server looprpc.SwapServerClient
|
||||
server swapserverrpc.SwapServerClient
|
||||
conn *grpc.ClientConn
|
||||
|
||||
wg sync.WaitGroup
|
||||
|
|
@ -178,7 +178,7 @@ func newSwapServerClient(cfg *ClientConfig, l402Store l402.Store) (
|
|||
return nil, err
|
||||
}
|
||||
|
||||
server := looprpc.NewSwapServerClient(serverConn)
|
||||
server := swapserverrpc.NewSwapServerClient(serverConn)
|
||||
|
||||
return &grpcSwapServerClient{
|
||||
conn: serverConn,
|
||||
|
|
@ -192,7 +192,7 @@ func (s *grpcSwapServerClient) GetLoopOutTerms(ctx context.Context,
|
|||
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
|
||||
defer rpcCancel()
|
||||
terms, err := s.server.LoopOutTerms(rpcCtx,
|
||||
&looprpc.ServerLoopOutTermsRequest{
|
||||
&swapserverrpc.ServerLoopOutTermsRequest{
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
UserAgent: UserAgent(initiator),
|
||||
},
|
||||
|
|
@ -216,7 +216,7 @@ func (s *grpcSwapServerClient) GetLoopOutQuote(ctx context.Context,
|
|||
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
|
||||
defer rpcCancel()
|
||||
quoteResp, err := s.server.LoopOutQuote(rpcCtx,
|
||||
&looprpc.ServerLoopOutQuoteRequest{
|
||||
&swapserverrpc.ServerLoopOutQuoteRequest{
|
||||
Amt: uint64(amt),
|
||||
SwapPublicationDeadline: swapPublicationDeadline.Unix(),
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
|
|
@ -251,7 +251,7 @@ func (s *grpcSwapServerClient) GetLoopInTerms(ctx context.Context,
|
|||
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
|
||||
defer rpcCancel()
|
||||
terms, err := s.server.LoopInTerms(rpcCtx,
|
||||
&looprpc.ServerLoopInTermsRequest{
|
||||
&swapserverrpc.ServerLoopInTermsRequest{
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
UserAgent: UserAgent(initiator),
|
||||
},
|
||||
|
|
@ -278,7 +278,7 @@ func (s *grpcSwapServerClient) GetLoopInQuote(ctx context.Context,
|
|||
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
|
||||
defer rpcCancel()
|
||||
|
||||
req := &looprpc.ServerLoopInQuoteRequest{
|
||||
req := &swapserverrpc.ServerLoopInQuoteRequest{
|
||||
Amt: uint64(amt),
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
Pubkey: pubKey[:],
|
||||
|
|
@ -310,12 +310,12 @@ func (s *grpcSwapServerClient) GetLoopInQuote(ctx context.Context,
|
|||
|
||||
// marshallRouteHints marshalls a list of route hints.
|
||||
func marshallRouteHints(routeHints [][]zpay32.HopHint) (
|
||||
[]*looprpc.RouteHint, error) {
|
||||
[]*swapserverrpc.RouteHint, error) {
|
||||
|
||||
rpcRouteHints := make([]*looprpc.RouteHint, 0, len(routeHints))
|
||||
rpcRouteHints := make([]*swapserverrpc.RouteHint, 0, len(routeHints))
|
||||
for _, routeHint := range routeHints {
|
||||
rpcRouteHint := make(
|
||||
[]*looprpc.HopHint, 0, len(routeHint),
|
||||
[]*swapserverrpc.HopHint, 0, len(routeHint),
|
||||
)
|
||||
for _, hint := range routeHint {
|
||||
rpcHint, err := marshallHopHint(hint)
|
||||
|
|
@ -325,7 +325,7 @@ func marshallRouteHints(routeHints [][]zpay32.HopHint) (
|
|||
|
||||
rpcRouteHint = append(rpcRouteHint, rpcHint)
|
||||
}
|
||||
rpcRouteHints = append(rpcRouteHints, &looprpc.RouteHint{
|
||||
rpcRouteHints = append(rpcRouteHints, &swapserverrpc.RouteHint{
|
||||
HopHints: rpcRouteHint,
|
||||
})
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ func marshallRouteHints(routeHints [][]zpay32.HopHint) (
|
|||
}
|
||||
|
||||
// marshallHopHint marshalls a single hop hint.
|
||||
func marshallHopHint(hint zpay32.HopHint) (*looprpc.HopHint, error) {
|
||||
func marshallHopHint(hint zpay32.HopHint) (*swapserverrpc.HopHint, error) {
|
||||
nodeID, err := route.NewVertexFromBytes(
|
||||
hint.NodeID.SerializeCompressed(),
|
||||
)
|
||||
|
|
@ -342,7 +342,7 @@ func marshallHopHint(hint zpay32.HopHint) (*looprpc.HopHint, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &looprpc.HopHint{
|
||||
return &swapserverrpc.HopHint{
|
||||
ChanId: hint.ChannelID,
|
||||
CltvExpiryDelta: uint32(hint.CLTVExpiryDelta),
|
||||
FeeBaseMsat: hint.FeeBaseMSat,
|
||||
|
|
@ -363,7 +363,7 @@ func (s *grpcSwapServerClient) Probe(ctx context.Context, amt btcutil.Amount,
|
|||
return err
|
||||
}
|
||||
|
||||
req := &looprpc.ServerProbeRequest{
|
||||
req := &swapserverrpc.ServerProbeRequest{
|
||||
Amt: uint64(amt),
|
||||
Target: target[:],
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
|
|
@ -386,7 +386,7 @@ func (s *grpcSwapServerClient) NewLoopOutSwap(ctx context.Context,
|
|||
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
|
||||
defer rpcCancel()
|
||||
swapResp, err := s.server.NewLoopOutSwap(rpcCtx,
|
||||
&looprpc.ServerLoopOutRequest{
|
||||
&swapserverrpc.ServerLoopOutRequest{
|
||||
SwapHash: swapHash[:],
|
||||
Amt: uint64(amount),
|
||||
ReceiverKey: receiverKey[:],
|
||||
|
|
@ -425,7 +425,7 @@ func (s *grpcSwapServerClient) PushLoopOutPreimage(ctx context.Context,
|
|||
defer rpcCancel()
|
||||
|
||||
_, err := s.server.LoopOutPushPreimage(rpcCtx,
|
||||
&looprpc.ServerLoopOutPushPreimageRequest{
|
||||
&swapserverrpc.ServerLoopOutPushPreimageRequest{
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
Preimage: preimage[:],
|
||||
},
|
||||
|
|
@ -442,7 +442,7 @@ func (s *grpcSwapServerClient) NewLoopInSwap(ctx context.Context,
|
|||
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
|
||||
defer rpcCancel()
|
||||
|
||||
req := &looprpc.ServerLoopInRequest{
|
||||
req := &swapserverrpc.ServerLoopInRequest{
|
||||
SwapHash: swapHash[:],
|
||||
Amt: uint64(amount),
|
||||
SenderKey: senderScriptKey[:],
|
||||
|
|
@ -486,7 +486,7 @@ func (s *grpcSwapServerClient) NewLoopInSwap(ctx context.Context,
|
|||
// ServerUpdate summarizes an update from the swap server.
|
||||
type ServerUpdate struct {
|
||||
// State is the state that the server has sent us.
|
||||
State looprpc.ServerSwapState
|
||||
State swapserverrpc.ServerSwapState
|
||||
|
||||
// Timestamp is the time of the server state update.
|
||||
Timestamp time.Time
|
||||
|
|
@ -498,7 +498,7 @@ func (s *grpcSwapServerClient) SubscribeLoopInUpdates(ctx context.Context,
|
|||
hash lntypes.Hash) (<-chan *ServerUpdate, <-chan error, error) {
|
||||
|
||||
resp, err := s.server.SubscribeLoopInUpdates(
|
||||
ctx, &looprpc.SubscribeUpdatesRequest{
|
||||
ctx, &swapserverrpc.SubscribeUpdatesRequest{
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
SwapHash: hash[:],
|
||||
},
|
||||
|
|
@ -529,7 +529,7 @@ func (s *grpcSwapServerClient) SubscribeLoopOutUpdates(ctx context.Context,
|
|||
hash lntypes.Hash) (<-chan *ServerUpdate, <-chan error, error) {
|
||||
|
||||
resp, err := s.server.SubscribeLoopOutUpdates(
|
||||
ctx, &looprpc.SubscribeUpdatesRequest{
|
||||
ctx, &swapserverrpc.SubscribeUpdatesRequest{
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
SwapHash: hash[:],
|
||||
},
|
||||
|
|
@ -668,7 +668,7 @@ type outCancelDetails struct {
|
|||
func (s *grpcSwapServerClient) CancelLoopOutSwap(ctx context.Context,
|
||||
details *outCancelDetails) error {
|
||||
|
||||
req := &looprpc.CancelLoopOutSwapRequest{
|
||||
req := &swapserverrpc.CancelLoopOutSwapRequest{
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
SwapHash: details.hash[:],
|
||||
PaymentAddress: details.paymentAddr[:],
|
||||
|
|
@ -689,7 +689,7 @@ func (s *grpcSwapServerClient) CancelLoopOutSwap(ctx context.Context,
|
|||
func (s *grpcSwapServerClient) RecommendRoutingPlugin(ctx context.Context,
|
||||
swapHash lntypes.Hash, paymentAddr [32]byte) (RoutingPluginType, error) {
|
||||
|
||||
req := &looprpc.RecommendRoutingPluginReq{
|
||||
req := &swapserverrpc.RecommendRoutingPluginReq{
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
SwapHash: swapHash[:],
|
||||
PaymentAddress: paymentAddr[:],
|
||||
|
|
@ -705,10 +705,10 @@ func (s *grpcSwapServerClient) RecommendRoutingPlugin(ctx context.Context,
|
|||
|
||||
var plugin RoutingPluginType
|
||||
switch res.Plugin {
|
||||
case looprpc.RoutingPlugin_NONE:
|
||||
case swapserverrpc.RoutingPlugin_NONE:
|
||||
plugin = RoutingPluginNone
|
||||
|
||||
case looprpc.RoutingPlugin_LOW_HIGH:
|
||||
case swapserverrpc.RoutingPlugin_LOW_HIGH:
|
||||
plugin = RoutingPluginLowHigh
|
||||
|
||||
default:
|
||||
|
|
@ -724,16 +724,16 @@ func (s *grpcSwapServerClient) ReportRoutingResult(ctx context.Context,
|
|||
swapHash lntypes.Hash, paymentAddr [32]byte, plugin RoutingPluginType,
|
||||
success bool, attempts int32, totalTime int64) error {
|
||||
|
||||
var rpcRoutingPlugin looprpc.RoutingPlugin
|
||||
var rpcRoutingPlugin swapserverrpc.RoutingPlugin
|
||||
switch plugin {
|
||||
case RoutingPluginLowHigh:
|
||||
rpcRoutingPlugin = looprpc.RoutingPlugin_LOW_HIGH
|
||||
rpcRoutingPlugin = swapserverrpc.RoutingPlugin_LOW_HIGH
|
||||
|
||||
default:
|
||||
rpcRoutingPlugin = looprpc.RoutingPlugin_NONE
|
||||
rpcRoutingPlugin = swapserverrpc.RoutingPlugin_NONE
|
||||
}
|
||||
|
||||
req := &looprpc.ReportRoutingResultReq{
|
||||
req := &swapserverrpc.ReportRoutingResultReq{
|
||||
ProtocolVersion: loopdb.CurrentRPCProtocolVersion(),
|
||||
SwapHash: swapHash[:],
|
||||
PaymentAddress: paymentAddr[:],
|
||||
|
|
@ -757,8 +757,8 @@ func (s *grpcSwapServerClient) MuSig2SignSweep(ctx context.Context,
|
|||
paymentAddr [32]byte, nonce []byte, sweepTxPsbt []byte) (
|
||||
[]byte, []byte, error) {
|
||||
|
||||
req := &looprpc.MuSig2SignSweepReq{
|
||||
ProtocolVersion: looprpc.ProtocolVersion(protocolVersion),
|
||||
req := &swapserverrpc.MuSig2SignSweepReq{
|
||||
ProtocolVersion: swapserverrpc.ProtocolVersion(protocolVersion),
|
||||
SwapHash: swapHash[:],
|
||||
PaymentAddress: paymentAddr[:],
|
||||
Nonce: nonce,
|
||||
|
|
@ -787,13 +787,13 @@ func (s *grpcSwapServerClient) MultiMuSig2SignSweep(ctx context.Context,
|
|||
prevoutMap map[wire.OutPoint]*wire.TxOut) (
|
||||
[]byte, []byte, error) {
|
||||
|
||||
prevOutInfo := make([]*looprpc.PrevoutInfo, 0, len(prevoutMap))
|
||||
prevOutInfo := make([]*swapserverrpc.PrevoutInfo, 0, len(prevoutMap))
|
||||
for prevOut, txOut := range prevoutMap {
|
||||
txOut := *txOut
|
||||
prevOut := prevOut
|
||||
|
||||
prevOutInfo = append(prevOutInfo,
|
||||
&looprpc.PrevoutInfo{
|
||||
&swapserverrpc.PrevoutInfo{
|
||||
TxidBytes: prevOut.Hash[:],
|
||||
OutputIndex: prevOut.Index,
|
||||
Value: uint64(txOut.Value),
|
||||
|
|
@ -801,8 +801,8 @@ func (s *grpcSwapServerClient) MultiMuSig2SignSweep(ctx context.Context,
|
|||
})
|
||||
}
|
||||
|
||||
req := &looprpc.MuSig2SignSweepReq{
|
||||
ProtocolVersion: looprpc.ProtocolVersion(protocolVersion),
|
||||
req := &swapserverrpc.MuSig2SignSweepReq{
|
||||
ProtocolVersion: swapserverrpc.ProtocolVersion(protocolVersion),
|
||||
SwapHash: swapHash[:],
|
||||
PaymentAddress: paymentAddr[:],
|
||||
Nonce: nonce,
|
||||
|
|
@ -827,8 +827,8 @@ func (s *grpcSwapServerClient) PushKey(ctx context.Context,
|
|||
protocolVersion loopdb.ProtocolVersion, swapHash lntypes.Hash,
|
||||
clientInternalPrivateKey [32]byte) error {
|
||||
|
||||
req := &looprpc.ServerPushKeyReq{
|
||||
ProtocolVersion: looprpc.ProtocolVersion(protocolVersion),
|
||||
req := &swapserverrpc.ServerPushKeyReq{
|
||||
ProtocolVersion: swapserverrpc.ProtocolVersion(protocolVersion),
|
||||
SwapHash: swapHash[:],
|
||||
InternalPrivkey: clientInternalPrivateKey[:],
|
||||
}
|
||||
|
|
@ -843,7 +843,7 @@ func (s *grpcSwapServerClient) PushKey(ctx context.Context,
|
|||
// FetchL402 is a helper function that tries to fetch an l402 token from the
|
||||
// server.
|
||||
func (s *grpcSwapServerClient) FetchL402(ctx context.Context) error {
|
||||
req := &looprpc.FetchL402Request{}
|
||||
req := &swapserverrpc.FetchL402Request{}
|
||||
|
||||
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
|
||||
defer rpcCancel()
|
||||
|
|
@ -853,24 +853,24 @@ func (s *grpcSwapServerClient) FetchL402(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func rpcRouteCancel(details *outCancelDetails) (
|
||||
*looprpc.CancelLoopOutSwapRequest_RouteCancel, error) {
|
||||
*swapserverrpc.CancelLoopOutSwapRequest_RouteCancel, error) {
|
||||
|
||||
attempts := make(
|
||||
[]*looprpc.HtlcAttempt, len(details.metadata.attempts),
|
||||
[]*swapserverrpc.HtlcAttempt, len(details.metadata.attempts),
|
||||
)
|
||||
for i, remaining := range details.metadata.attempts {
|
||||
attempts[i] = &looprpc.HtlcAttempt{
|
||||
attempts[i] = &swapserverrpc.HtlcAttempt{
|
||||
RemainingHops: remaining,
|
||||
}
|
||||
}
|
||||
|
||||
resp := &looprpc.CancelLoopOutSwapRequest_RouteCancel{
|
||||
RouteCancel: &looprpc.RouteCancel{
|
||||
resp := &swapserverrpc.CancelLoopOutSwapRequest_RouteCancel{
|
||||
RouteCancel: &swapserverrpc.RouteCancel{
|
||||
Attempts: attempts,
|
||||
// We can cast our lnd failure reason to a loop payment
|
||||
// failure reason because these values are copied 1:1
|
||||
// from lnd.
|
||||
Failure: looprpc.PaymentFailureReason(
|
||||
Failure: swapserverrpc.PaymentFailureReason(
|
||||
details.metadata.failureReason,
|
||||
),
|
||||
},
|
||||
|
|
@ -878,10 +878,10 @@ func rpcRouteCancel(details *outCancelDetails) (
|
|||
|
||||
switch details.metadata.paymentType {
|
||||
case paymentTypePrepay:
|
||||
resp.RouteCancel.RouteType = looprpc.RoutePaymentType_PREPAY_ROUTE
|
||||
resp.RouteCancel.RouteType = swapserverrpc.RoutePaymentType_PREPAY_ROUTE
|
||||
|
||||
case paymentTypeInvoice:
|
||||
resp.RouteCancel.RouteType = looprpc.RoutePaymentType_INVOICE_ROUTE
|
||||
resp.RouteCancel.RouteType = swapserverrpc.RoutePaymentType_INVOICE_ROUTE
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown payment type: %v",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue