diff --git a/cmd/loop/loopin.go b/cmd/loop/loopin.go index bf990ca..0cb4812 100644 --- a/cmd/loop/loopin.go +++ b/cmd/loop/loopin.go @@ -7,27 +7,36 @@ import ( "github.com/btcsuite/btcutil" "github.com/lightninglabs/loop/looprpc" "github.com/lightninglabs/loop/swap" + "github.com/lightningnetwork/lnd/routing/route" "github.com/urfave/cli" ) -var loopInCommand = cli.Command{ - Name: "in", - Usage: "perform an on-chain to off-chain swap (loop in)", - ArgsUsage: "amt", - Description: ` +var ( + lastHopFlag = cli.StringFlag{ + Name: "last_hop", + Usage: "the pubkey of the last hop to use for this swap", + } + + loopInCommand = cli.Command{ + Name: "in", + Usage: "perform an on-chain to off-chain swap (loop in)", + ArgsUsage: "amt", + Description: ` Send the amount in satoshis specified by the amt argument off-chain.`, - Flags: []cli.Flag{ - cli.Uint64Flag{ - Name: "amt", - Usage: "the amount in satoshis to loop in", - }, - cli.BoolFlag{ - Name: "external", - Usage: "expect htlc to be published externally", + Flags: []cli.Flag{ + cli.Uint64Flag{ + Name: "amt", + Usage: "the amount in satoshis to loop in", + }, + cli.BoolFlag{ + Name: "external", + Usage: "expect htlc to be published externally", + }, + lastHopFlag, }, - }, - Action: loopIn, -} + Action: loopIn, + } +) func loopIn(ctx *cli.Context) error { args := ctx.Args() @@ -73,12 +82,25 @@ func loopIn(ctx *cli.Context) error { return err } - resp, err := client.LoopIn(context.Background(), &looprpc.LoopInRequest{ + req := &looprpc.LoopInRequest{ Amt: int64(amt), MaxMinerFee: int64(limits.maxMinerFee), MaxSwapFee: int64(limits.maxSwapFee), ExternalHtlc: external, - }) + } + + if ctx.IsSet(lastHopFlag.Name) { + lastHop, err := route.NewVertexFromStr( + ctx.String(lastHopFlag.Name), + ) + if err != nil { + return err + } + + req.LastHop = lastHop[:] + } + + resp, err := client.LoopIn(context.Background(), req) if err != nil { return err } diff --git a/loopin.go b/loopin.go index aceda47..98a979e 100644 --- a/loopin.go +++ b/loopin.go @@ -114,7 +114,7 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig, // htlc. log.Infof("Initiating swap request at height %v", currentHeight) swapResp, err := cfg.server.NewLoopInSwap(globalCtx, swapHash, - request.Amount, senderKey, swapInvoice, + request.Amount, senderKey, swapInvoice, request.LastHop, ) if err != nil { return nil, fmt.Errorf("cannot initiate swap: %v", err) diff --git a/looprpc/server.pb.go b/looprpc/server.pb.go index 9b1afbf..5d2e6f8 100644 --- a/looprpc/server.pb.go +++ b/looprpc/server.pb.go @@ -374,6 +374,7 @@ type ServerLoopInRequest struct { SwapHash []byte `protobuf:"bytes,2,opt,name=swap_hash,json=swapHash,proto3" json:"swap_hash,omitempty"` Amt uint64 `protobuf:"varint,3,opt,name=amt,proto3" json:"amt,omitempty"` SwapInvoice string `protobuf:"bytes,4,opt,name=swap_invoice,json=swapInvoice,proto3" json:"swap_invoice,omitempty"` + LastHop []byte `protobuf:"bytes,5,opt,name=last_hop,json=lastHop,proto3" json:"last_hop,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -432,6 +433,13 @@ func (m *ServerLoopInRequest) GetSwapInvoice() string { return "" } +func (m *ServerLoopInRequest) GetLastHop() []byte { + if m != nil { + return m.LastHop + } + return nil +} + type ServerLoopInResponse struct { ReceiverKey []byte `protobuf:"bytes,1,opt,name=receiver_key,json=receiverKey,proto3" json:"receiver_key,omitempty"` Expiry int32 `protobuf:"varint,2,opt,name=expiry,proto3" json:"expiry,omitempty"` @@ -689,50 +697,51 @@ func init() { func init() { proto.RegisterFile("server.proto", fileDescriptor_ad098daeda4239f7) } var fileDescriptor_ad098daeda4239f7 = []byte{ - // 677 bytes of a gzipped FileDescriptorProto + // 693 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x4e, 0xdb, 0x4c, - 0x10, 0x95, 0x9d, 0x10, 0xb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0x23, 0xed, 0x0f, 0x22, - 0x86, 0x5e, 0x7d, 0xd3, 0xd9, 0xa9, 0x05, 0x2f, 0x14, 0xe1, 0xf3, 0xa4, 0x7e, 0x68, 0xcb, 0xfe, - 0x0f, 0x07, 0x9e, 0x95, 0x64, 0xa6, 0x82, 0xb3, 0x14, 0x95, 0x4e, 0xdd, 0x35, 0x62, 0x23, 0x1e, - 0xf5, 0x50, 0xeb, 0x6c, 0x06, 0x4b, 0x0a, 0x3b, 0x36, 0x10, 0x79, 0x05, 0xcb, 0x22, 0x41, 0x41, - 0xc7, 0x77, 0x24, 0x57, 0x93, 0xda, 0x06, 0xcd, 0x68, 0x5d, 0x80, 0x14, 0x59, 0xdf, 0xce, 0x5b, - 0xd3, 0xf3, 0x34, 0x0d, 0xa2, 0xa6, 0x7d, 0x0e, 0x0d, 0xbc, 0x15, 0x51, 0x32, 0xd6, 0x5a, 0x17, - 0x02, 0x7b, 0xf2, 0x23, 0x58, 0x2b, 0x28, 0x3b, 0x1b, 0x72, 0x89, 0x99, 0x8b, 0xd6, 0x05, 0xe7, - 0x81, 0x2e, 0xb8, 0xf3, 0x5d, 0xf8, 0xe9, 0x02, 0x99, 0xbe, 0x8b, 0xec, 0xc2, 0xaa, 0x69, 0x49, - 0xc7, 0x31, 0x32, 0x19, 0xf6, 0x31, 0x95, 0xd6, 0x87, 0x15, 0xdd, 0xca, 0xe0, 0x87, 0x4a, 0xd0, - 0x1a, 0xe8, 0x15, 0x85, 0x5f, 0x30, 0xbb, 0x6d, 0x51, 0x9d, 0x8f, 0x10, 0xc9, 0x36, 0xb4, 0xb3, - 0x52, 0x98, 0x50, 0x89, 0xda, 0x82, 0xda, 0x7b, 0xd7, 0x73, 0x8c, 0x9d, 0x47, 0x88, 0x01, 0x95, - 0xda, 0x27, 0x6b, 0xa7, 0x1a, 0xad, 0xae, 0x47, 0x6b, 0x1a, 0xe4, 0x20, 0x96, 0x64, 0x17, 0x56, - 0xe2, 0x88, 0x85, 0xba, 0x15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, 0x23, 0x72, 0xda, 0x17, 0x50, 0xc3, 0x3b, 0x1e, 0x24, 0x63, 0xc5, 0x75, 0xc9, + 0x33, 0x2f, 0x37, 0x80, 0x76, 0x81, 0xd9, 0xc5, 0x90, 0x09, 0xcc, 0x54, 0x34, 0x2a, 0x58, 0x8f, + 0x54, 0xc1, 0x5e, 0xac, 0xc2, 0x0f, 0x1b, 0xc8, 0x74, 0x2f, 0xb2, 0x07, 0xeb, 0xba, 0x24, 0x1d, + 0x47, 0x18, 0x0b, 0xbf, 0x8f, 0xa9, 0x30, 0x3a, 0xac, 0xa9, 0x52, 0x3a, 0x7e, 0x24, 0x09, 0xb5, + 0x41, 0xad, 0xc8, 0xff, 0x82, 0x59, 0xb7, 0xba, 0x7c, 0x1f, 0x23, 0x92, 0x1d, 0x68, 0x65, 0x29, + 0x3f, 0xa1, 0x02, 0x95, 0x04, 0x95, 0x0f, 0xb6, 0x63, 0x69, 0x39, 0x8f, 0x11, 0x3d, 0x2a, 0x94, + 0x4e, 0x46, 0x4e, 0x39, 0x5a, 0x55, 0x8d, 0xd6, 0xd0, 0x91, 0xc3, 0x48, 0x90, 0x3d, 0x58, 0x8b, + 0x82, 0xd8, 0x57, 0xa5, 0x68, 0xc4, 0x86, 0xb1, 0x70, 0x96, 0x24, 0x46, 0x15, 0x6a, 0x45, 0x41, + 0x7c, 0x79, 0x4b, 0xf9, 0xa1, 0x4a, 0x28, 0x2c, 0xbd, 0x2b, 0x60, 0x6b, 0x39, 0x2c, 0xbd, 0xcb, + 0x61, 0xbb, 0x00, 0xbd, 0x50, 0x8c, 0xfc, 0x3e, 0x86, 0x82, 0x3a, 0x75, 0xb5, 0x83, 0x86, 0x8c, + 0x1c, 0xc9, 0x80, 0xbb, 0x51, 0x5a, 0xc3, 0x15, 0x26, 0x51, 0x6a, 0xd6, 0xe0, 0xf6, 0x4b, 0xba, + 0xa9, 0x24, 0xd9, 0x99, 0x66, 0xaa, 0x17, 0x55, 0x62, 0xb9, 0x33, 0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 0x7c, 0x08, 0x39, 0x83, 0x96, 0x99, 0xf7, 0x54, 0xad, 0x83, 0x6c, 0xce, 0x04, 0x67, 0xa5, 0xba, + 0x73, 0xb2, 0x66, 0xd8, 0xab, 0x8c, 0x9b, 0xa6, 0x3a, 0x9b, 0x5b, 0x61, 0x54, 0x77, 0x11, 0x44, + 0x57, 0xbd, 0xae, 0xa9, 0x8f, 0xf8, 0xbb, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x99, 0x4f, + 0x5f, 0xfb, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/looprpc/server.proto b/looprpc/server.proto index 6ab28f6..920d0b2 100644 --- a/looprpc/server.proto +++ b/looprpc/server.proto @@ -78,6 +78,7 @@ message ServerLoopInRequest { bytes swap_hash = 2; uint64 amt = 3; string swap_invoice = 4; + bytes last_hop = 5; } message ServerLoopInResponse { diff --git a/server_mock_test.go b/server_mock_test.go index b8cbdd7..21dba55 100644 --- a/server_mock_test.go +++ b/server_mock_test.go @@ -11,6 +11,7 @@ import ( "github.com/lightninglabs/loop/test" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" + "github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/zpay32" ) @@ -127,7 +128,7 @@ func getInvoice(hash lntypes.Hash, amt btcutil.Amount, memo string) (string, err func (s *serverMock) NewLoopInSwap(ctx context.Context, swapHash lntypes.Hash, amount btcutil.Amount, - senderKey [33]byte, swapInvoice string) ( + senderKey [33]byte, swapInvoice string, lastHop *route.Vertex) ( *newLoopInResponse, error) { _, receiverKey := test.CreateKey(101) diff --git a/swap_server_client.go b/swap_server_client.go index 95c4786..38204a2 100644 --- a/swap_server_client.go +++ b/swap_server_client.go @@ -14,6 +14,7 @@ import ( "github.com/lightninglabs/loop/looprpc" "github.com/lightninglabs/loop/lsat" "github.com/lightningnetwork/lnd/lntypes" + "github.com/lightningnetwork/lnd/routing/route" "google.golang.org/grpc" "google.golang.org/grpc/credentials" ) @@ -40,7 +41,7 @@ type swapServerClient interface { NewLoopInSwap(ctx context.Context, swapHash lntypes.Hash, amount btcutil.Amount, - senderKey [33]byte, swapInvoice string) ( + senderKey [33]byte, swapInvoice string, lastHop *route.Vertex) ( *newLoopInResponse, error) } @@ -203,18 +204,22 @@ func (s *grpcSwapServerClient) NewLoopOutSwap(ctx context.Context, func (s *grpcSwapServerClient) NewLoopInSwap(ctx context.Context, swapHash lntypes.Hash, amount btcutil.Amount, senderKey [33]byte, - swapInvoice string) (*newLoopInResponse, error) { + swapInvoice string, lastHop *route.Vertex) (*newLoopInResponse, error) { rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout) defer rpcCancel() - swapResp, err := s.server.NewLoopInSwap(rpcCtx, - &looprpc.ServerLoopInRequest{ - SwapHash: swapHash[:], - Amt: uint64(amount), - SenderKey: senderKey[:], - SwapInvoice: swapInvoice, - }, - ) + + req := &looprpc.ServerLoopInRequest{ + SwapHash: swapHash[:], + Amt: uint64(amount), + SenderKey: senderKey[:], + SwapInvoice: swapInvoice, + } + if lastHop != nil { + req.LastHop = lastHop[:] + } + + swapResp, err := s.server.NewLoopInSwap(rpcCtx, req) if err != nil { return nil, err }