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

lightningnetwork / lnd / 15205630088

23 May 2025 08:14AM UTC coverage: 57.45% (-11.5%) from 68.996%
15205630088

Pull #9784

github

web-flow
Merge f8b9f36a3 into c52a6ddeb
Pull Request #9784: [wip] lnwallet+walletrpc: add SubmitPackage and related RPC call

47 of 96 new or added lines in 5 files covered. (48.96%)

30087 existing lines in 459 files now uncovered.

95586 of 166380 relevant lines covered (57.45%)

0.61 hits per line

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

0.0
/chainreg/no_chain_backend.go
1
package chainreg
2

3
import (
4
        "errors"
5
        "time"
6

7
        "github.com/btcsuite/btcd/btcjson"
8
        "github.com/btcsuite/btcd/btcutil"
9
        "github.com/btcsuite/btcd/chaincfg/chainhash"
10
        "github.com/btcsuite/btcd/wire"
11
        "github.com/btcsuite/btcwallet/chain"
12
        "github.com/btcsuite/btcwallet/waddrmgr"
13
        "github.com/lightningnetwork/lnd/chainntnfs"
14
        graphdb "github.com/lightningnetwork/lnd/graph/db"
15
        "github.com/lightningnetwork/lnd/lnwallet/chainfee"
16
        "github.com/lightningnetwork/lnd/routing/chainview"
17
)
18

19
var (
20
        // defaultFee is the fee that is returned by NoChainBackend.
21
        defaultFee = chainfee.FeePerKwFloor
22

23
        // noChainBackendName is the backend name returned by NoChainBackend.
24
        noChainBackendName = "nochainbackend"
25

26
        // errNotImplemented is the error that is returned by NoChainBackend for
27
        // any operation that is not supported by it. Such paths should in
28
        // practice never been hit, so seeing this error either means a remote
29
        // signing instance was used for an unsupported purpose or a previously
30
        // forgotten edge case path was hit.
31
        errNotImplemented = errors.New("not implemented in nochainbackend " +
32
                "mode")
33

34
        // noChainBackendBestHash is the chain hash of the chain tip that is
35
        // returned by NoChainBackend.
36
        noChainBackendBestHash = &chainhash.Hash{0x01}
37

38
        // noChainBackendBestHeight is the best height that is returned by
39
        // NoChainBackend.
40
        noChainBackendBestHeight int32 = 1
41
)
42

43
// NoChainBackend is a mock implementation of the following interfaces:
44
//   - chainview.FilteredChainView
45
//   - chainntnfs.ChainNotifier
46
//   - chainfee.Estimator
47
type NoChainBackend struct {
48
}
49

50
func (n *NoChainBackend) EstimateFeePerKW(uint32) (chainfee.SatPerKWeight,
51
        error) {
×
52

×
53
        return defaultFee, nil
×
54
}
×
55

56
func (n *NoChainBackend) RelayFeePerKW() chainfee.SatPerKWeight {
×
57
        return defaultFee
×
58
}
×
59

60
func (n *NoChainBackend) RegisterConfirmationsNtfn(*chainhash.Hash, []byte,
61
        uint32, uint32,
62
        ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error) {
×
63

×
64
        return nil, errNotImplemented
×
65
}
×
66

67
func (n *NoChainBackend) RegisterSpendNtfn(*wire.OutPoint, []byte,
68
        uint32) (*chainntnfs.SpendEvent, error) {
×
69

×
70
        return nil, errNotImplemented
×
71
}
×
72

73
func (n *NoChainBackend) RegisterBlockEpochNtfn(
74
        *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) {
×
75

×
76
        epochChan := make(chan *chainntnfs.BlockEpoch)
×
77
        return &chainntnfs.BlockEpochEvent{
×
78
                Epochs: epochChan,
×
79
                Cancel: func() {
×
80
                        close(epochChan)
×
81
                },
×
82
        }, nil
83
}
84

85
func (n *NoChainBackend) Started() bool {
×
86
        return true
×
87
}
×
88

89
func (n *NoChainBackend) FilteredBlocks() <-chan *chainview.FilteredBlock {
×
90
        return make(chan *chainview.FilteredBlock)
×
91
}
×
92

93
func (n *NoChainBackend) DisconnectedBlocks() <-chan *chainview.FilteredBlock {
×
94
        return make(chan *chainview.FilteredBlock)
×
95
}
×
96

97
func (n *NoChainBackend) UpdateFilter([]graphdb.EdgePoint, uint32) error {
×
98
        return nil
×
99
}
×
100

101
func (n *NoChainBackend) FilterBlock(*chainhash.Hash) (*chainview.FilteredBlock,
102
        error) {
×
103

×
104
        return nil, errNotImplemented
×
105
}
×
106

