Skip to content

Commit d55b4ab

Browse files
authored
Merge pull request #926 from starius/fix-protos
looprpc: fix several minor bugs
2 parents 802e3f6 + 1af9cb7 commit d55b4ab

File tree

12 files changed

+483
-485
lines changed

12 files changed

+483
-485
lines changed

Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ rpc:
7676

7777
rpc-check: rpc
7878
@$(call print, "Verifying protos.")
79-
if test -n "$$(git describe --dirty | grep dirty)"; then echo "Protos not properly formatted or not compiled with correct version!"; git status; git diff; exit 1; fi
79+
if test -n "$$(git status --porcelain)"; then echo "Protos not properly formatted or not compiled with correct version!"; git status; git diff; exit 1; fi
8080

8181
rpc-js-compile:
8282
@$(call print, "Compiling JSON/WASM stubs.")
@@ -135,8 +135,11 @@ mod-tidy:
135135

136136
mod-check:
137137
@$(call print, "Checking modules.")
138-
$(GOMOD) tidy
139-
if test -n "$$(git status | grep -e "go.mod\|go.sum")"; then echo "Running go mod tidy changes go.mod/go.sum"; git status; git diff; exit 1; fi
138+
GOPROXY=direct $(GOMOD) tidy
139+
cd swapserverrpc/ && GOPROXY=direct $(GOMOD) tidy
140+
cd looprpc/ && GOPROXY=direct $(GOMOD) tidy
141+
cd tools/ && GOPROXY=direct $(GOMOD) tidy
142+
if test -n "$$(git status --porcelain)"; then echo "Running go mod tidy changes go.mod/go.sum"; git status; git diff; exit 1; fi
140143

141144
sqlc:
142145
@$(call print, "Generating sql models and queries in Go")

go.mod

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ require (
2121
github.com/lightninglabs/aperture v0.3.8-beta
2222
github.com/lightninglabs/lndclient v0.19.0-2
2323
github.com/lightninglabs/loop/looprpc v1.0.0
24-
github.com/lightninglabs/loop/swapserverrpc v1.0.11
25-
// TODO(guggero): Update this to a commit in master.
26-
github.com/lightninglabs/taproot-assets v0.5.2-0.20250306114727-f0691d155619
24+
github.com/lightninglabs/loop/swapserverrpc v1.0.13
25+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250311211321-3793cf066af7
2726
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20250304192711-9feb761b4ec4
2827
github.com/lightningnetwork/lnd/cert v1.2.2
2928
github.com/lightningnetwork/lnd/clock v1.1.1

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,8 @@ github.com/lightninglabs/neutrino/cache v1.1.2 h1:C9DY/DAPaPxbFC+xNNEI/z1SJY9GS3
11391139
github.com/lightninglabs/neutrino/cache v1.1.2/go.mod h1:XJNcgdOw1LQnanGjw8Vj44CvguYA25IMKjWFZczwZuo=
11401140
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9Z6CpKxl13mS48idsu6F+cEZf0lkyiV+Dq9g=
11411141
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
1142-
github.com/lightninglabs/taproot-assets v0.5.2-0.20250306114727-f0691d155619 h1:GrWJ7yA8YQuh6wf98qA8TF9jkOvH0D9tdM9tSxpFnnc=
1143-
github.com/lightninglabs/taproot-assets v0.5.2-0.20250306114727-f0691d155619/go.mod h1:+EoY8qorrcrutZeX9S5lqI76CbPewbM2B6P2O2gEZL4=
1142+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250311211321-3793cf066af7 h1:CGOClQ1aEXe2W1ZTaEZr8LUBtD6HaBYc6ZydvTY8A4M=
1143+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250311211321-3793cf066af7/go.mod h1:+EoY8qorrcrutZeX9S5lqI76CbPewbM2B6P2O2gEZL4=
11441144
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
11451145
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
11461146
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20250304192711-9feb761b4ec4 h1:3UfT25sO71q3V7RSb/wE0ruiwk3ex30h7ZvPZ0O2Z80=

loopd/swapclient_server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context,
15801580
}
15811581
}
15821582

1583-
txhash, pkScript, err := s.withdrawalManager.DeliverWithdrawalRequest(
1583+
txhash, address, err := s.withdrawalManager.DeliverWithdrawalRequest(
15841584
ctx, outpoints, req.DestAddr, req.SatPerVbyte, req.Amount,
15851585
)
15861586
if err != nil {
@@ -1589,7 +1589,7 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context,
15891589

15901590
return &looprpc.WithdrawDepositsResponse{
15911591
WithdrawalTxHash: txhash,
1592-
PkScript: pkScript,
1592+
Address: address,
15931593
}, err
15941594
}
15951595

looprpc/client.pb.go

+442-442
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

+2-2
Original file line numberDiff line numberDiff line change
@@ -1678,9 +1678,9 @@ message WithdrawDepositsResponse {
16781678
string withdrawal_tx_hash = 1;
16791679

16801680
/*
1681-
The pkscript of the withdrawal transaction.
1681+
The destination address of the withdrawal transaction.
16821682
*/
1683-
string pk_script = 2;
1683+
string address = 2;
16841684
}
16851685

16861686
message OutPoint {

looprpc/client.swagger.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@
14401440
"next_start_time": {
14411441
"type": "string",
14421442
"format": "int64",
1443-
"description": "Timestamp of the last swap returned."
1443+
"description": "Timestamp to use for paging start_timestamp_ns."
14441444
}
14451445
}
14461446
},
@@ -2132,9 +2132,9 @@
21322132
"type": "string",
21332133
"description": "The transaction hash of the withdrawal transaction."
21342134
},
2135-
"pk_script": {
2135+
"address": {
21362136
"type": "string",
2137-
"description": "The pkscript of the withdrawal transaction."
2137+
"description": "The destination address of the withdrawal transaction."
21382138
}
21392139
}
21402140
},

