• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 15439942501

04 Jun 2025 10:28AM UTC coverage: 68.827%. First build
15439942501

Pull #9896

github

web-flow
Merge 33efc6831 into 4b3fb1150
Pull Request #9896: release: create branch for v0.19.1-beta.rc1

81 of 660 new or added lines in 7 files covered. (12.27%)

134026 of 194729 relevant lines covered (68.83%)

21986.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lntest/rpc/wallet_kit.go
1
package rpc
2

3
import (
4
        "context"
5

6
        "github.com/lightningnetwork/lnd/lnrpc"
7
        "github.com/lightningnetwork/lnd/lnrpc/signrpc"
8
        "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
9
        "github.com/stretchr/testify/require"
10
)
11

12
// =====================
13
// WalletKitClient related RPCs.
14
// =====================
15

16
type (
17
        SignReq    *walletrpc.SignMessageWithAddrResponse
18
        VerifyResp *walletrpc.VerifyMessageWithAddrResponse
19
)
20

21
// FinalizePsbt makes a RPC call to node's ListUnspent and asserts.
22
func (h *HarnessRPC) ListUnspent(
23
        req *walletrpc.ListUnspentRequest) *walletrpc.ListUnspentResponse {
×
24

×
25
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
26
        defer cancel()
×
27

×
28
        resp, err := h.WalletKit.ListUnspent(ctxt, req)
×
29
        h.NoError(err, "ListUnspent")
×
30

×
31
        return resp
×
32
}
×
33

34
// DeriveKey makes a RPC call to the DeriveKey and asserts.
35
func (h *HarnessRPC) DeriveKey(kl *signrpc.KeyLocator) *signrpc.KeyDescriptor {
×
36
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
37
        defer cancel()
×
38

×
39
        key, err := h.WalletKit.DeriveKey(ctxt, kl)
×
40
        h.NoError(err, "DeriveKey")
×
41

×
42
        return key
×
43
}
×
44

45
// SendOutputs makes a RPC call to the node's WalletKitClient and asserts.
46
func (h *HarnessRPC) SendOutputs(
47
        req *walletrpc.SendOutputsRequest) *walletrpc.SendOutputsResponse {
×
48

×
49
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
50
        defer cancel()
×
51

×
52
        resp, err := h.WalletKit.SendOutputs(ctxt, req)
×
53
        h.NoError(err, "SendOutputs")
×
54

×
55
        return resp
×
56
}
×
57

58
// FundPsbt makes a RPC call to node's FundPsbt and asserts.
59
func (h *HarnessRPC) FundPsbt(
60
        req *walletrpc.FundPsbtRequest) *walletrpc.FundPsbtResponse {
×
61

×
62
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
63
        defer cancel()
×
64

×
65
        resp, err := h.WalletKit.FundPsbt(ctxt, req)
×
66
        h.NoError(err, "FundPsbt")
×
67

×
68
        return resp
×
69
}
×
70

71
// FundPsbtAssertErr makes a RPC call to the node's FundPsbt and asserts an
72
// error is returned.
73
func (h *HarnessRPC) FundPsbtAssertErr(req *walletrpc.FundPsbtRequest) {
×
74
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
75
        defer cancel()
×
76

×
77
        _, err := h.WalletKit.FundPsbt(ctxt, req)
×
78
        require.Error(h, err, "expected error returned")
×
79
}
×
80

81
// FinalizePsbt makes a RPC call to node's FinalizePsbt and asserts.
82
func (h *HarnessRPC) FinalizePsbt(
83
        req *walletrpc.FinalizePsbtRequest) *walletrpc.FinalizePsbtResponse {
×
84

×
85
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
86
        defer cancel()
×
87

×
88
        resp, err := h.WalletKit.FinalizePsbt(ctxt, req)
×
89
        h.NoError(err, "FinalizePsbt")
×
90

×
91
        return resp
×
92
}
×
93