107
func (n *NoChainBackend) Start() error {
×
108
        return nil
×
109
}
×
110

111
func (n *NoChainBackend) Stop() error {
×
112
        return nil
×
113
}
×
114

115
var _ chainview.FilteredChainView = (*NoChainBackend)(nil)
116
var _ chainntnfs.ChainNotifier = (*NoChainBackend)(nil)
117
var _ chainfee.Estimator = (*NoChainBackend)(nil)
118

119
// NoChainSource is a mock implementation of chain.Interface.
120
// The mock is designed to return static values where necessary to make any
121
// caller believe the chain is fully synced to virtual block height 1 (hash
122
// 0x0000..0001). That should avoid calls to other methods completely since they
123
// are only used for advancing the chain forward.
124
type NoChainSource struct {
125
        notifChan chan interface{}
126

127
        BestBlockTime time.Time
128
}
129

130
func (n *NoChainSource) Start() error {
×
131
        n.notifChan = make(chan interface{})
×
132

×
133
        go func() {
×
134
                n.notifChan <- &chain.RescanFinished{
×
135
                        Hash:   noChainBackendBestHash,
×
136
                        Height: noChainBackendBestHeight,
×
137
                        Time:   n.BestBlockTime,
×
138
                }
×
139
        }()
×
140

141
        return nil
×
142
}
143

144
func (n *NoChainSource) Stop() {
×
145
}
×
146

147
func (n *NoChainSource) WaitForShutdown() {
×
148
}
×
149

150
func (n *NoChainSource) GetBestBlock() (*chainhash.Hash, int32, error) {
×
151
        return noChainBackendBestHash, noChainBackendBestHeight, nil
×
152
}
×
153

154
func (n *NoChainSource) GetBlock(*chainhash.Hash) (*wire.MsgBlock, error) {
×
155
        return &wire.MsgBlock{
×
156
                Header: wire.BlockHeader{
×
157
                        Timestamp: n.BestBlockTime,
×
158
                },
×
159
                Transactions: []*wire.MsgTx{},
×
160
        }, nil
×
161
}
×
162

163
func (n *NoChainSource) GetBlockHash(int64) (*chainhash.Hash, error) {
×
164
        return noChainBackendBestHash, nil
×
165
}
×
166

167
func (n *NoChainSource) GetBlockHeader(*chainhash.Hash) (*wire.BlockHeader,
168
        error) {
×
169

×
170
        return &wire.BlockHeader{
×
171
                Timestamp: n.BestBlockTime,
×
172
        }, nil
×
173
}
×
174

175
func (n *NoChainSource) IsCurrent() bool {
×
176
        return true
×
177
}
×
178

179
func (n *NoChainSource) FilterBlocks(
180
        *chain.FilterBlocksRequest) (*chain.FilterBlocksResponse, error) {
×
181

×
182
        return nil, errNotImplemented
×
183
}
×
184

185
func (n *NoChainSource) BlockStamp() (*waddrmgr.BlockStamp, error) {
×
186
        return nil, errNotImplemented
×
187
}
×
188

189
func (n *NoChainSource) SendRawTransaction(*wire.MsgTx, bool) (*chainhash.Hash,
190
        error) {
×
191

×
192
        return nil, errNotImplemented
×
193
}
×
194

195
func (n *NoChainSource) Rescan(*chainhash.Hash, []btcutil.Address,
196
        map[wire.OutPoint]btcutil.Address) error {
×
197

×
198
        return nil
×
199
}
×
200

201
func (n *NoChainSource) NotifyReceived([]btcutil.Address) error {
×
202
        return nil
×
203
}
×
204

205
func (n *NoChainSource) NotifyBlocks() error {
×
206
        return nil
×
207
}
×
208

209
func (n *NoChainSource) Notifications() <-chan interface{} {
×
210
        return n.notifChan
×
211
}
×
212

213
func (n *NoChainSource) BackEnd() string {
×
214
        return noChainBackendName
×
215
}
×
216

217
func (n *NoChainSource) TestMempoolAccept([]*wire.MsgTx,
218
        float64) ([]*btcjson.TestMempoolAcceptResult, error) {
×
219

×
220
        return nil, nil
×
221
}
×
222

223
func (n *NoChainSource) MapRPCErr(err error) error {
×
224
        return err
×
225
}
×
226

227
func (n *NoChainSource) SubmitPackage([]*wire.MsgTx, *wire.MsgTx,
NEW
228
        *float64) (*btcjson.SubmitPackageResult, error) {
×
NEW
229

×
NEW
230
        return nil, errNotImplemented
×
NEW
231
}
×
232

233
var _ chain.Interface = (*NoChainSource)(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