looprpc/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.23.7
66

77
require (
88
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3
9-
github.com/lightninglabs/loop/swapserverrpc v1.0.11
9+
github.com/lightninglabs/loop/swapserverrpc v1.0.13
1010
google.golang.org/grpc v1.64.1
1111
google.golang.org/protobuf v1.34.2
1212
)

looprpc/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,8 @@ github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NB
793793
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
794794
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
795795
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
796-
github.com/lightninglabs/loop/swapserverrpc v1.0.11 h1:R/8c/bo4rpqm5/cfi944rj24oQUlZu+xXjzMhEDSkrc=
797-
github.com/lightninglabs/loop/swapserverrpc v1.0.11/go.mod h1:Ml3gMwe/iTRLvu1QGGZzXcr0DYSa9sJGwKPktLaWtwE=
796+
github.com/lightninglabs/loop/swapserverrpc v1.0.13 h1:Qf4L8QBJKzhKRcC8dpvfrrBEXJMF3+XbpomAHEJsRDY=
797+
github.com/lightninglabs/loop/swapserverrpc v1.0.13/go.mod h1:Ml3gMwe/iTRLvu1QGGZzXcr0DYSa9sJGwKPktLaWtwE=
798798
github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
799799
github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
800800
github.com/lyft/protoc-gen-star/v2 v2.0.1/go.mod h1:RcCdONR2ScXaYnQC5tUzxzlpA3WVYF7/opLeUgcQs/o=

staticaddr/loopin/actions.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/lightninglabs/loop/staticaddr/deposit"
2020
"github.com/lightninglabs/loop/staticaddr/version"
2121
"github.com/lightninglabs/loop/swap"
22-
looprpc "github.com/lightninglabs/loop/swapserverrpc"
22+
"github.com/lightninglabs/loop/swapserverrpc"
2323
"github.com/lightningnetwork/lnd/chainntnfs"
2424
"github.com/lightningnetwork/lnd/input"
2525
"github.com/lightningnetwork/lnd/invoices"
@@ -117,7 +117,7 @@ func (f *FSM) InitHtlcAction(ctx context.Context,
117117
version.CurrentRPCProtocolVersion(),
118118
)
119119