94
// LabelTransactionAssertErr makes a RPC call to the node's LabelTransaction
95
// and asserts an error is returned. It then returns the error.
96
func (h *HarnessRPC) LabelTransactionAssertErr(
97
        req *walletrpc.LabelTransactionRequest) error {
×
98

×
99
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
100
        defer cancel()
×
101

×
102
        _, err := h.WalletKit.LabelTransaction(ctxt, req)
×
103
        require.Error(h, err, "expected error returned")
×
104

×
105
        return err
×
106
}
×
107

108
// LabelTransaction makes a RPC call to the node's LabelTransaction
109
// and asserts no error is returned.
110
func (h *HarnessRPC) LabelTransaction(req *walletrpc.LabelTransactionRequest) {
×
111
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
112
        defer cancel()
×
113

×
114
        _, err := h.WalletKit.LabelTransaction(ctxt, req)
×
115
        h.NoError(err, "LabelTransaction")
×
116
}
×
117

118
// DeriveNextKey makes a RPC call to the DeriveNextKey and asserts.
119
func (h *HarnessRPC) DeriveNextKey(
120
        req *walletrpc.KeyReq) *signrpc.KeyDescriptor {
×
121

×
122
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
123
        defer cancel()
×
124

×
125
        key, err := h.WalletKit.DeriveNextKey(ctxt, req)
×
126
        h.NoError(err, "DeriveNextKey")
×
127

×
128
        return key
×
129
}
×
130

131
// ListAddresses makes a RPC call to the ListAddresses and asserts.
132
func (h *HarnessRPC) ListAddresses(
133
        req *walletrpc.ListAddressesRequest) *walletrpc.ListAddressesResponse {
×
134

×
135
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
136
        defer cancel()
×
137

×
138
        key, err := h.WalletKit.ListAddresses(ctxt, req)
×
139
        h.NoError(err, "ListAddresses")
×
140

×
141
        return key
×
142
}
×
143

144
// SignMessageWithAddr makes a RPC call to the SignMessageWithAddr and asserts.
145
func (h *HarnessRPC) SignMessageWithAddr(
146
        req *walletrpc.SignMessageWithAddrRequest) SignReq {
×
147

×
148
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
149
        defer cancel()
×
150

×
151
        key, err := h.WalletKit.SignMessageWithAddr(ctxt, req)
×
152
        h.NoError(err, "SignMessageWithAddr")
×
153

×
154
        return key
×
155
}
×
156

157
// VerifyMessageWithAddr makes a RPC call to
158
// the VerifyMessageWithAddr and asserts.
159
func (h *HarnessRPC) VerifyMessageWithAddr(
160
        req *walletrpc.VerifyMessageWithAddrRequest) VerifyResp {
×
161

×
162
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
163
        defer cancel()
×
164

×
165
        key, err := h.WalletKit.VerifyMessageWithAddr(ctxt, req)
×
166
        h.NoError(err, "VerifyMessageWithAddr")
×
167

×
168
        return key
×
169
}
×
170

171
// ListSweeps makes a ListSweeps RPC call to the node's WalletKit client.
172
func (h *HarnessRPC) ListSweeps(verbose bool,
173
        startHeight int32) *walletrpc.ListSweepsResponse {
×
174

×
175
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
176
        defer cancel()
×
177

×
178
        req := &walletrpc.ListSweepsRequest{
×
179
                Verbose:     verbose,
×
180
                StartHeight: startHeight,
×
181
        }
×
182
        resp, err := h.WalletKit.ListSweeps(ctxt, req)
×
183
        h.NoError(err, "ListSweeps")
×
184

×
185
        return resp
×
186
}
×
187

188
// PendingSweeps makes a RPC call to the node's WalletKitClient and asserts.
189
func (h *HarnessRPC) PendingSweeps() *walletrpc.PendingSweepsResponse {
×
190
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
191
        defer cancel()
×
192

×
193
        req := &walletrpc.PendingSweepsRequest{}
×
194

×
195
        resp, err := h.WalletKit.PendingSweeps(ctxt, req)
×
196
        h.NoError(err, "PendingSweeps")
×
197

×
198
        return resp
×
199
}
×
200

