Merge pull request #825 from starius/swapserverrpc-looprpc

multi: do not rename swapserverrpc to looprpc
This commit is contained in:
Boris Nagaev 2024-09-25 12:42:10 -03:00 committed by GitHub
commit 96d321ece7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 1257 additions and 598 deletions

View file

@ -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[:],
},
)

View file

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

View file

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

View file

@ -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(),
}

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

@ -81,7 +81,9 @@ type InstantLoopOutRequest struct {
ReceiverKey []byte `protobuf:"bytes,1,opt,name=receiver_key,json=receiverKey,proto3" json:"receiver_key,omitempty"`
// The hash of the preimage that will be used to settle the htlc.
SwapHash []byte `protobuf:"bytes,2,opt,name=swap_hash,json=swapHash,proto3" json:"swap_hash,omitempty"`
// The requested absolute block height of the on-chain htlc.
// The requested absolute block height of the on-chain htlc. This is
// subjected to min and max constraints as reported in the LoopOutTerms
// response.
Expiry int32 `protobuf:"varint,3,opt,name=expiry,proto3" json:"expiry,omitempty"`
// The fee rate in sat/kw that should be used for the htlc.
HtlcFeeRate uint64 `protobuf:"varint,4,opt,name=htlc_fee_rate,json=htlcFeeRate,proto3" json:"htlc_fee_rate,omitempty"`

View file

@ -30,7 +30,8 @@ service InstantSwapServer {
rpc PushPreimage (PushPreimageRequest) returns (PushPreimageResponse);
// CancelInstantSwap tries to cancel the instant swap. This can only be
// called if the swap has not been accepted yet.
// called if the swap has not been accepted yet. This allows the server to
// release the reservation inputs.
rpc CancelInstantSwap (CancelInstantSwapRequest)
returns (CancelInstantSwapResponse);
@ -48,7 +49,9 @@ message InstantLoopOutRequest {
// The hash of the preimage that will be used to settle the htlc.
bytes swap_hash = 2;
// The requested absolute block height of the on-chain htlc.
// The requested absolute block height of the on-chain htlc. This is
// subjected to min and max constraints as reported in the LoopOutTerms
// response.
int32 expiry = 3;
// The fee rate in sat/kw that should be used for the htlc.

View file

@ -32,7 +32,8 @@ type InstantSwapServerClient interface {
// htlc.
PushPreimage(ctx context.Context, in *PushPreimageRequest, opts ...grpc.CallOption) (*PushPreimageResponse, error)
// CancelInstantSwap tries to cancel the instant swap. This can only be
// called if the swap has not been accepted yet.
// called if the swap has not been accepted yet. This allows the server to
// release the reservation inputs.
CancelInstantSwap(ctx context.Context, in *CancelInstantSwapRequest, opts ...grpc.CallOption) (*CancelInstantSwapResponse, error)
// GetInstantOutQuote returns the absolute fee in satoshis for the swap and
// the pubkey to query the route to estimate offchain payment fees.
@ -128,7 +129,8 @@ type InstantSwapServerServer interface {
// htlc.
PushPreimage(context.Context, *PushPreimageRequest) (*PushPreimageResponse, error)
// CancelInstantSwap tries to cancel the instant swap. This can only be
// called if the swap has not been accepted yet.
// called if the swap has not been accepted yet. This allows the server to
// release the reservation inputs.
CancelInstantSwap(context.Context, *CancelInstantSwapRequest) (*CancelInstantSwapResponse, error)
// GetInstantOutQuote returns the absolute fee in satoshis for the swap and
// the pubkey to query the route to estimate offchain payment fees.

View file

@ -32,7 +32,7 @@ const (
// RESERVATION_NONE is the default value and means that the reservation
// protocol version is not set.
ReservationProtocolVersion_RESERVATION_NONE ReservationProtocolVersion = 0
// RESERVATION_SERVER_REQUEST is the first version of the reservation
// RESERVATION_SERVER_NOTIFY is the first version of the reservation
// protocol where the server notifies the client about a reservation.
ReservationProtocolVersion_RESERVATION_SERVER_NOTIFY ReservationProtocolVersion = 1
)
@ -82,6 +82,9 @@ type ReservationNotificationRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// protocol_version is the maximum version the client supports.
ProtocolVersion ReservationProtocolVersion `protobuf:"varint,1,opt,name=protocol_version,json=protocolVersion,proto3,enum=looprpc.ReservationProtocolVersion" json:"protocol_version,omitempty"`
}
func (x *ReservationNotificationRequest) Reset() {
@ -116,6 +119,13 @@ func (*ReservationNotificationRequest) Descriptor() ([]byte, []int) {
return file_reservation_proto_rawDescGZIP(), []int{0}
}
func (x *ReservationNotificationRequest) GetProtocolVersion() ReservationProtocolVersion {
if x != nil {
return x.ProtocolVersion
}
return ReservationProtocolVersion_RESERVATION_NONE
}
// ServerReservationNotification is a notification sent from the server to the
// client if the server wants to open a reservation.
type ServerReservationNotification struct {
@ -305,9 +315,14 @@ var File_reservation_proto protoreflect.FileDescriptor
var file_reservation_proto_rawDesc = []byte{
0x0a, 0x11, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x22, 0x20, 0x0a, 0x1e,
0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x22, 0x70, 0x0a, 0x1e,
0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x66,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xe3,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4e,
0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69,
0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72,
0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72,
0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xe3,
0x01, 0x0a, 0x1d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f,
@ -379,16 +394,17 @@ var file_reservation_proto_goTypes = []interface{}{
(*ServerOpenReservationResponse)(nil), // 4: looprpc.ServerOpenReservationResponse
}
var file_reservation_proto_depIdxs = []int32{
0, // 0: looprpc.ServerReservationNotification.protocol_version:type_name -> looprpc.ReservationProtocolVersion
1, // 1: looprpc.ReservationService.ReservationNotificationStream:input_type -> looprpc.ReservationNotificationRequest
3, // 2: looprpc.ReservationService.OpenReservation:input_type -> looprpc.ServerOpenReservationRequest
2, // 3: looprpc.ReservationService.ReservationNotificationStream:output_type -> looprpc.ServerReservationNotification
4, // 4: looprpc.ReservationService.OpenReservation:output_type -> looprpc.ServerOpenReservationResponse
3, // [3:5] is the sub-list for method output_type
1, // [1:3] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
0, // 0: looprpc.ReservationNotificationRequest.protocol_version:type_name -> looprpc.ReservationProtocolVersion
0, // 1: looprpc.ServerReservationNotification.protocol_version:type_name -> looprpc.ReservationProtocolVersion
1, // 2: looprpc.ReservationService.ReservationNotificationStream:input_type -> looprpc.ReservationNotificationRequest
3, // 3: looprpc.ReservationService.OpenReservation:input_type -> looprpc.ServerOpenReservationRequest
2, // 4: looprpc.ReservationService.ReservationNotificationStream:output_type -> looprpc.ServerReservationNotification
4, // 5: looprpc.ReservationService.OpenReservation:output_type -> looprpc.ServerOpenReservationResponse
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_reservation_proto_init() }

View file

@ -22,6 +22,8 @@ service ReservationService {
// ReservationNotificationRequest is an empty request sent from the client to
// the server to open a stream to receive reservation notifications.
message ReservationNotificationRequest {
// protocol_version is the maximum version the client supports.
ReservationProtocolVersion protocol_version = 1;
}
// ServerReservationNotification is a notification sent from the server to the
@ -64,7 +66,7 @@ enum ReservationProtocolVersion {
// protocol version is not set.
RESERVATION_NONE = 0;
// RESERVATION_SERVER_REQUEST is the first version of the reservation
// RESERVATION_SERVER_NOTIFY is the first version of the reservation
// protocol where the server notifies the client about a reservation.
RESERVATION_SERVER_NOTIFY = 1;
};

File diff suppressed because it is too large Load diff

View file

@ -284,6 +284,13 @@ message ServerLoopInQuoteRequest {
// loopd/v0.10.0-beta/commit=3b635821
// litd/v0.2.0-alpha/commit=326d754
string user_agent = 6;
// If this is a quote request for a static address loop in, this value
// defines the number of static address deposits that the client wants to
// quote for. The amount of the quote reflects the sum of all deposits. The
// number of deposits here is taken into consideration for the total swap
// fee.
uint32 num_static_address_deposits = 7;
}
message ServerLoopInQuoteResponse {
@ -514,6 +521,7 @@ message ServerProbeRequest {
// The protocol version that the client adheres to.
ProtocolVersion protocol_version = 1;
// The probe amount.
uint64 amt = 2;
// The target node for the probe.
@ -638,12 +646,12 @@ message ServerPushKeyRes {
}
// FetchL402Request is an empty request sent from the client to the server to
// fetch the lnd l402.
// fetch the lnd L402.
message FetchL402Request {
}
// FetchL402Response is an empty response sent from the server to the client to
// confirm the lnd l402.
// confirm the lnd L402.
message FetchL402Response {
}
@ -652,4 +660,61 @@ message FetchL402Response {
enum StaticAddressProtocolVersion {
// V0 is the initially released static address protocol version.
V0 = 0;
}
}
service StaticAddressServer {
// ServerNewAddress generates a new static address for the client to use.
// The server will generate the address and return the server key and the
// address's CSV expiry.
rpc ServerNewAddress (ServerNewAddressRequest)
returns (ServerNewAddressResponse);
// ServerWithdrawDeposits allows to cooperatively sweep deposits that
// haven't timed out yet to the client's wallet. The server will generate
// the partial sigs for the client's selected deposits.
rpc ServerWithdrawDeposits (ServerWithdrawRequest)
returns (ServerWithdrawResponse);
}
message ServerNewAddressRequest {
// The protocol version that the client adheres to.
StaticAddressProtocolVersion protocol_version = 1;
// The client key for the MuSig2 static address output.
bytes client_key = 2;
}
message ServerNewAddressResponse {
ServerAddressParameters params = 1;
}
message ServerAddressParameters {
// The server key for the MuSig2 static address output.
bytes server_key = 1;
// The CSV expiry of the static address output.
uint32 expiry = 2;
}
message ServerWithdrawRequest {
// The deposit outpoints the client wishes to close.
repeated PrevoutInfo outpoints = 1;
// The nonces that the client used to generate the coop close tx sigs.
repeated bytes client_nonces = 2;
// The address that the client wants to sweep the static address deposits
// to.
string client_sweep_addr = 3;
// The fee rate in sat/kw that the client wants to use for the sweep.
uint64 tx_fee_rate = 4;
}
message ServerWithdrawResponse {
// The sweep sigs that the server generated for the htlc.
repeated bytes musig2_sweep_sigs = 1;
// The nonces that the server used to generate the sweepless sweep sigs.
repeated bytes server_nonces = 2;
}

View file

@ -698,3 +698,137 @@ var SwapServer_ServiceDesc = grpc.ServiceDesc{
},
Metadata: "server.proto",
}
// StaticAddressServerClient is the client API for StaticAddressServer service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type StaticAddressServerClient interface {
// ServerNewAddress generates a new static address for the client to use.
// The server will generate the address and return the server key and the
// address's CSV expiry.
ServerNewAddress(ctx context.Context, in *ServerNewAddressRequest, opts ...grpc.CallOption) (*ServerNewAddressResponse, error)
// ServerWithdrawDeposits allows to cooperatively sweep deposits that
// haven't timed out yet to the client's wallet. The server will generate
// the partial sigs for the client's selected deposits.
ServerWithdrawDeposits(ctx context.Context, in *ServerWithdrawRequest, opts ...grpc.CallOption) (*ServerWithdrawResponse, error)
}
type staticAddressServerClient struct {
cc grpc.ClientConnInterface
}
func NewStaticAddressServerClient(cc grpc.ClientConnInterface) StaticAddressServerClient {
return &staticAddressServerClient{cc}
}
func (c *staticAddressServerClient) ServerNewAddress(ctx context.Context, in *ServerNewAddressRequest, opts ...grpc.CallOption) (*ServerNewAddressResponse, error) {
out := new(ServerNewAddressResponse)
err := c.cc.Invoke(ctx, "/looprpc.StaticAddressServer/ServerNewAddress", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *staticAddressServerClient) ServerWithdrawDeposits(ctx context.Context, in *ServerWithdrawRequest, opts ...grpc.CallOption) (*ServerWithdrawResponse, error) {
out := new(ServerWithdrawResponse)
err := c.cc.Invoke(ctx, "/looprpc.StaticAddressServer/ServerWithdrawDeposits", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// StaticAddressServerServer is the server API for StaticAddressServer service.
// All implementations must embed UnimplementedStaticAddressServerServer
// for forward compatibility
type StaticAddressServerServer interface {
// ServerNewAddress generates a new static address for the client to use.
// The server will generate the address and return the server key and the
// address's CSV expiry.
ServerNewAddress(context.Context, *ServerNewAddressRequest) (*ServerNewAddressResponse, error)
// ServerWithdrawDeposits allows to cooperatively sweep deposits that
// haven't timed out yet to the client's wallet. The server will generate
// the partial sigs for the client's selected deposits.
ServerWithdrawDeposits(context.Context, *ServerWithdrawRequest) (*ServerWithdrawResponse, error)
mustEmbedUnimplementedStaticAddressServerServer()
}
// UnimplementedStaticAddressServerServer must be embedded to have forward compatible implementations.
type UnimplementedStaticAddressServerServer struct {
}
func (UnimplementedStaticAddressServerServer) ServerNewAddress(context.Context, *ServerNewAddressRequest) (*ServerNewAddressResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ServerNewAddress not implemented")
}
func (UnimplementedStaticAddressServerServer) ServerWithdrawDeposits(context.Context, *ServerWithdrawRequest) (*ServerWithdrawResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ServerWithdrawDeposits not implemented")
}
func (UnimplementedStaticAddressServerServer) mustEmbedUnimplementedStaticAddressServerServer() {}
// UnsafeStaticAddressServerServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to StaticAddressServerServer will
// result in compilation errors.
type UnsafeStaticAddressServerServer interface {
mustEmbedUnimplementedStaticAddressServerServer()
}
func RegisterStaticAddressServerServer(s grpc.ServiceRegistrar, srv StaticAddressServerServer) {
s.RegisterService(&StaticAddressServer_ServiceDesc, srv)
}
func _StaticAddressServer_ServerNewAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ServerNewAddressRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StaticAddressServerServer).ServerNewAddress(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/looprpc.StaticAddressServer/ServerNewAddress",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StaticAddressServerServer).ServerNewAddress(ctx, req.(*ServerNewAddressRequest))
}
return interceptor(ctx, in, info, handler)
}
func _StaticAddressServer_ServerWithdrawDeposits_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ServerWithdrawRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StaticAddressServerServer).ServerWithdrawDeposits(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/looprpc.StaticAddressServer/ServerWithdrawDeposits",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StaticAddressServerServer).ServerWithdrawDeposits(ctx, req.(*ServerWithdrawRequest))
}
return interceptor(ctx, in, info, handler)
}
// StaticAddressServer_ServiceDesc is the grpc.ServiceDesc for StaticAddressServer service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var StaticAddressServer_ServiceDesc = grpc.ServiceDesc{
ServiceName: "looprpc.StaticAddressServer",
HandlerType: (*StaticAddressServerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ServerNewAddress",
Handler: _StaticAddressServer_ServerNewAddress_Handler,
},
{
MethodName: "ServerWithdrawDeposits",
Handler: _StaticAddressServer_ServerWithdrawDeposits_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "server.proto",
}