120-
loopInReq := &looprpc.ServerStaticAddressLoopInRequest{
120+
loopInReq := &swapserverrpc.ServerStaticAddressLoopInRequest{
121121
SwapHash: f.loopIn.SwapHash[:],
122122
DepositOutpoints: f.loopIn.DepositOutpoints,
123123
HtlcClientPubKey: f.loopIn.ClientPubkey.SerializeCompressed(),
@@ -144,7 +144,7 @@ func (f *FSM) InitHtlcAction(ctx context.Context,
144144
// attempt.
145145
pushEmptySigs := func() {
146146
_, err = f.cfg.Server.PushStaticAddressHtlcSigs(
147-
ctx, &looprpc.PushStaticAddressHtlcSigsRequest{
147+
ctx, &swapserverrpc.PushStaticAddressHtlcSigsRequest{
148148
SwapHash: f.loopIn.SwapHash[:],
149149
},
150150
)
@@ -382,17 +382,17 @@ func (f *FSM) SignHtlcTxAction(ctx context.Context,
382382
}
383383

384384
// Push htlc tx sigs to server.
385-
pushHtlcReq := &looprpc.PushStaticAddressHtlcSigsRequest{
385+
pushHtlcReq := &swapserverrpc.PushStaticAddressHtlcSigsRequest{
386386
SwapHash: f.loopIn.SwapHash[:],
387-
StandardHtlcInfo: &looprpc.ClientHtlcSigningInfo{
387+
StandardHtlcInfo: &swapserverrpc.ClientHtlcSigningInfo{
388388
Nonces: clientHtlcNonces,
389389
Sigs: htlcSigs,
390390
},
391-
HighFeeHtlcInfo: &looprpc.ClientHtlcSigningInfo{
391+
HighFeeHtlcInfo: &swapserverrpc.ClientHtlcSigningInfo{
392392
Nonces: highFeeNonces,
393393
Sigs: htlcSigsHighFee,
394394
},
395-
ExtremeFeeHtlcInfo: &looprpc.ClientHtlcSigningInfo{
395+
ExtremeFeeHtlcInfo: &swapserverrpc.ClientHtlcSigningInfo{
396396
Nonces: extremelyHighNonces,
397397
Sigs: htlcSigsExtremelyHighFee,
398398
},

staticaddr/loopin/manager.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/lightninglabs/loop/labels"
2020
"github.com/lightninglabs/loop/staticaddr/deposit"
2121
"github.com/lightninglabs/loop/swapserverrpc"
22-
looprpc "github.com/lightninglabs/loop/swapserverrpc"
2322
"github.com/lightningnetwork/lnd/lntypes"
2423
"github.com/lightningnetwork/lnd/routing/route"
2524
)
@@ -34,7 +33,7 @@ const (
3433
type Config struct {
3534
// Server is the client that is used to communicate with the static
3635
// address server.
37-
Server looprpc.StaticAddressServerClient
36+
Server swapserverrpc.StaticAddressServerClient
3837

3938
// AddressManager gives the withdrawal manager access to static address
4039
// parameters.
@@ -232,7 +231,7 @@ func (m *Manager) notifyNotFinished(ctx context.Context, swapHash lntypes.Hash,
232231
txId chainhash.Hash) error {
233232

234233
_, err := m.cfg.Server.PushStaticAddressSweeplessSigs(
235-
ctx, &looprpc.PushStaticAddressSweeplessSigsRequest{
234+
ctx, &swapserverrpc.PushStaticAddressSweeplessSigsRequest{
236235
SwapHash: swapHash[:],
237236
Txid: txId[:],
238237
ErrorMessage: SwapNotFinishedMsg,
@@ -332,7 +331,7 @@ func (m *Manager) handleLoopInSweepReq(ctx context.Context,
332331

333332
// We'll now sign for every deposit that is part of the loop-in.
334333
responseMap := make(
335-
map[string]*looprpc.ClientSweeplessSigningInfo,
334+
map[string]*swapserverrpc.ClientSweeplessSigningInfo,
336335
len(req.DepositToNonces),
337336
)
338337

@@ -394,16 +393,17 @@ func (m *Manager) handleLoopInSweepReq(ctx context.Context,
394393
return err
395394
}
396395

397-
responseMap[depositOutpoint] = &looprpc.ClientSweeplessSigningInfo{ //nolint:lll
396+
signingInfo := &swapserverrpc.ClientSweeplessSigningInfo{
398397
Nonce: musig2Session.PublicNonce[:],
399398
Sig: sig,
400399
}
400+
responseMap[depositOutpoint] = signingInfo
401401
}
402402

403403
txHash := sweepTx.TxHash()
404404

405405
_, err = m.cfg.Server.PushStaticAddressSweeplessSigs(
406-
ctx, &looprpc.PushStaticAddressSweeplessSigsRequest{
406+
ctx, &swapserverrpc.PushStaticAddressSweeplessSigsRequest{
407407
SwapHash: loopIn.SwapHash[:],
408408
Txid: txHash[:],
409409
SigningInfo: responseMap,

staticaddr/withdraw/manager.go

+8-12
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ type newWithdrawalRequest struct {
8383
// newWithdrawalResponse is used to return withdrawal info and error to the
8484
// server.
8585
type newWithdrawalResponse struct {
86-
txHash string
87-
withdrawalPkScript string
88-
err error
86+
txHash string
87+
withdrawalAddress string
88+
err error
8989
}
9090

9191
// Manager manages the withdrawal state machines.
@@ -147,10 +147,6 @@ func (m *Manager) Run(ctx context.Context) error {
147147
// initialization.
148148
close(m.initChan)
149149

150-
var (
151-
txHash string
152-
pkScript string
153-
)
154150
for {
155151
select {
156152
case <-newBlockChan:
@@ -161,7 +157,7 @@ func (m *Manager) Run(ctx context.Context) error {
161157
}
162158

163159
case req := <-m.newWithdrawalRequestChan:
164-
txHash, pkScript, err = m.WithdrawDeposits(
160+
txHash, withdrawalAddress, err := m.WithdrawDeposits(
165161
ctx, req.outpoints, req.destAddr,
166162
req.satPerVbyte, req.amount,
167163
)
@@ -173,9 +169,9 @@ func (m *Manager) Run(ctx context.Context) error {
173169
// We forward the initialized loop-in and error to
174170
// DeliverLoopInRequest.
175171
resp := &newWithdrawalResponse{
176-
txHash: txHash,
177-
withdrawalPkScript: pkScript,
178-
err: err,
172+
txHash: txHash,
173+
withdrawalAddress: withdrawalAddress,
174+
err: err,
179175
}
180176
select {
181177
case req.respChan <- resp:
@@ -956,7 +952,7 @@ func (m *Manager) DeliverWithdrawalRequest(ctx context.Context,
956952
// Wait for the response from the manager run loop.
957953
select {
958954
case resp := <-request.respChan:
959-
return resp.txHash, resp.withdrawalPkScript, resp.err
955+
return resp.txHash, resp.withdrawalAddress, resp.err
960956

961957
case <-m.exitChan:
962958
return "", "", fmt.Errorf("withdrawal manager has been " +

0 commit comments

Comments
 (0)