201
// PublishTransaction makes an RPC call to the node's WalletKitClient and
202
// asserts.
203
func (h *HarnessRPC) PublishTransaction(
204
        req *walletrpc.Transaction) *walletrpc.PublishResponse {
×
205

×
206
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
207
        defer cancel()
×
208

×
209
        resp, err := h.WalletKit.PublishTransaction(ctxt, req)
×
210
        h.NoError(err, "PublishTransaction")
×
211

×
212
        return resp
×
213
}
×
214

215
// GetTransaction makes a RPC call to the node's WalletKitClient and asserts.
216
func (h *HarnessRPC) GetTransaction(
217
        req *walletrpc.GetTransactionRequest) *lnrpc.Transaction {
×
218

×
219
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
220
        defer cancel()
×
221

×
222
        resp, err := h.WalletKit.GetTransaction(ctxt, req)
×
223
        h.NoError(err, "GetTransaction")
×
224

×
225
        return resp
×
226
}
×
227

228
// RemoveTransaction makes an RPC call to the node's WalletKitClient and
229
// asserts.
230
//
231
//nolint:ll
232
func (h *HarnessRPC) RemoveTransaction(
233
        req *walletrpc.GetTransactionRequest) *walletrpc.RemoveTransactionResponse {
×
234

×
235
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
236
        defer cancel()
×
237

×
238
        resp, err := h.WalletKit.RemoveTransaction(ctxt, req)
×
239
        h.NoError(err, "RemoveTransaction")
×
240

×
241
        return resp
×
242
}
×
243

244
// BumpFee makes a RPC call to the node's WalletKitClient and asserts.
245
func (h *HarnessRPC) BumpFee(
246
        req *walletrpc.BumpFeeRequest) *walletrpc.BumpFeeResponse {
×
247

×
248
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
249
        defer cancel()
×
250

×
251
        resp, err := h.WalletKit.BumpFee(ctxt, req)
×
252
        h.NoError(err, "BumpFee")
×
253

×
254
        return resp
×
255
}
×
256

257
// BumpFeeAssertErr makes a RPC call to the node's WalletKitClient and asserts
258
// that an error is returned.
NEW
259
func (h *HarnessRPC) BumpFeeAssertErr(req *walletrpc.BumpFeeRequest) error {
×
NEW
260
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
NEW
261
        defer cancel()
×
NEW
262

×
NEW
263
        _, err := h.WalletKit.BumpFee(ctxt, req)
×
NEW
264
        require.Errorf(h, err, "%s: expect BumpFee to return an error", h.Name)
×
NEW
265

×
NEW
266
        return err
×
NEW
267
}
×
268

269
// BumpForceCloseFee makes a RPC call to the node's WalletKitClient and asserts.
270
//
271
//nolint:ll
272
func (h *HarnessRPC) BumpForceCloseFee(
273
        req *walletrpc.BumpForceCloseFeeRequest) *walletrpc.BumpForceCloseFeeResponse {
×
274

×
275
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
276
        defer cancel()
×
277

×
278
        resp, err := h.WalletKit.BumpForceCloseFee(ctxt, req)
×
279
        h.NoError(err, "BumpForceCloseFee")
×
280

×
281
        return resp
×
282
}
×
283

284
// ListAccounts makes a RPC call to the node's WalletKitClient and asserts.
285
func (h *HarnessRPC) ListAccounts(
286
        req *walletrpc.ListAccountsRequest) *walletrpc.ListAccountsResponse {
×
287

×
288
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
289
        defer cancel()
×
290

×
291
        resp, err := h.WalletKit.ListAccounts(ctxt, req)
×
292
        h.NoError(err, "ListAccounts")
×
293

×
294
        return resp
×
295
}
×
296

