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

lightningnetwork / lnd / 12885323020

21 Jan 2025 10:47AM UTC coverage: 58.729% (+0.009%) from 58.72%
12885323020

Pull #9432

github

NishantBansal2003
docs: add release notes.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Pull Request #9432: multi: add upfront-shutdown-address to lnd.conf.

30 of 38 new or added lines in 4 files covered. (78.95%)

64 existing lines in 16 files now uncovered.

135482 of 230690 relevant lines covered (58.73%)

19132.94 hits per line

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

86.84
/chanacceptor/zeroconfacceptor.go
1
package chanacceptor
2

3
import (
4
        "github.com/btcsuite/btcd/chaincfg"
5
        "github.com/lightningnetwork/lnd/lnwire"
6
)
7

8
// ZeroConfAcceptor wraps a regular ChainedAcceptor. If no acceptors are in the
9
// ChainedAcceptor, then Accept will reject all channel open requests. This
10
// should only be enabled when the zero-conf feature bit is set and is used to
11
// protect users from a malicious counter-party double-spending the zero-conf
12
// funding tx.
13
type ZeroConfAcceptor struct {
14
        chainedAcceptor *ChainedAcceptor
15
}
16

17
// NewZeroConfAcceptor initializes a ZeroConfAcceptor.
UNCOV
18
func NewZeroConfAcceptor() *ZeroConfAcceptor {
×
UNCOV
19
        return &ZeroConfAcceptor{
×
UNCOV
20
                chainedAcceptor: NewChainedAcceptor(),
×
UNCOV
21
        }
×
UNCOV
22
}
×
23

24
// NewZeroConfAcceptorWithOpts initializes a ZeroConfAcceptor with the given
25
// closeAddress and params.
26
func NewZeroConfAcceptorWithOpts(
27
        closeAddress string,
28
        params *chaincfg.Params,
29
) *ZeroConfAcceptor {
5✔
30

5✔
31
        return &ZeroConfAcceptor{
5✔
32
                chainedAcceptor: NewChainedAcceptorWithOpts(closeAddress,
5✔
33
                        params),
5✔
34
        }
5✔
35
}
5✔
36

37
// AddAcceptor adds a sub-ChannelAcceptor to the internal ChainedAcceptor.
38
func (z *ZeroConfAcceptor) AddAcceptor(acceptor ChannelAcceptor) uint64 {
5✔
39
        return z.chainedAcceptor.AddAcceptor(acceptor)
5✔
40
}
5✔
41

42
// RemoveAcceptor removes a sub-ChannelAcceptor from the internal
43
// ChainedAcceptor.
44
func (z *ZeroConfAcceptor) RemoveAcceptor(id uint64) {
5✔
45
        z.chainedAcceptor.RemoveAcceptor(id)
5✔
46
}
5✔
47

48
// Accept will deny the channel open request if the internal ChainedAcceptor is
49
// empty. If the internal ChainedAcceptor has any acceptors, then Accept will
50
// instead be called on it.
51
//
52
// NOTE: Part of the ChannelAcceptor interface.
53
func (z *ZeroConfAcceptor) Accept(
54
        req *ChannelAcceptRequest) *ChannelAcceptResponse {
9✔
55

9✔
56
        // Alias for less verbosity.
9✔
57
        channelType := req.OpenChanMsg.ChannelType
9✔
58

9✔
59
        // Check if the channel type sets the zero-conf bit.
9✔
60
        var zeroConfSet bool
9✔
61

9✔
62
        if channelType != nil {
15✔
63
                channelFeatures := lnwire.RawFeatureVector(*channelType)
6✔
64
                zeroConfSet = channelFeatures.IsSet(lnwire.ZeroConfRequired)
6✔
65
        }
6✔
66

67
        // If there are no acceptors and the counter-party is requesting a zero
68
        // conf channel, reject the attempt.
69
        if z.chainedAcceptor.numAcceptors() == 0 && zeroConfSet {
14✔
70
                // Deny the channel open request.
5✔
71
                rejectChannel := NewChannelAcceptResponse(
5✔
72
                        false, nil, nil, 0, 0, 0, 0, 0, 0, false,
5✔
73
                )
5✔
74
                return rejectChannel
5✔
75
        }
5✔
76

77
        // Otherwise, the ChainedAcceptor has sub-acceptors, so call Accept on
78
        // it.
79
        return z.chainedAcceptor.Accept(req)
7✔
80
}
81

82
// A compile-time constraint to ensure ZeroConfAcceptor implements the
83
// MultiplexAcceptor interface.
84
var _ MultiplexAcceptor = (*ZeroConfAcceptor)(nil)
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