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

lightningnetwork / lnd / 17189880600

24 Aug 2025 02:23PM UTC coverage: 66.762% (+9.4%) from 57.321%
17189880600

Pull #9432

github

web-flow
Merge a4a00e732 into 0c2f045f5
Pull Request #9432: multi: add upfront-shutdown-address to lnd.conf.

31 of 39 new or added lines in 4 files covered. (79.49%)

22 existing lines in 8 files now uncovered.

136012 of 203728 relevant lines covered (66.76%)

21523.06 hits per line

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

87.18
/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, params *chaincfg.Params) *ZeroConfAcceptor {
5✔
28

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

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

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

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

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

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

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

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

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

81
// A compile-time constraint to ensure ZeroConfAcceptor implements the
82
// MultiplexAcceptor interface.
83
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