Skip to content

Commit d22b393

Browse files
authored
Merge pull request #8901 from ellemouton/0-18-2-fix
build: create v0.18.2-beta release branch
2 parents 42b856d + 53b07eb commit d22b393

12 files changed

+105
-40
lines changed

build/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const (
4343
AppMinor uint = 18
4444

4545
// AppPatch defines the application patch for this binary.
46-
AppPatch uint = 1
46+
AppPatch uint = 2
4747

4848
// AppPreRelease MUST only contain characters from semanticAlphabet per
4949
// the semantic versioning spec.

chainreg/no_chain_backend.go

+4
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,8 @@ func (n *NoChainSource) TestMempoolAccept([]*wire.MsgTx,
220220
return nil, nil
221221
}
222222

223+
func (n *NoChainSource) MapRPCErr(err error) error {
224+
return err
225+
}
226+
223227
var _ chain.Interface = (*NoChainSource)(nil)

config_builder.go

+15-13
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import (
1717

1818
"github.com/btcsuite/btcd/chaincfg"
1919
"github.com/btcsuite/btcd/chaincfg/chainhash"
20-
"github.com/btcsuite/btcd/rpcclient"
2120
"github.com/btcsuite/btcd/wire"
2221
"github.com/btcsuite/btclog"
22+
"github.com/btcsuite/btcwallet/chain"
2323
"github.com/btcsuite/btcwallet/waddrmgr"
2424
"github.com/btcsuite/btcwallet/wallet"
2525
"github.com/btcsuite/btcwallet/walletdb"
@@ -708,9 +708,9 @@ func (d *DefaultWalletImpl) BuildChainControl(
708708
// The broadcast is already always active for neutrino nodes, so we
709709
// don't want to create a rebroadcast loop.
710710
if partialChainControl.Cfg.NeutrinoCS == nil {
711+
cs := partialChainControl.ChainSource
711712
broadcastCfg := pushtx.Config{
712713
Broadcast: func(tx *wire.MsgTx) error {
713-
cs := partialChainControl.ChainSource
714714
_, err := cs.SendRawTransaction(
715715
tx, true,
716716
)
@@ -724,7 +724,10 @@ func (d *DefaultWalletImpl) BuildChainControl(
724724
// In case the backend is different from neutrino we
725725
// make sure that broadcast backend errors are mapped
726726
// to the neutrino broadcastErr.
727-
MapCustomBroadcastError: broadcastErrorMapper,
727+
MapCustomBroadcastError: func(err error) error {
728+
rpcErr := cs.MapRPCErr(err)
729+
return broadcastErrorMapper(rpcErr)
730+
},
728731
}
729732

730733
lnWalletConfig.Rebroadcaster = newWalletReBroadcaster(
@@ -1475,41 +1478,40 @@ func parseHeaderStateAssertion(state string) (*headerfs.FilterHeader, error) {
14751478
// the neutrino BroadcastError which allows the Rebroadcaster which currently
14761479
// resides in the neutrino package to use all of its functionalities.
14771480
func broadcastErrorMapper(err error) error {
1478-
returnErr := rpcclient.MapRPCErr(err)
1481+
var returnErr error
14791482

14801483
// We only filter for specific backend errors which are relevant for the
14811484
// Rebroadcaster.
14821485
switch {
14831486
// This makes sure the tx is removed from the rebroadcaster once it is
14841487
// confirmed.
1485-
case errors.Is(returnErr, rpcclient.ErrTxAlreadyKnown),
1486-
errors.Is(err, rpcclient.ErrTxAlreadyConfirmed):
1488+
case errors.Is(err, chain.ErrTxAlreadyKnown),
1489+
errors.Is(err, chain.ErrTxAlreadyConfirmed):
14871490

14881491
returnErr = &pushtx.BroadcastError{
14891492
Code: pushtx.Confirmed,
1490-
Reason: returnErr.Error(),
1493+
Reason: err.Error(),
14911494
}
14921495

14931496
// Transactions which are still in mempool but might fall out because
14941497
// of low fees are rebroadcasted despite of their backend error.
1495-
case errors.Is(returnErr, rpcclient.ErrTxAlreadyInMempool):
1498+
case errors.Is(err, chain.ErrTxAlreadyInMempool):
14961499
returnErr = &pushtx.BroadcastError{
14971500
Code: pushtx.Mempool,
1498-
Reason: returnErr.Error(),
1501+
Reason: err.Error(),
14991502
}
15001503

15011504
// Transactions which are not accepted into mempool because of low fees
15021505
// in the first place are rebroadcasted despite of their backend error.
15031506
// Mempool conditions change over time so it makes sense to retry
15041507
// publishing the transaction. Moreover we log the detailed error so the
15051508
// user can intervene and increase the size of his mempool.
1506-
case errors.Is(err, rpcclient.ErrMempoolMinFeeNotMet):
1507-
ltndLog.Warnf("Error while broadcasting transaction: %v",
1508-
returnErr)
1509+
case errors.Is(err, chain.ErrMempoolMinFeeNotMet):
1510+
ltndLog.Warnf("Error while broadcasting transaction: %v", err)
15091511

15101512
returnErr = &pushtx.BroadcastError{
15111513
Code: pushtx.Mempool,
1512-
Reason: returnErr.Error(),
1514+
Reason: err.Error(),
15131515
}
15141516
}
15151517

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Release Notes
2+
- [Bug Fixes](#bug-fixes)
3+
- [New Features](#new-features)
4+
- [Functional Enhancements](#functional-enhancements)
5+
- [RPC Additions](#rpc-additions)
6+
- [lncli Additions](#lncli-additions)
7+
- [Improvements](#improvements)
8+
- [Functional Updates](#functional-updates)
9+
- [RPC Updates](#rpc-updates)
10+
- [lncli Updates](#lncli-updates)
11+
- [Breaking Changes](#breaking-changes)
12+
- [Performance Improvements](#performance-improvements)
13+
- [Technical and Architectural Updates](#technical-and-architectural-updates)
14+
- [BOLT Spec Updates](#bolt-spec-updates)
15+
- [Testing](#testing)
16+
- [Database](#database)
17+
- [Code Health](#code-health)
18+
- [Tooling and Documentation](#tooling-and-documentation)
19+
20+
# Bug Fixes
21+
22+
* [Fixed a bug](https://github.com/lightningnetwork/lnd/pull/8887) in error
23+
matching from publishing already confirmed transactions that can cause lnd
24+
fail to startup if `btcd` with an older version (pre-`v0.24.2`) is used.
25+
26+
# New Features
27+
## Functional Enhancements
28+
## RPC Additions
29+
## lncli Additions
30+
31+
# Improvements
32+
## Functional Updates
33+
## RPC Updates
34+
## lncli Updates
35+
## Code Health
36+
## Breaking Changes
37+
## Performance Improvements
38+
39+
# Technical and Architectural Updates
40+
## BOLT Spec Updates
41+
## Testing
42+
## Database
43+
## Code Health
44+
## Tooling and Documentation
45+
46+
# Contributors (Alphabetical Order)
47+
48+
* Yong Yu

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/btcsuite/btcd/btcutil/psbt v1.1.8
1111
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
1212
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
13-
github.com/btcsuite/btcwallet v0.16.10-0.20240625163855-b42ed59f0528
13+
github.com/btcsuite/btcwallet v0.16.10-0.20240706055350-e391a1c31df2
1414
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.4
1515
github.com/btcsuite/btcwallet/wallet/txrules v1.2.1
1616
github.com/btcsuite/btcwallet/walletdb v1.4.2
@@ -54,7 +54,7 @@ require (
5454
golang.org/x/crypto v0.22.0
5555
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
5656
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028
57-
golang.org/x/net v0.22.0
57+
golang.org/x/net v0.24.0
5858
golang.org/x/sync v0.6.0
5959
golang.org/x/term v0.19.0
6060
golang.org/x/time v0.3.0

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtyd
9292
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
9393
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
9494
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
95-
github.com/btcsuite/btcwallet v0.16.10-0.20240625163855-b42ed59f0528 h1:DZRmr47CdPnNglwEVACPnJnGrfb/GBGyoGs5oqvLFg4=
96-
github.com/btcsuite/btcwallet v0.16.10-0.20240625163855-b42ed59f0528/go.mod h1:SLFUSQbP8ON/wxholYMfVLvGPJyk7boczOW/ob+nww4=
95+
github.com/btcsuite/btcwallet v0.16.10-0.20240706055350-e391a1c31df2 h1:mJquwdcEA4hZip4XKbRPAM9rOrus6wlNEcWzMz5CHsI=
96+
github.com/btcsuite/btcwallet v0.16.10-0.20240706055350-e391a1c31df2/go.mod h1:SLFUSQbP8ON/wxholYMfVLvGPJyk7boczOW/ob+nww4=
9797
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.4 h1:poyHFf7+5+RdxNp5r2T6IBRD7RyraUsYARYbp/7t4D8=
9898
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.4/go.mod h1:GETGDQuyq+VFfH1S/+/7slLM/9aNa4l7P4ejX6dJfb0=
9999
github.com/btcsuite/btcwallet/wallet/txrules v1.2.1 h1:UZo7YRzdHbwhK7Rhv3PO9bXgTxiOH45edK5qdsdiatk=
@@ -763,8 +763,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
763763
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
764764
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
765765
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
766-
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
767-
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
766+
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
767+
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
768768
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
769769
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
770770
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=

lnmock/chain.go

+6
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,9 @@ func (m *MockChain) TestMempoolAccept(txns []*wire.MsgTx, maxFeeRate float64) (
157157

158158
return args.Get(0).([]*btcjson.TestMempoolAcceptResult), args.Error(1)
159159
}
160+
161+
func (m *MockChain) MapRPCErr(err error) error {
162+
args := m.Called(err)
163+
164+
return args.Error(0)
165+
}

lnwallet/btcwallet/btcwallet.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,8 @@ func (b *BtcWallet) ListUnspentWitness(minConfs, maxConfs int32,
11911191
return witnessOutputs, nil
11921192
}
11931193

1194-
// mapRpcclientError maps an error from the rpcclient package to defined error
1195-
// in this package.
1194+
// mapRpcclientError maps an error from the `btcwallet/chain` package to
1195+
// defined error in this package.
11961196
//
11971197
// NOTE: we are mapping the errors returned from `sendrawtransaction` RPC or
11981198
// the reject reason from `testmempoolaccept` RPC.
@@ -1202,15 +1202,17 @@ func mapRpcclientError(err error) error {
12021202
switch {
12031203
// If the wallet reports a double spend, convert it to our internal
12041204
// ErrDoubleSpend and return.
1205-
case errors.Is(err, rpcclient.ErrMempoolConflict),
1206-
errors.Is(err, rpcclient.ErrMissingInputs):
1205+
case errors.Is(err, chain.ErrMempoolConflict),
1206+
errors.Is(err, chain.ErrMissingInputs),
1207+
errors.Is(err, chain.ErrTxAlreadyKnown),
1208+
errors.Is(err, chain.ErrTxAlreadyConfirmed):
12071209

12081210
return lnwallet.ErrDoubleSpend
12091211

12101212
// If the wallet reports that fee requirements for accepting the tx
12111213
// into mempool are not met, convert it to our internal ErrMempoolFee
12121214
// and return.
1213-
case errors.Is(err, rpcclient.ErrMempoolMinFeeNotMet):
1215+
case errors.Is(err, chain.ErrMempoolMinFeeNotMet):
12141216
return fmt.Errorf("%w: %v", lnwallet.ErrMempoolFee, err.Error())
12151217
}
12161218

@@ -1277,7 +1279,7 @@ func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx, label string) error {
12771279

12781280
// We need to use the string to create an error type and map it to a
12791281
// btcwallet error.
1280-
err = rpcclient.MapRPCErr(errors.New(result.RejectReason))
1282+
err = b.chain.MapRPCErr(errors.New(result.RejectReason))
12811283

12821284
//nolint:lll
12831285
// These two errors are ignored inside `PublishTransaction`:
@@ -1295,9 +1297,9 @@ func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx, label string) error {
12951297
// `PublishTransaction` again because we need to mark the label in the
12961298
// wallet. We can remove this exception once we have the above TODO
12971299
// fixed.
1298-
case errors.Is(err, rpcclient.ErrTxAlreadyInMempool),
1299-
errors.Is(err, rpcclient.ErrTxAlreadyKnown),
1300-
errors.Is(err, rpcclient.ErrTxAlreadyConfirmed):
1300+
case errors.Is(err, chain.ErrTxAlreadyInMempool),
1301+
errors.Is(err, chain.ErrTxAlreadyKnown),
1302+
errors.Is(err, chain.ErrTxAlreadyConfirmed):
13011303

13021304
err := b.wallet.PublishTransaction(tx, label)
13031305
return mapRpcclientError(err)
@@ -1922,7 +1924,7 @@ func (b *BtcWallet) CheckMempoolAcceptance(tx *wire.MsgTx) error {
19221924
// Mempool check failed, we now map the reject reason to a proper RPC
19231925
// error and return it.
19241926
if !result.Allowed {
1925-
err := rpcclient.MapRPCErr(errors.New(result.RejectReason))
1927+
err := b.chain.MapRPCErr(errors.New(result.RejectReason))
19261928

19271929
return fmt.Errorf("mempool rejection: %w", err)
19281930
}

lnwallet/btcwallet/btcwallet_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/btcsuite/btcwallet/wallet"
1111
"github.com/lightningnetwork/lnd/lnmock"
1212
"github.com/lightningnetwork/lnd/lnwallet"
13+
"github.com/stretchr/testify/mock"
1314
"github.com/stretchr/testify/require"
1415
)
1516

@@ -204,10 +205,12 @@ func TestCheckMempoolAcceptance(t *testing.T) {
204205
}}
205206
mockChain.On("TestMempoolAccept", []*wire.MsgTx{tx}, maxFeeRate).Return(
206207
results, nil).Once()
208+
mockChain.On("MapRPCErr", mock.Anything).Return(
209+
chain.ErrInsufficientFee).Once()
207210

208211
// Now call the method under test.
209212
err = wallet.CheckMempoolAcceptance(tx)
210-
rt.ErrorIs(err, rpcclient.ErrInsufficientFee)
213+
rt.ErrorIs(err, chain.ErrInsufficientFee)
211214

212215
// Assert that when the tx is accepted, no error is returned.
213216
//

lnwallet/test/test_interface.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ func testPublishTransaction(r *rpctest.Harness,
18081808
// If RBF is enabled, we expect it to be rejected
18091809
// because it doesn't pay enough fees.
18101810
if rbf {
1811-
expectedErr = rpcclient.ErrInsufficientFee
1811+
expectedErr = chain.ErrInsufficientFee
18121812
}
18131813

18141814
// Assert the expected error.
@@ -1891,7 +1891,7 @@ func testPublishTransaction(r *rpctest.Harness,
18911891
// Now broadcast the transaction, we should get an error that
18921892
// the weight is too large.
18931893
err := alice.PublishTransaction(testTx, labels.External)
1894-
require.ErrorIs(t, err, rpcclient.ErrOversizeTx)
1894+
require.ErrorIs(t, err, chain.ErrOversizeTx)
18951895
})
18961896
}
18971897

sweep/fee_bumper.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ func (t *TxPublisher) createRBFCompliantTx(req *BumpRequest,
427427
fallthrough
428428

429429
// We are not paying enough fees so we increase it.
430-
case errors.Is(err, rpcclient.ErrInsufficientFee):
430+
case errors.Is(err, chain.ErrInsufficientFee):
431431
increased := false
432432

433433
// Keep calling the fee function until the fee rate is
@@ -934,7 +934,7 @@ func (t *TxPublisher) createAndPublishTx(requestID uint64,
934934
// - if the deadline is close, we expect the fee function to give us a
935935
// higher fee rate. If the fee rate cannot satisfy the RBF rules, it
936936
// means the budget is not enough.
937-
if errors.Is(err, rpcclient.ErrInsufficientFee) ||
937+
if errors.Is(err, chain.ErrInsufficientFee) ||
938938
errors.Is(err, lnwallet.ErrMempoolFee) {
939939

940940
log.Debugf("Failed to bump tx %v: %v", oldTx.TxHash(), err)
@@ -989,7 +989,7 @@ func (t *TxPublisher) createAndPublishTx(requestID uint64,
989989
//
990990
// NOTE: we may get this error if we've bypassed the mempool check,
991991
// which means we are suing neutrino backend.
992-
if errors.Is(result.Err, rpcclient.ErrInsufficientFee) ||
992+
if errors.Is(result.Err, chain.ErrInsufficientFee) ||
993993
errors.Is(result.Err, lnwallet.ErrMempoolFee) {
994994

995995
log.Debugf("Failed to bump tx %v: %v", oldTx.TxHash(), err)

sweep/fee_bumper_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88

99
"github.com/btcsuite/btcd/btcutil"
1010
"github.com/btcsuite/btcd/chaincfg/chainhash"
11-
"github.com/btcsuite/btcd/rpcclient"
1211
"github.com/btcsuite/btcd/wire"
12+
"github.com/btcsuite/btcwallet/chain"
1313
"github.com/lightningnetwork/lnd/chainntnfs"
1414
"github.com/lightningnetwork/lnd/input"
1515
"github.com/lightningnetwork/lnd/keychain"
@@ -569,7 +569,7 @@ func TestCreateRBFCompliantTx(t *testing.T) {
569569
// for the first call.
570570
m.wallet.On("CheckMempoolAcceptance",
571571
mock.Anything).Return(
572-
rpcclient.ErrInsufficientFee).Once()
572+
chain.ErrInsufficientFee).Once()
573573

574574
// Mock the fee function to increase feerate.
575575
m.feeFunc.On("Increment").Return(
@@ -591,7 +591,7 @@ func TestCreateRBFCompliantTx(t *testing.T) {
591591
// for the first call.
592592
m.wallet.On("CheckMempoolAcceptance",
593593
mock.Anything).Return(
594-
rpcclient.ErrInsufficientFee).Once()
594+
chain.ErrInsufficientFee).Once()
595595

596596
// Mock the fee function to NOT increase
597597
// feerate on the first round.
@@ -1087,7 +1087,7 @@ func TestCreateAnPublishFail(t *testing.T) {
10871087
// Mock the testmempoolaccept to return a fee related error that should
10881088
// be ignored.
10891089
m.wallet.On("CheckMempoolAcceptance",
1090-
mock.Anything).Return(rpcclient.ErrInsufficientFee).Once()
1090+
mock.Anything).Return(chain.ErrInsufficientFee).Once()
10911091

10921092
// Call the createAndPublish method and expect a none option.
10931093
resultOpt = tp.createAndPublishTx(requestID, record)

0 commit comments

Comments
 (0)