multi: do not rename swapserverrpc to looprpc

Many imports renamed it, but it was not needed.
This commit is contained in:
Boris Nagaev 2024-09-10 09:54:17 -03:00
parent 6db2a39331
commit 8447f58ff9
No known key found for this signature in database
10 changed files with 196 additions and 195 deletions

View file

@ -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",