Skip to content

Commit 1e9eec1

Browse files
committed
loopd: add hyperloop rpc call
1 parent 746555a commit 1e9eec1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

loopd/perms/perms.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,8 @@ var RequiredPermissions = map[string][]bakery.Op{
120120
Entity: "swap",
121121
Action: "read",
122122
}},
123+
"/looprpc.SwapClient/HyperLoopOut": {{
124+
Entity: "swap",
125+
Action: "write",
126+
}},
123127
}

loopd/swapclient_server.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/lightninglabs/aperture/l402"
1919
"github.com/lightninglabs/lndclient"
2020
"github.com/lightninglabs/loop"
21+
"github.com/lightninglabs/loop/hyperloop"
2122
"github.com/lightninglabs/loop/instantout"
2223
"github.com/lightninglabs/loop/instantout/reservation"
2324
"github.com/lightninglabs/loop/labels"
@@ -83,6 +84,7 @@ type swapClientServer struct {
8384
lnd *lndclient.LndServices
8485
reservationManager *reservation.Manager
8586
instantOutManager *instantout.Manager
87+
hyperloopManager *hyperloop.Manager
8688
swaps map[lntypes.Hash]loop.SwapInfo
8789
subscribers map[int]chan<- interface{}
8890
statusChan chan loop.SwapInfo
@@ -91,6 +93,24 @@ type swapClientServer struct {
9193
mainCtx context.Context
9294
}
9395

96+
func (s *swapClientServer) HyperLoopOut(ctx context.Context,
97+
req *looprpc.HyperLoopOutRequest) (
98+
*looprpc.HyperLoopOutResponse, error) {
99+
100+
log.Infof("HyperLoop out request received")
101+
102+
hyperloop, err := s.hyperloopManager.RequestNewHyperloop(
103+
ctx, btcutil.Amount(req.Amt), req.CustomSweepAddr,
104+
)
105+
if err != nil {
106+
return nil, err
107+
}
108+
109+
return &looprpc.HyperLoopOutResponse{
110+
Hyperloop: hyperloop.ToRpcHyperloop(),
111+
}, nil
112+
}
113+
94114
// LoopOut initiates a loop out swap with the given parameters. The call returns
95115
// after the swap has been set up with the swap server. From that point onwards,
96116
// progress can be tracked via the LoopOutStatus stream that is returned from

0 commit comments

Comments
 (0)