297
// ImportAccount makes a RPC call to the node's WalletKitClient and asserts.
298
func (h *HarnessRPC) ImportAccount(
299
        req *walletrpc.ImportAccountRequest) *walletrpc.ImportAccountResponse {
×
300

×
301
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
302
        defer cancel()
×
303

×
304
        resp, err := h.WalletKit.ImportAccount(ctxt, req)
×
305
        h.NoError(err, "ImportAccount")
×
306

×
307
        return resp
×
308
}
×
309

310
// ImportAccountAssertErr makes the ImportAccount RPC call and asserts an error
311
// is returned. It then returns the error.
312
func (h *HarnessRPC) ImportAccountAssertErr(
313
        req *walletrpc.ImportAccountRequest) error {
×
314

×
315
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
316
        defer cancel()
×
317

×
318
        _, err := h.WalletKit.ImportAccount(ctxt, req)
×
319
        require.Error(h, err)
×
320

×
321
        return err
×
322
}
×
323

324
// ImportPublicKey makes a RPC call to the node's WalletKitClient and asserts.
325
//
326
//nolint:ll
327
func (h *HarnessRPC) ImportPublicKey(
328
        req *walletrpc.ImportPublicKeyRequest) *walletrpc.ImportPublicKeyResponse {
×
329

×
330
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
331
        defer cancel()
×
332

×
333
        resp, err := h.WalletKit.ImportPublicKey(ctxt, req)
×
334
        h.NoError(err, "ImportPublicKey")
×
335

×
336
        return resp
×
337
}
×
338

339
// SignPsbt makes a RPC call to the node's WalletKitClient and asserts.
340
func (h *HarnessRPC) SignPsbt(
341
        req *walletrpc.SignPsbtRequest) *walletrpc.SignPsbtResponse {
×
342

×
343
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
344
        defer cancel()
×
345

×
346
        resp, err := h.WalletKit.SignPsbt(ctxt, req)
×
347
        h.NoError(err, "SignPsbt")
×
348

×
349
        return resp
×
350
}
×
351

352
// SignPsbtErr makes a RPC call to the node's WalletKitClient and asserts
353
// an error returned.
354
func (h *HarnessRPC) SignPsbtErr(req *walletrpc.SignPsbtRequest) error {
×
355
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
356
        defer cancel()
×
357

×
358
        _, err := h.WalletKit.SignPsbt(ctxt, req)
×
359
        require.Errorf(h, err, "%s: expect sign psbt to return an error",
×
360
                h.Name)
×
361

×
362
        return err
×
363
}
×
364

365
// ImportTapscript makes a RPC call to the node's WalletKitClient and asserts.
366
//
367
//nolint:ll
368
func (h *HarnessRPC) ImportTapscript(
369
        req *walletrpc.ImportTapscriptRequest) *walletrpc.ImportTapscriptResponse {
×
370

×
371
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
372
        defer cancel()
×
373

×
374
        resp, err := h.WalletKit.ImportTapscript(ctxt, req)
×
375
        h.NoError(err, "ImportTapscript")
×
376

×
377
        return resp
×
378
}
×
379

380
// RequiredReserve makes a RPC call to the node's WalletKitClient and asserts.
381
//
382
//nolint:ll
383
func (h *HarnessRPC) RequiredReserve(
384
        req *walletrpc.RequiredReserveRequest) *walletrpc.RequiredReserveResponse {
×
385

×
386
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
387
        defer cancel()
×
388

×
389
        resp, err := h.WalletKit.RequiredReserve(ctxt, req)
×
390
        h.NoError(err, "RequiredReserve")
×
391

×
392
        return resp
×
393
}
×
394

395
// ListLeases makes a ListLeases RPC call to the node's WalletKit client.
396
func (h *HarnessRPC) ListLeases() *walletrpc.ListLeasesResponse {
×
397
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
398
        defer cancel()
×
399

×
400
        resp, err := h.WalletKit.ListLeases(
×
401
                ctxt, &walletrpc.ListLeasesRequest{},
×
402
        )
×
403
        h.NoError(err, "ListLeases")
×
404

×
405
        return resp
×
406
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc