Compare commits

...

3621 Commits

Author SHA1 Message Date
rockstardev
db58257e24
Update README.md
Some checks failed
CI / Sqlc check (push) Has been cancelled
CI / RPC and mobile compilation check (push) Has been cancelled
CI / check commits (push) Has been cancelled
CI / lint code (push) Has been cancelled
CI / cross compilation (push) Has been cancelled
CI / sample configuration check (push) Has been cancelled
CI / run ubuntu itests (backend=bitcoind dbbackend=postgres nativesql=true, bitcoind-postgres-nativesql) (push) Has been cancelled
CI / run unit tests (btcd unit-cover) (push) Has been cancelled
CI / run unit tests (btcd unit-race) (push) Has been cancelled
CI / run unit tests (unit tags="kvdb_etcd") (push) Has been cancelled
CI / run unit tests (unit tags="kvdb_postgres") (push) Has been cancelled
CI / run unit tests (unit tags="kvdb_sqlite") (push) Has been cancelled
CI / run unit tests (unit-module) (push) Has been cancelled
CI / run ubuntu itests (backend="bitcoind notxindex", bitcoind-notxindex) (push) Has been cancelled
CI / run ubuntu itests (backend="bitcoind rpcpolling" cover=1, bitcoind-rpcpolling) (push) Has been cancelled
CI / run ubuntu itests (backend=bitcoind cover=1, bitcoind) (push) Has been cancelled
CI / run ubuntu itests (backend=bitcoind dbbackend=etcd, bitcoind-etcd) (push) Has been cancelled
CI / run ubuntu itests (backend=bitcoind dbbackend=postgres, bitcoind-postgres) (push) Has been cancelled
CI / run ubuntu itests (backend=bitcoind dbbackend=sqlite nativesql=true, bitcoind-sqlite-nativesql) (push) Has been cancelled
CI / run ubuntu itests (backend=bitcoind dbbackend=sqlite, bitcoind-sqlite) (push) Has been cancelled
CI / run ubuntu itests (backend=btcd cover=1, btcd) (push) Has been cancelled
CI / run ubuntu itests (backend=neutrino cover=1, neutrino) (push) Has been cancelled
CI / run windows itest (push) Has been cancelled
CI / run macOS itest (push) Has been cancelled
CI / check pinned dependencies (github.com/golang/protobuf v1.5.3) (push) Has been cancelled
CI / check pinned dependencies (google.golang.org/grpc v1.59.0) (push) Has been cancelled
CI / check release notes updated (push) Has been cancelled
CI / finish (push) Has been cancelled
2025-07-22 23:12:37 +02:00
rockstardev
d97fa8b923
Merge pull request #8 from btcpayserver/pr/lnd-v0.18.4-beta
Building BTCPay LND 0.18.4
2025-01-08 16:57:18 -05:00
rockstardev
655d470280 Updating docker files to build 0.18.4 lnd 2025-01-07 18:53:54 -06:00
rockstardev
ce16689d73 Merge remote-tracking branch 'source/0-18-4-branch' 2025-01-07 18:46:41 -06:00
rockstardev
3da675df42
Update README.md
Adding example of local docker build process
2025-01-07 09:57:32 -06:00
rockstardev
e2a063f0e3
Update README.md
Link to Loop and fixing link to commit
2025-01-07 09:47:47 -06:00
Oliver Gugger
ddeb835168
Merge pull request #9367 from lightningnetwork/0-18-4-branch-rc3
release: create branch for v0.18.4-beta
2024-12-17 21:17:09 +01:00
Oliver Gugger
74d15d1fbc
build: bump version to v0.18.4-beta 2024-12-17 21:15:07 +01:00
Oliver Gugger
88cbec291c
Merge branch '0-18-4-branch-rc3-9357' into 0-18-4-branch-rc3 2024-12-16 12:51:50 +01:00
George Tsagkarelis
d30cba1089
contractcourt: include custom records on replayed htlc
When notifying the invoice registry for an exit hop htlc we also want to
include its custom records. The channelLink, the other caller of this
method, already populates this field. So we make sure the contest
resolver does so too.
2024-12-16 12:51:49 +01:00
Oliver Gugger
3c0810963f
Merge pull request #9335 from lightningnetwork/0-18-4-branch-rc2
release: create branch for v0.18.4-beta.rc2
2024-12-11 13:33:04 +01:00
Oliver Gugger
3447484a66
Merge branch '0-18-4-branch-rc2-9316' into 0-18-4-branch-rc2 2024-12-10 22:29:38 +01:00
ziggie
71eb1ae57d
docs: add release-notes for 18.4 2024-12-10 22:29:29 +01:00
ziggie
4c61411802
routing: bugfix for mc reporting of blinded paths
When reporting an error  or a success case of a payment to a
blinded paths, the amounts to forward for intermediate hops
are set to 0 so we need to use the receiver amount instead.
2024-12-10 22:29:29 +01:00
ziggie
a1e5dfc266
routing: add pathfinding test
We add a test where we add duplicate hops in a route and verify
that the pathfinding engine can handle this edge case.
2024-12-10 20:27:25 +01:00
ziggie
c579a6bf2f
routing: improve lasthoppaylaod size calculation
Fixes a bug and makes the function more robust. Before
we would always return the encrypted data size of last hop
of the last path. Now we return the greatest last hop payload
not always the one of the last path.
2024-12-10 20:27:25 +01:00
ziggie
eb93eb7ee9
routing: Use NUMS point for blinded paths
To be able to do MPP payment to multiple blinded routes we need
to add a constant dummy hop as a final hop to every blined path.
This is used when sending or querying a blinded path, to let the
pathfinder be able to send MPP payments over different blinded
routes. For this dummy final hop we use a NUMS key so that we
are sure no other node can use this blinded pubkey either in a
normal or blinded route.
Moreover this helps us handling the mission control data for
blinded paths correctly because we always consider the blinded
pubkey pairs which are registered with mission control when
a payment to a blinded path fails.
2024-12-10 20:27:24 +01:00
ziggie
0b90d3c3c2
input: export NUMS key parser. 2024-12-10 20:24:01 +01:00
Oliver Gugger
f312064bfb
build: bump version to v0.18.4-beta.rc2 2024-12-05 21:49:08 +01:00
Oliver Gugger
b63ac70113
Merge branch '0-18-4-branch-rc2-9333' into 0-18-4-branch-rc2 2024-12-05 21:47:45 +01:00
Oliver Gugger
72b4a1cb34
multi: thread through and use AuxTrafficShaper 2024-12-05 21:46:27 +01:00
Oliver Gugger
662049681d
htlcswitch: thread through packet's inbound wire records
For calculating the available auxiliary bandwidth of a channel, we need
access to the inbound custom wire records of the HTLC packet, which
might contain auxiliary information about the worth of the HTLC packet
apart from the BTC value being transported.
2024-12-05 21:44:58 +01:00
Oliver Gugger
699e2b74f6
multi: move routing.TlvTrafficShaper => htlcswitch.AuxTrafficShaper
With this commit we move the traffic shaper definition from the routing
package to the HTLC switch package as a preparation for being able to
use it there as well.
At the same time we rename it to AuxTrafficShaper to be more in line
with the other auxiliary components.
2024-12-05 21:44:56 +01:00
Oliver Gugger
f5ad1ee438
Merge branch '0-18-4-branch-rc2-9324' into 0-18-4-branch-rc2 2024-12-05 21:41:27 +01:00
ziggie
ae227ce2c6
docs: add release-notes 2024-12-05 21:41:13 +01:00
ziggie
7e228f22a8
contractcourt: refactor start up of arbitrators
We decouple the state machine of the channel arbitrator from
the start-up process so that we can startup the whole daemon
reliably.
2024-12-05 21:40:31 +01:00
Oliver Gugger
c1129bb086
Merge pull request #9183 from lightningnetwork/0-18-4-branch-rc1
release: create branch for v0.18.4-beta.rc1
2024-11-21 20:19:40 +01:00
Oliver Gugger
9246d5c51c
Merge branch '0-18-4-branch-rc1-9288' into 0-18-4-branch-rc1 2024-11-20 15:31:13 +01:00
Oliver Gugger
117a145b97
docs: add release notes 2024-11-20 15:31:12 +01:00
Oliver Gugger
e074a8fab3
chanacceptor: add custom channel commitment type 2024-11-20 15:31:12 +01:00
Oliver Gugger
f9d876e8a3
Merge branch '0-18-4-branch-rc1-9253' into 0-18-4-branch-rc1 2024-11-20 10:44:12 +01:00
ziggie
a4211251bd
docs: add release notes 2024-11-20 10:43:59 +01:00
ziggie
d695383386
rpcserver: add robustness check 2024-11-20 10:42:54 +01:00
ziggie
79d0655a96
multi: introduce an option for resolutions
We don't always need the resolutions in the local force close
summary so we make it an option.
2024-11-20 10:42:54 +01:00
Oliver Gugger
78c8990772
Merge branch '0-18-4-branch-rc1-9272' into 0-18-4-branch-rc1 2024-11-19 12:44:51 +01:00
Olaoluwa Osuntokun
86de1ebdc2
sweep: update storeRecord to include utxo index
In this commit, we complete a recently added feature by ensuring that
even if we go through the RBF loop to create a txn, that we still
populate the `outpointToIndex` map. Unit tests have been updated to
ensure this is always set as expected.
2024-11-19 12:44:51 +01:00
Oliver Gugger
4c9d25cbe7
Merge branch '0-18-4-branch-rc1-9194' into 0-18-4-branch-rc1 2024-11-15 13:09:56 +01:00
Oliver Gugger
04b053e405
docs: move 0.18.4 items, add full list of custom chan PRs 2024-11-15 13:09:35 +01:00
Olaoluwa Osuntokun
e1a25f6c30
sweep: update BudgetInputSet.Budget() to factor in extra budget
In this commit, we update the `Budget()` call to factor in the
`extraBudget` value. Otherwise, when we go to intialize the fee
function, we won't factor in the extra budget, and will determine that
we can't broadcast/bump.
2024-11-15 13:09:10 +01:00
Olaoluwa Osuntokun
6db7d42654
lnwallet: add whoseCommit to FetchLeavesFromCommit
This is useful for additional context to know which commit the
AuxLeafStore is fetching the leaves for.
2024-11-15 13:09:10 +01:00
Olaoluwa Osuntokun
b8035d9db7
sweep: expand NotifyBroadcast to include an outpoint index
In this commit, we expand the `NotifyBroadcast` to include an outpoint
index. This is useful as it indicates the index of a given required tx
out input.
2024-11-15 13:09:09 +01:00
Olaoluwa Osuntokun
83f1c883ba
contractcourt: pass in new aux resolution blob to sweeper in resolvers
With this commit, we update all the resolvers to pass in the new htlc
resolution blobs. Along the way, we remove the old blocking guard on
this resolution logic for HTLCs with blobs.
2024-11-15 13:09:09 +01:00
Olaoluwa Osuntokun
f1a1c033d1
contractcourt: update encode/decode for taproot aux data
When we read/write the aux data, we need to make sure we always set the
new fields for aux HTLCs.
2024-11-15 13:09:09 +01:00
Olaoluwa Osuntokun
6914e6a4a5
contractcourt: add HtlcBlobs to taprootBriefcase
In this commit, we add the set of HtlcBlobs to the taprootBriefcase
struct. This new field will store all the resolution blobs for a given
HTLC. We also add some new property based tests along the way for
adequate test coverage.
2024-11-15 13:09:09 +01:00
Olaoluwa Osuntokun
413fdaf3fb
input: add new Preimage method to input.Input
In this commit, we add a new method to obtain an option of a preimage to
the input.Input struct. This is useful for callers that have an Input,
and want to optionally obtain the preimage.
2024-11-15 13:09:09 +01:00
Olaoluwa Osuntokun
e3eef0adff
lnwallet: populate resolution blob for incoming+outgoing HTLC resolutions
In this commit, we populate the resolution blobs for the incoming and
outgoing HTLCs. We take care to populate the AuxSigDesc with the correct
information, as we need to pass along the second-level aux signature and
also sign desc along with it.
2024-11-15 13:09:09 +01:00
Olaoluwa Osuntokun
84aacc6c39
channel: add ResolutionBlob to Incoming+Outgoing HtlcResolution
Similar to the other blobs we have for the commitment output force close
resolution, these blobs will be used to ensure that we have everything
needed to sweep aux HTLCs.
2024-11-15 13:09:08 +01:00
Olaoluwa Osuntokun
57617dc4f7
channel: always specify ChanType in ResolutionReq 2024-11-15 13:09:08 +01:00
Olaoluwa Osuntokun
a5beb340e4
lnwallet: expand attributes in ResolutionReq
In this commit, we add some additional attributes to the ResolutionReq
struct. These will be used to make sure that we can properly handle all
the HTLC variants, on chain.

The `AuxSigDesc` will be used to communicate if an HTLC needs to go to
the second level or not. It contains the second-level sig information
needed to finalize a broadcast to the second level.
2024-11-15 13:09:07 +01:00
Oliver Gugger
31ace742a5
Merge branch '0-18-4-branch-rc1-9084' into 0-18-4-branch-rc1 2024-11-13 12:52:32 +01:00
Matt Morehouse
2c25f38a5a
discovery: remove check for incorrect number of timestamps
The check is no longer required, as it is now done during decoding.
2024-11-13 12:52:32 +01:00
Matt Morehouse
c8033e1725
lnwire: fail decoding on incorrect number of timestamps
Currently if an incorrect number of timestamps is given, we fail later
on in the GossipSyncer. It makes more sense to fail right away, since we
already do that for incorrect SCID formats (e.g., unsorted or duplicate
SCIDs). There is already a matching check in Encode for incorrect number
of timestamps, so adding this check to Decode makes things symmetric.
2024-11-13 12:52:32 +01:00
Oliver Gugger
9bf48a7e9a
Merge branch '0-18-4-branch-rc1-9082' into 0-18-4-branch-rc1 2024-11-13 12:50:57 +01:00
Matt Morehouse
a4414fbbb9
lnwire: manually compare Timestamps in fuzz test
We can't use require.Equal because it considers nil slices and empty
slices to be not equal.
2024-11-13 12:50:56 +01:00
Oliver Gugger
af08c42d58
Merge branch '0-18-4-branch-rc1-9062' into 0-18-4-branch-rc1 2024-11-08 08:52:31 +01:00
Olaoluwa Osuntokun
b2b5ec052b
contractcourt: use the sweeper for HTLC offered remote timeout resolution
In this commit, we bring the timeout resolver more in line with the
success resolver by using the sweeper to handle the HTLC offered remote
timeout outputs. These are outputs that we can sweep directly from the
remote party's commitment transaction when they broadcast their version
of the commitment transaction.

With this change, we slim down the scope slightly by only doing this for
anchor channels. Non-anchor channels will continue to use the
utxonursery for this output type for now.
2024-11-08 08:52:31 +01:00
Olaoluwa Osuntokun
941590d384
contractcourt: use t.Run in TestHtlcTimeoutResolver
Along the way we refactor the test to eliminate some unnecessary line
length.
2024-11-08 08:52:30 +01:00
Oliver Gugger
906fa0b7b8
Merge branch '0-18-4-branch-rc1-9223' into 0-18-4-branch-rc1 2024-10-30 14:16:37 +01:00
Boris Nagaev
593afee12d
itest: coop_close_with_external_delivery with p2tr
Customize the itest with the type of external delivery address. Test with P2TR
address type in addition to P2WKPH.
2024-10-30 14:16:37 +01:00
Boris Nagaev
552d182594
lnwallet: fix closechannel for P2TR external addr
If the delivery address is P2TR, function InternalKeyForAddr checks its
existance in the wallet to return internal key for it in case it is a custom
taproot channel. It used to return the error returned by wallet.AddressInfo.
The error is now ignored if it is ErrAddressNotFound error. This fixes
"lncli closechannel --delivery_addr <external p2tr address" case.
2024-10-30 14:16:36 +01:00
Oliver Gugger
615f3d633e
Merge branch '0-18-4-branch-rc1-9199' into 0-18-4-branch-rc1 2024-10-25 11:00:09 +02:00
George Tsagkarelis
6f401b4265
invoices: cancel htlc on HtlcModify signal 2024-10-25 11:00:08 +02:00
George Tsagkarelis
2999b37607
lnrpc+invoices: add cancelSet to HtlcModifier interface 2024-10-25 11:00:08 +02:00
Oliver Gugger
b69fc15cc1
Merge branch '0-18-4-branch-rc1-9197' into 0-18-4-branch-rc1 2024-10-22 09:06:30 +02:00
Jonathan Harvey-Buschel
d650829f9b
gitignore: ignore vscode workspace files 2024-10-22 09:06:17 +02:00
Jonathan Harvey-Buschel
455cdffede
lnwallet: test link quit signal handling 2024-10-22 09:06:17 +02:00
Jonathan Harvey-Buschel
8703153c44
multi: link quit can interrupt commitment signing
In this commit, we make sig job handling when singing a next commitment
non-blocking by allowing the shutdown of a channel link to prevent
further waiting on sig jobs by the channel state machine. This addresses
possible cases where the aux signer may be shut down via a separate quit
signal, so the state machine could block indefinitely on receiving an
update on a sig job.
2024-10-22 09:06:17 +02:00
Oliver Gugger
6feb74137d
mod: bump fn to v1.2.3 2024-10-22 09:06:15 +02:00
Jonathan Harvey-Buschel
753301cf38
htlcswitch: pass quit chans as unidirectional
This is a requirement for replacing the quit channel with a Context.
The Done() channel of a Context is always recv-only, so all users of
that channel must not expect a bidirectional channel.
2024-10-22 09:05:42 +02:00
Jonathan Harvey-Buschel
afb7532f17
lnwallet: sort sig jobs before submission 2024-10-22 09:05:42 +02:00
Jonathan Harvey-Buschel
ed5d748a9f
lnwallet: test aux signer shutdown handling 2024-10-22 09:05:42 +02:00
Jonathan Harvey-Buschel
b6363a8da4
lnwallet: refactor test code for HTLC add and recv 2024-10-22 09:05:42 +02:00
Jonathan Harvey-Buschel
afdd53194b
multi: allow mock aux signer to customize sig jobs 2024-10-22 09:05:41 +02:00
Oliver Gugger
6f0d7f9a87
Merge branch '0-18-4-branch-rc1-9195' into 0-18-4-branch-rc1 2024-10-21 13:26:23 +02:00
yyforyongyu
f09b638343
lntest: add method AssertTxnsNotInMempool
So we only need to do one `GetRawMempool` lookup when checking the
exclusion of multiple txns.
2024-10-21 13:26:09 +02:00
yyforyongyu
56e05a3e1e
lntest: remove unused return value 2024-10-21 13:26:09 +02:00
yyforyongyu
1aae94f17d
itest+lntest: stop using pointer to chainhash.Hash
This commit fixes the methods used in `lntest` so they stop using
pointers to chainhash.
2024-10-21 13:26:09 +02:00
Oliver Gugger
3b8b738be9
Merge branch '0-18-4-branch-rc1-9059' into 0-18-4-branch-rc1 2024-10-16 16:00:25 +02:00
Oliver Gugger
55e6460707
docs: add release notes 2024-10-16 15:59:54 +02:00
Oliver Gugger
34ea769501
mod: fix unit tests by updating error matching in btcwallet 2024-10-16 15:59:52 +02:00
Oliver Gugger
57e7b41510
lnwallet: turn off RBF detection in test 2024-10-16 15:58:00 +02:00
Oliver Gugger
6aec5b00ad
lntest: avoid port collision on Tor listen port
bitcoind now seems to listen on the -bind port at all times. So we need
to make sure multiple instances don't collide by using a unique port.
2024-10-16 15:58:00 +02:00
Oliver Gugger
5966150db5
lntest: move debug flag, disable spammy libevent 2024-10-16 15:57:59 +02:00
Oliver Gugger
fe8b89dc2c
github+scripts: bump itests to bitcoind v28, allow testing with RCs 2024-10-16 15:57:59 +02:00
rockstardev
9f0402c685 Updating README 2024-10-15 19:01:28 -05:00
rockstardev
4f332436cc Merge branch 'lnd/v0.18.3-beta'
# Conflicts:
#	docker-initunlocklnd.sh
2024-10-15 18:58:46 -05:00
rockstardev
e888c2a317 Adding BtcPayServer related files and resources 2024-10-15 18:38:30 -05:00
rockstardev
eb64ae0260 Update README 2024-10-15 18:11:52 -05:00
rockstardev
48120906c9 Merge branch 'lnd/v0.18.3-beta'
# Conflicts:
#	.circleci/config.yml
#	Makefile
#	README.md
#	build/version.go
#	go.mod
#	go.sum
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
2024-10-15 18:09:25 -05:00
rockstardev
ae4bb33c6a Adding BtcPayServer related files and resources 2024-10-15 17:56:11 -05:00
rockstardev
8742a9a506
Merge pull request #7 from ziggie1984/fix-lnd-wallet-pw
Fix Password for lnd instance.
2024-10-15 17:36:29 -05:00
Oliver Gugger
9ca21ecf2d
Merge branch '0-18-4-branch-rc1-9187' into 0-18-4-branch-rc1 2024-10-15 17:33:27 +02:00
Oliver Gugger
58bf721f2e
cmd/commands: don't error out on replacement failure 2024-10-15 17:33:26 +02:00
Oliver Gugger
560b7286b5
rpcserver: don't write any custom channel data if empty 2024-10-15 17:33:26 +02:00
ziggie
33508380e7
Fix Password for lnd instance 2024-10-13 15:14:25 +02:00
Oliver Gugger
ca3bde901e
build: bump version to v0.18.4-beta.rc1 2024-10-11 14:46:28 +02:00
Oliver Gugger
89c84f1da6
lnwallet: fix import issue 2024-10-11 14:46:09 +02:00
Oliver Gugger
a3db2145dc
Merge branch '0-18-4-branch-rc1-9154' into 0-18-4-branch-rc1 2024-10-11 14:23:41 +02:00
ziggie
a5eca91602
multi: bump btcd version.
The new SignCompact return values had to be adopted across the
code base.
2024-10-11 14:23:41 +02:00
Oliver Gugger
5c7be35ca5
Merge branch '0-18-4-branch-rc1-8960' into 0-18-4-branch-rc1 2024-10-11 14:23:05 +02:00
Olaoluwa Osuntokun
16edbf3026
sweep: ensure we factor in extra change addrs in MaxFeeRateAllowed 2024-10-11 14:22:50 +02:00
George Tsagkarelis
00ed751ee5
docs: update release notes 2024-10-11 14:22:47 +02:00
Olaoluwa Osuntokun
9f048b0ea3
lnd: signal taproot overlay chans based on config
We also add a sanity check to make sure they can't be signaled without
the aux interfaces.
2024-10-11 14:22:13 +02:00
Olaoluwa Osuntokun
6619646088
lncfg: add new config option for taproot overlay chans 2024-10-11 14:22:13 +02:00
Olaoluwa Osuntokun
3031f21182
rpc+funding: add taproot overlay as RPC chan type 2024-10-11 14:22:12 +02:00
Olaoluwa Osuntokun
4eaba9b3db
lnrpc: add SIMPLE_TAPROOT_OVERLAY feature bit 2024-10-11 14:22:12 +02:00
Olaoluwa Osuntokun
72d437d5c8
funding: add chan type awareness for new taproot chans overlay 2024-10-11 14:22:12 +02:00
Olaoluwa Osuntokun
4efa39ddb1
lnwallet: add awareness of taproot overlay chan type to reservations 2024-10-11 14:22:12 +02:00
Olaoluwa Osuntokun
745f3a6181
feature: add awareness of new taproot chans overlay feature bit
This bit will be false by default in current production deployments.
2024-10-11 14:22:12 +02:00
Olaoluwa Osuntokun
1a3c94a501
lnwire: add new taproot chans overlay feature bit 2024-10-11 14:22:12 +02:00
Olaoluwa Osuntokun
3d7d9d2612
contractcourt: integration aux sweeper to breach arb
Similar to the sweeper, when we're about to make a new breach
transaction, we ask the sweeper for a new change address, if it has one.
Then when we go to publish, we notify broadcast.
2024-10-11 14:22:12 +02:00
Olaoluwa Osuntokun
4c16e55aca
contractcourt: update makeBreachedOutput to accept resolution blob 2024-10-11 14:22:11 +02:00
Olaoluwa Osuntokun
ded6959fd5
contractcourt: update GenSweepScript to return internal key
For the upcoming aux sweeper integration, the internal key is needed for
the call backs.
2024-10-11 14:22:11 +02:00
Olaoluwa Osuntokun
d0501ab840
multi: hook up new aux interfaces 2024-10-11 14:22:11 +02:00
Olaoluwa Osuntokun
678028cee9
contractcourt: pause resolution for HTLCs w/ custom records
This is a hold over until the aux resolution is finalized for HTLC
outputs.
2024-10-11 14:22:11 +02:00
Olaoluwa Osuntokun
a21fb1b69c
sweep: update sweeper to use AuxSweeper to add extra change addr
In this commit, we start to use the AuxSweeper (if present) to obtain a
new extra change addr we should add to the sweeping transaction. With
this, we'll take the set of inputs and our change addr, and then maybe
gain a new change addr to add to the sweep transaction.

The extra change addr will be treated as an extra required tx out,
shared across all the relevant inputs. This'll also be used in
NeedWalletInput to make sure that we add an extra input if needed to be
able to pay for the change addr.
2024-10-11 14:22:11 +02:00
Olaoluwa Osuntokun
23e99ddd4d
sweep: add new AuxSweeper interface
In this commit, we add a new AuxSweeper interface. This'll take a set of
inputs, and a change addr for the sweep transaction, then optionally
return a new sweep output to be added to the sweep transaction.

We also add a new NotifyBroadcast method.  This'll be used to notify
that we're _about_ to broadcast a sweeping transaction. The set of
inputs is passed in, which allows the caller to prepare for the ultimate
broadcast of the sweeping transaction.

We also add ExtraTxOut to BumpRequest pass fees to NotifyBroadcast. This
allows the callee to know the total fee of the sweeping transaction.
2024-10-11 14:22:11 +02:00
Olaoluwa Osuntokun
3726cfa319
server+sweep: convert GenSweepScript to use new addr type
We convert it to use lnwallet.AddrWithKey, as in the future, knowing the
internal key for an address will be useful.
2024-10-11 14:22:11 +02:00
Olaoluwa Osuntokun
fef368bb38
contractcourt: set resolution blob in commitSweepResolver 2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
080771db62
input: add ResolutionBlob method to inputKit
We also update breachedOutput w/ the new API.
2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
fc02cd7b0c
input: refactor all inputs to use MakeBaseInput, add opts
In this commit, we refactor all the other constructors for the input to
use MakeBaseInput. We also add a new set of functional options as well.
This'll be useful later on to ensure that new options are properly
applied to all the input types.
2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
07ee114116
lnwallet+peer: move internalKeyForAddr to lnwallet package
This way we can re-use it. We also make it slightly more generalized.
2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
74d27f2c7c
contractcourt: add CommitBlob to taprootBriefcase
This'll be used to store the extra resolution information for the
commitment outputs.
2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
f4710ca639
lnwallet: add new aux resolver interface
This will be used by external callers to modify the way we resolve
contracts on chain. For a given contract, we'll store an extra "blob",
that will later be presented during the sweeping phase.
2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
900a0a114a
contractcourt: convert taprootBriefcase to use new tlv record type
This commit doesn't yet go all the way to modify all the other records
quite yet.
2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
035126b280
lnwire: modify TestLightningWireProtocol to use sub-tests
This way, it's possible to run induvidual tests to target failures.
2024-10-11 14:22:09 +02:00
George Tsagkarelis
9d50e273a3
routing: add htlcAmt to PaymentBandwidth method of TlvTrafficShaper
This commit was added to the 0-19-staging branch recently and therefore
didn't make it into a previous part yet. So it's unrelated to the
changes in this part but is required for the whole custom channel saga.
2024-10-11 14:22:09 +02:00
Oliver Gugger
053b6bcfad
Merge branch '0-18-4-branch-rc1-9134' into 0-18-4-branch-rc1 2024-10-11 14:20:33 +02:00
Elle Mouton
663f4c251e
feature: remove b11 feature bit from default invoice set 2024-10-11 14:20:19 +02:00
Elle Mouton
6df4f27929
server: stop interceptable switch in Stop 2024-10-11 14:20:19 +02:00
Elle Mouton
575d699917
invoices: init quit channel of modifier
Also add atomic start and stop vars to prevent close of a closed
channel.
2024-10-11 14:20:19 +02:00
Elle Mouton
d2c745e610
multi: update PaymentAddr to use fn.Option
Since it is allowed to not be set and so can lead to nil deref panics if
it is a pointer.
2024-10-11 14:20:17 +02:00
Oliver Gugger
7857f38f45
Merge branch '0-18-4-branch-rc1-9095' into 0-18-4-branch-rc1 2024-10-11 14:17:28 +02:00
Oliver Gugger
9ce799578c
multi: add co-op close custom data to close update
With this commit we populate additional information about the close
outputs (including potential custom channel data) in the close update
RPC message.
This will allow custom channels to find out how the additional close
outputs look like on chain and what data they might commit to.

We also hook up the aux custom data formatter, so it can format the
custom channel data to JSON.
2024-10-11 14:17:28 +02:00
Olaoluwa Osuntokun
39e4e8d8a4
peer: decorate delivery addr w/ internal key
In this commit, we move to add the internal key to the delivery addr. This way, we give the aux chan closer the extra information it may need to properly augment the normal co-op close process.
2024-10-11 14:17:28 +02:00
Olaoluwa Osuntokun
fbbcecc635
server+peer: init peer struct w/ AuxChanCloser if present 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
8b97d4f833
lnwallet: modify CoopCloseBalance to not depend on chan commit 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
e536cfad0f
lnwallet/chancloser: add aux chan closer, use in coop flow 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
e2dae56698
lnwallet/chancloser: add new AuxChanCloser interface 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
2d8c4fda2f
lnwallet: add ability to do custom sort for coop close txn 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
0cb211e14c
lnwallet: add ability to add extra co-op close outputs 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
7e4f6f5b4a
lnwallet: add FundingBlob method to LightningChannel 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
6feb189a21
lnwire: add CustomRecords to shutdown message 2024-10-11 14:17:26 +02:00
ffranr
35ce62c021
itest: add basic invoice HTLC modifier integration test
This commit introduces a basic integration test for the invoice
HTLC modifier. The test covers scenarios where an invoice is settled with a
payment that is less than the invoice amount, facilitated by the invoice
HTLC modifier.
2024-10-11 14:17:26 +02:00
Oliver Gugger
0cb599dbf6
lnrpc+rpcserver: encode custom records as custom channel data
With this commit we encode the custom records as a TLV stream into the
custom channel data field of the invoice HTLC.
This allows the custom data parser to parse those records and replace it
with human-readable JSON on the RPC interface.
2024-10-11 14:17:26 +02:00
ffranr
c1aa44c476
multi: pass UpdateAddHtlc message custom records to invoice modifier 2024-10-11 14:17:26 +02:00
Oliver Gugger
109e27cfb2
lnwire: add MergedCopy method to CustomRecords 2024-10-11 14:17:26 +02:00
ffranr
ce7c053de0
lntest: add HtlcModifier support to node RPC harness
This commit enhances the itest LND node harness to include support for
the new `HtlcModifier` RPC endpoint.
At the same time we move another method to the correct file.
2024-10-11 14:17:26 +02:00
ffranr
e417250f6d
invoicesrpc: add HtlcModifier RPC endpoint and modifier RPC server
This commit introduces a singleton invoice HTLC modifier RPC server and
an endpoint to activate it. The server interfaces with the internal
invoice HTLC modifier interpreter, handling the marshalling between RPC
types and internal formats.
2024-10-11 14:17:26 +02:00
ffranr
7285dfa66a
invoicesrpc: add HTLC modifier to invoices RPC server
This commit integrates the HTLC modifier service into the
invoices RPC server.
2024-10-11 14:17:25 +02:00
ffranr
f903e16c47
lnd: initialize invoice settlement interceptor at server startup
This commit initiates the invoice settlement interceptor during the
main server startup, assigning it a handle within the server.
2024-10-11 14:17:25 +02:00
ffranr
4d9422a064
invoices: integrate settlement interceptor with invoice registry
This commit updates the invoice registry to utilize the settlement
interceptor during the invoice settlement routine. It allows the
interceptor to capture the invoice, providing interception clients an
opportunity to determine the settlement outcome.
2024-10-11 14:17:25 +02:00
ffranr
acf0d0ebe8
invoices: add invoice htlc interceptor service
This commit introduces a new invoice htlc interceptor service
that intercepts invoice HTLCs during their settlement phase. It forwards
HTLCs to a subscribed client to determine their settlement outcomes.

This commit also introduces an interface to facilitate integrating the
interceptor with other packages.
2024-10-11 14:17:25 +02:00
Oliver Gugger
153a133ea6
Merge branch '0-18-4-branch-rc1-9072' into 0-18-4-branch-rc1 2024-10-11 14:16:36 +02:00
Oliver Gugger
c3627545be
htlcswitch: override amount check on custom records 2024-10-11 14:16:36 +02:00
Oliver Gugger
b35dae72a5
channeldb: add NextHeight, fix formatting 2024-10-11 14:16:36 +02:00
Oliver Gugger
f9debb148b
lnd: add aux data parser
This commit adds an optional data parser that can inspect and in-place
format custom data of certain RPC messages.
We don't add an implementation of the interface itself, as that will be
provided by external components when packaging up lnd as a bundle with
other software.
2024-10-11 14:16:36 +02:00
Oliver Gugger
23ef68a2f7
lnrpc+rpcserver: add and populate custom channel data 2024-10-11 14:16:36 +02:00
Jonathan Harvey-Buschel
9c80088abd
lnwallet: sort sig jobs before submission
To make sure we attempt to read the results of the sig batches in the
same order they're processed, we sort them _before_ submitting them to
the batch processor.
Otherwise it might happen that we try to read on a result channel that
was never sent on because we aborted due to an error.
We also use slices.SortFunc now which doesn't use reflection and might
be slightly faster.
2024-10-11 14:16:35 +02:00
Olaoluwa Osuntokun
69155bc60b
multi: obtain+verify aux sigs for all second level HTLCs
In this commit, we start to use the new AuxSigner to obtain+verify aux sigs for all second level HTLCs. This is similar to the existing SigPool, but we'll only attempt to do this if the AuxSigner is present (won't be for most channels).
2024-10-11 14:16:35 +02:00
Oliver Gugger
4db0d76ca4
lnwire: add custom records field to type CommitSig 2024-10-11 14:16:35 +02:00
Olaoluwa Osuntokun
b83783cc3d
lnwallet: add WithAuxSigner option to channel 2024-10-11 14:16:35 +02:00
Oliver Gugger
6d3f8af007
lnwallet: clarify usage of cancel and response channels 2024-10-11 14:16:35 +02:00
Oliver Gugger
266aba8a6c
lnwallet: allow read-only access to HtlcView's HTLCs
Due to a recent refactor, the HTLCs are no longer an exported type.
Custom channels need access to those updates, so we provide them in a
read-only manner.
2024-10-11 14:16:35 +02:00
Olaoluwa Osuntokun
6dda51d026
lnwallet: add new AuxSigner interface to mirror SigPool
In this commit, we add a new aux signer interface that's meant to mirror the SigPool. If present, this'll be used to (maybe) obtain signatures for second level HTLCs for certain classes of custom channels.
2024-10-11 14:16:35 +02:00
Oliver Gugger
dbb87b4ef9
funding: inform aux controller about channel ready/finalize 2024-10-11 14:16:34 +02:00
Oliver Gugger
18dca6f4c8
multi: add tapscript root to gossip message 2024-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
1402f087ab
funding+lnwallet: finish hook up new aux funding flow
For the initiator, once we get the signal that the PSBT has been
finalized, we'll call into the aux funder to get the funding desc. For
the responder, once we receive the funding_created message, we'll do the
same.

We now also have local+remote aux leaves for the commitment transaction.

Some old TODO comments that in retrospect aren't required anymore are
removed as well.
2024-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
f2dff16c37
funding+lnwallet: only blind tapscript root early in funding flow
In this commit, we modify the aux funding work flow slightly. We won't
be able to generate the full AuxFundingDesc until both sides has
sent+received funding params. So we'll now only attempt to bind the
tapscript root as soon as we send+recv the open_channel message.

We'll now also make sure that we pass the tapscript root all the way
down into the musig2 session creation.
2024-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
39b1080166
lnwallet: for PsbtIntent return the internal key in the POutput
We also add a new assertion to the itests to ensure the field is being properly set.
2024-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
0a7139c9ca
lnwallet: add TaprootInternalKey method to ShimIntent
If this is a taproot channel, then we'll return the internal key which'll be useful to callers.
2024-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
723621bd2b
config+serer: add AuxFundingController as top level cfg option 2024-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
7f3aff9e10
funding: create new AuxFundingController interface
In this commit, we make a new `AuxFundingController` interface capable of processing messages off the wire. In addition, we can use it to abstract away details w.r.t how we obtain a `AuxFundingDesc` for a given channel.

We'll now use this whenever we get a channel funding request, to make sure we pass along the custom state that a channel may require.
2024-10-11 14:16:33 +02:00
Olaoluwa Osuntokun
5f5bbf9ae2
lnwallet: use AuxFundingDesc to populate all custom chan info
With this commit, we'll now populate all the custom channel information within the OpenChannel and ChannelCommitment structs.
2024-10-11 14:16:33 +02:00
Olaoluwa Osuntokun
f73f5f5582
lnwallet: add new AuxFundingDesc struct
This struct will house all the information we'll need to do a class of custom channels that relies primarily on adding additional items to the tapscript root of the HTLC/commitment/funding outputs.
2024-10-11 14:16:33 +02:00
Oliver Gugger
a7534597dd
Merge branch '0-18-4-branch-rc1-8981' into 0-18-4-branch-rc1 2024-10-11 14:15:30 +02:00
Keagan McClelland
56866448dc
lnwallet: remove unnecessary chanID argument form unsignedLocalUpdates 2024-10-11 14:15:16 +02:00
Keagan McClelland
f8979c0614
htlcswitch+lnwallet: quarantine paymentDescriptor to lnwallet
The objective of this commit is to make paymentDescriptor a private
data structure so we can quarantine it to the lnwallet package.
To accomplish this we had to prevent it from leaking out via the
arguments or return values of the public functions in lnwallet.
This naturally had consequences for the htlcswitch package as we
choose other mechanisms for tracking the data that paymentDescriptor
was responsible for.

Astoundingly, this was highly successful and allowed us to remove
a ton of redundant code. The diff for this commit represents a
substantial reduction in total lines of code as well as extraneous
arguments and return values from key functions.

This also sets the stage for future commits where we actually will
be attempting to rid lnwallet of paymentDescriptor completely.
2024-10-11 14:15:14 +02:00
Keagan McClelland
7e5f6b5802
lnwallet: remove unused function PayDescsFromRemoteLogUpdates
This function is no longer used as of the last commit and it is the
last remaining leak of the PaymentDescriptor type through the public
API.
2024-10-11 14:14:41 +02:00
Keagan McClelland
addf9e8dbe
htlcswitch: remove PaymentDescriptor conversion from reforwardSettleFails
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-10-11 14:14:41 +02:00
Keagan McClelland
870800b81a
htlcswitch+lnwallet: remove PaymentDescriptor from ReceiveRevocation returns
This is part of a systematic removal of PaymentDescriptor from the public
API of the lnwallet package. This marks the last change needed before we
make the PaymentDescriptor structure private.
2024-10-11 14:14:41 +02:00
Keagan McClelland
a3e127d1d6
htlcswitch: remove PaymentDescriptor from processRemoteSettleFails call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-10-11 14:14:41 +02:00
Keagan McClelland
875d2e4664
htlcswitch: remove PaymentDescriptor from processRemoteAdds call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-10-11 14:14:41 +02:00
Keagan McClelland
dd9568b648
htlcswitch: remove PaymentDescriptor from hodlHtlc
This is part of a systematic removal of PaymentDescriptor from the
mechanics of the htlcswitch package.
2024-10-11 14:14:40 +02:00
Keagan McClelland
e7d545fb0a
htlcswitch: remove PaymentDescriptor from the processExitHop's call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-10-11 14:14:40 +02:00
Keagan McClelland
160747cf5e
htlcswitch: remove PaymentDescriptor from settleHTLC's call signature
This is done as part of a systematic removal of PaymentDescriptor from
the mechanics of the htlcswitch package.
2024-10-11 14:14:40 +02:00
Keagan McClelland
22b2568f22
htlcswitch: remove PaymentDescriptor from sendHTLCError's call signature
This is done as part of a systematic removal of PaymentDescriptor from
the mechanics of the htlcswitch package.
2024-10-11 14:14:40 +02:00
Keagan McClelland
7f2fe2e5ff
channeldb: add convenience functions for generating Source/Dest Refs 2024-10-11 14:14:40 +02:00
Keagan McClelland
d364b9b9f8
lnwallet: add function to convert paymentDescriptor to LogUpdate
Here we add a function that is capable of recovering LogUpdates from
paymentDescriptors and we refactor the lnwallet code to use this
rather than doing JIT inline construction of the LogUpdates.
2024-10-11 14:14:40 +02:00
Keagan McClelland
9904af5d96
lnwire+htlcswitch: change NewInvalidBlinding to use array instead of slice 2024-10-11 14:14:40 +02:00
Keagan McClelland
e4497b4f45
htlcswitch: change sendMalformedHTLCError to take array instead of slice 2024-10-11 14:14:39 +02:00
Keagan McClelland
fb841b6436
htlcswitch+lnwallet: fix OnionBlob to 1366 bytes 2024-10-11 14:14:39 +02:00
Keagan McClelland
391370de20
lnwallet: track ChannelID on PaymentDescriptor
In this commit we track the ChannelID on the PaymentDescriptor.
This will be useful in upcoming commits that need to be able to
reconstruct lnwire.Message values from PaymentDescriptors as the
Messages that are exchanged to update channel state all include
the ChannelID.
2024-10-11 14:14:39 +02:00
Keagan McClelland
a40d363936
lnwallet: add ChannelID method to LightningChannel
In this commit we introduce a convenience method to LightningChannel
to allow us to quickly grab the channel id. This will be important
in upcoming commits where we need to remember the ChannelID to
reconstruct update messages.
2024-10-11 14:14:39 +02:00
Oliver Gugger
8cb8f589ee
Merge branch '0-18-4-branch-rc1-9049' into 0-18-4-branch-rc1 2024-10-11 14:13:49 +02:00
George Tsagkarelis
b0be0adcef
itest: add interceptor and first hop data tests 2024-10-11 14:13:49 +02:00
Oliver Gugger
1822b2f79a
lnrpc: add first hop custom data to route 2024-10-11 14:13:48 +02:00
George Tsagkarelis
444ef199a6
routing: use first hop records on path finding 2024-10-11 14:13:48 +02:00
Oliver Gugger
5489b06628
channeldb+routing: persist first hop custom data for route 2024-10-11 14:13:48 +02:00
George Tsagkarelis
6ac750955f
lnd: use impl cfg TlvTrafficShaper 2024-10-11 14:13:48 +02:00
Olaoluwa Osuntokun
ec2b2c6e1e
routing: skip amtInRange for custom HTLCs
We might be trying to send an invoice amount that's greater than the size of the channel, but once you factor in the custom channel logic, an actual HTLC can be sent over the channel to pay that larger payment.

As a result, we'll skip over this check if a have a custom HTLC.
2024-10-11 14:13:48 +02:00
George Tsagkarelis
f927563049
routing: add TlvTrafficShaper to bandwidth hints 2024-10-11 14:13:48 +02:00
George Tsagkarelis
69430ce042
htlcswitch: expose custom channel blob from link 2024-10-11 14:13:48 +02:00
George Tsagkarelis
c70832a823
lnwallet: expose commitment blob from channel 2024-10-11 14:13:47 +02:00
Oliver Gugger
0403b97a87
lnrpc: add first hop custom records to RPC payment info 2024-10-11 14:13:47 +02:00
Oliver Gugger
ff1a45549e
channeldb+routing: persist first hop custom records
With this commit we make sure the first hop custom records aren't lost
on restart/resume of a payment, so we persist it as part of the
PaymentCreationInfo struct.
2024-10-11 14:13:47 +02:00
George Tsagkarelis
857a16d838
lnrpc: add wire records fields to payment+interceptor RPCs 2024-10-11 14:13:47 +02:00
George Tsagkarelis
ef2c9801fb
multi: use wire records on payment and intercept flows 2024-10-11 14:13:47 +02:00
Oliver Gugger
b5efc0ef3e
lnwallet: extract diskCommit, remove unused error return value 2024-10-11 14:13:47 +02:00
ffranr
1b28f47c1d
itest: add itest for field modification HTLC interception response
Implement an integration test where an HTLC is intercepted and the
interception response modifies fields in the resultant p2p message.
2024-10-11 14:13:47 +02:00
ffranr
533b9f2d45
routerrpc: extend HTLC forward interceptor resp with modification fields
This commit extends the forward HTLC intercept response with fields that
can be used in conjunction with a `ResumeModified` action to modify the
intercepted HTLC p2p message.
2024-10-11 14:13:46 +02:00
ffranr
49db662b82
htlcswitch: add resume modified HTLC action to switch
Introduce `ResumeModified` action to resume standard behavior of a p2p
message with optional modifications as specified by the client during
interception.
2024-10-11 14:13:46 +02:00
ffranr
cb15297853
lnwire: add custom records field to type UpdateFulfillHtlc
- Introduce the field `CustomRecords` to the type `UpdateFulfillHtlc`.
- Encode and decode the new field into the `ExtraData` field of the
`update_fulfill_htlc` wire message.
- Empty `ExtraData` field is set to `nil`.
2024-10-11 14:13:46 +02:00
ffranr
2cfa89c719
lnwire: add custom records field to type UpdateAddHtlc
- Introduce the field `CustomRecords` to the type `UpdateAddHtlc`.
- Encode and decode the new field into the `ExtraData` field of
  the `update_add_htlc` wire message.
2024-10-11 14:13:46 +02:00
ffranr
ed69bb8757
lnwire: add ExtraOpaqueData helper functions and methods
Introduces a couple of new helper functions for both the ExtraOpaqueData
and CustomRecords types along with new methods on the ExtraOpaqueData.
2024-10-11 14:13:46 +02:00
ffranr
b07e857aef
lnwire: add unit tests for ExtraOpaqueData.PackRecords 2024-10-11 14:13:46 +02:00
George Tsagkarelis
08ca28773c
itest: add dynamic scid alias routing test 2024-10-11 14:13:46 +02:00
George Tsagkarelis
d6ef2a122f
routerrpc: add XAddLocalChanAliases & XDeleteLocalChanAliases 2024-10-11 14:13:45 +02:00
Oliver Gugger
2b1f347f98
aliasmgr: export alias start and end ranges
Because we restrict custom SCID aliases to be in a specific range, we
export the range start and end values so a user of the RPCs we're going
to add in the next commits can adjust their values to fit within the
range.
2024-10-11 14:13:45 +02:00
Oliver Gugger
148ba49530
aliasmgr: avoid collision when requesting alias
With the new RPC calls that we are going to add in the next commits, it
will be possible for users to add (local only, non-gossipped) SCID
aliases for channels. Since those will be in the same range as the ones
given out by RequestAlias, we need to make sure that when we generate a
new one that it doesn't collide with an already existing one.
2024-10-11 14:13:45 +02:00
Oliver Gugger
4757e891a2
aliasmgr: add map type alias 2024-10-11 14:13:45 +02:00
George Tsagkarelis
4ef68512a9
multi: refresh htlcswitch aliases on aliasmgr update 2024-10-11 14:13:45 +02:00
George Tsagkarelis
0c95dc2118
aliasmgr: add delete local alias method 2024-10-11 14:13:45 +02:00
Oliver Gugger
2da56bd776
Merge branch '0-18-4-branch-rc1-9044' into 0-18-4-branch-rc1 2024-10-11 14:13:12 +02:00
Keagan McClelland
d4a4233e96
lnwallet+htlcswitch: define expanded NumPendingUpdates
This commit squashes the below operations for a net result where
we have an expanded capability of assessing pending updates. This
is made possible by packing the components into Duals in the prior
commits. We squash the operations to simplify review.

htlcswitch+lnwallet: rename PendingLocalUpdateCount

lnwallet: complete pending update queries API for LightningChannel

lnwallet+htlcswitch: consolidate NumPendingUpdates using ChannelParty

This commit makes the observation that we can cleanly define the
NumPendingUpdates function using a single expression by taking
advantage of the relevant fields being properly packed into Duals.
2024-10-11 14:12:54 +02:00
Keagan McClelland
b337213fb2
lnwallet: pack commitment message indices into Dual
This is yet another commit that packs a symmetric structure into
a Dual. This is the last one needed for the time being to consolidate
Num{X}UpdatesPendingOn{Y} functions into a single one.
2024-10-11 14:12:53 +02:00
Keagan McClelland
214dac0c45
lnwallet: pack update logs into Dual
This commit, like the last one packs the update logs into a symmetric
Dual structure. This will allow us to index into them more concisely
in higher order logic.
2024-10-11 14:12:52 +02:00
Keagan McClelland
61383f1014
lnwallet: pack commit chains into Dual
This commit packs the LightningChannel's localCommitmentChain and
remoteCommitmentChain into a Dual structure for better symmetric
access. This will be leveraged by an upcoming commit where we want
to more concisely express how we compute the number of pending
updates.
2024-10-11 14:12:28 +02:00
Keagan McClelland
89a94e9ac8
htlcswitch: extract error handling for syncChanStates 2024-10-11 14:12:27 +02:00
Oliver Gugger
767a6f99a5
Merge branch '0-18-4-branch-rc1-9030' into 0-18-4-branch-rc1 2024-10-11 14:11:58 +02:00
Oliver Gugger
b0728647c9
lnwallet: thread thru input.AuxTapleaf to all relevant areas
In this commit, we start to thread thru the new aux tap leaf structures to all relevant areas. This includes: commitment outputs, resolution creation, breach handling, and also HTLC scripts.
2024-10-11 14:11:58 +02:00
Oliver Gugger
860cacb70a
lnwallet: refactor commit keys to use lntypes.Dual 2024-10-11 14:11:58 +02:00
Oliver Gugger
b1c8a836e3
multi: thread thru the AuxLeafStore everywhere 2024-10-11 14:11:58 +02:00
Olaoluwa Osuntokun
180648072c
channeldb: add HtlcIndex to HTLCEntry
This may be useful for custom channel types that base everything off the index (a global value) rather than the output index (can change with each state).
2024-10-11 14:11:58 +02:00
Olaoluwa Osuntokun
eb600a9447
channeldb: add custom blobs to RevocationLog+HTLCEntry
This'll be useful for custom channel types that want to store extra information that'll be useful to help handle channel revocation cases.
2024-10-11 14:11:58 +02:00
Olaoluwa Osuntokun
1f785e897e
channeldb: convert RevocationLog to use RecordT 2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
314a24689c
channeldb: convert HTLCEntry to use tlv.RecordT 2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
12ab2c3b51
lnwallet: add TLV blob to PaymentDescriptor + htlc add
In this commit, we add a TLV blob to the PaymentDescriptor struct. We also now thread through this value from the UpdateAddHTLC message to the PaymentDescriptor mapping, and the other way around.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
ef56d8654e
lnwallet+channeldb: add new AuxLeafStore for dynamic aux leaves
In this commit, we add a new AuxLeafStore which can be used to dynamically fetch the latest aux leaves for a given state. This is useful for custom channel types that will store some extra information in the form of a custom blob, then will use that information to derive the new leaf tapscript leaves that may be attached to reach state.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
9db810d67a
input: add some utility type definitions for aux leaves
In this commit, we add some useful type definitions for the aux leaf.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
ae1b121cdd
lnwallet: add custom tlv blob to internal commitment struct
In this commit, we also add the custom TLV blob to the internal commitment struct that we use within the in-memory commitment linked list.

This'll be useful to ensure that we're tracking the current blob for our in memory commitment for when we need to write it to disk.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
da9ceb131b
lnwallet: export the HtlcView struct
We'll need this later on to ensure we can always interact with the new aux blobs at all stages of commitment transaction construction.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
cd155d7d17
channeldb: new custom blob nested TLV
In this commit, for each channel, we'll now start to store an optional custom blob. This can be used to store extra information for custom channels in an opauqe manner.
2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
41bd293f33
input+lnwallet: update taproot scripts to accept optional aux leaf
In this commit, we update all the taproot scripts to also accept an
optional aux leaf. This aux leaf can be used to add more redemption
paths for advanced channels, or just as an extra commitment space.
2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
ca5dcbbf5c
lnwallet: add initial unit tests for musig2+tapscript root chans 2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
cae4f21897
lnwallet+peer: add tapscript root awareness to musig2 sessions
With this commit, the channel is now aware of if it's a musig2 channel, that also has a tapscript root. We'll need to always pass in the tapscript root each time we: make the funding output, sign a new state, and also verify a new state.
2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
62713c1270
lnwallet: update internal funding flow w/ tapscript root
This isn't hooked up yet to the funding manager, but with this commit, we can now start to write internal unit tests that handle musig2 channels with a tapscript root.
2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
b7e153fd82
multi: update GenTaprootFundingScript to pass tapscript root
In most cases, we won't yet be passing a root. The option usage helps us keep the control flow mostly unchanged.
2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
9fd8287c7b
lnwallet/chanfunding: add optional tapscript root 2024-10-11 14:11:55 +02:00
Olaoluwa Osuntokun
1e71b1e544
multi: add new tapscript root option to GenTaprootFundingScript
This'll allow us to create a funding output that uses musig2, but uses a tapscript tweak rather than a normal BIP 86 tweak.
2024-10-11 14:11:55 +02:00
Olaoluwa Osuntokun
74cb1f48ad
channeldb: add optional TapscriptRoot field + feature bit 2024-10-11 14:11:55 +02:00
Olaoluwa Osuntokun
e71627f893
channeldb: consolidate root bucket TLVs into new struct
In this commit, we consolidate the root bucket TLVs into a new struct.
This makes it easier to see all the new TLV fields at a glance. We also
convert TLV usage to use the new type param based APis.
2024-10-11 14:11:55 +02:00
Oliver Gugger
264dcd0641
Merge branch '0-18-4-branch-rc1-9025' into 0-18-4-branch-rc1 2024-10-11 14:04:01 +02:00
Oliver Gugger
830dd49fa8
routing+lnrpc: fix log statements 2024-10-11 14:04:00 +02:00
Oliver Gugger
1447493081
server: fix logging of pubkey 2024-10-11 14:04:00 +02:00
Oliver Gugger
2d6ba8c056
cmd/commands: export StripPrefix 2024-10-11 14:04:00 +02:00
Oliver Gugger
4fd1abfe52
lnwallet: add Tree() method, fix formatting 2024-10-11 14:04:00 +02:00
Oliver Gugger
89f75e7d1b
lnwallet: export GenTaprootHtlcScript 2024-10-11 14:04:00 +02:00
Oliver Gugger
29f139225b
lnwallet: export AnchorSize 2024-10-11 14:04:00 +02:00
Oliver Gugger
90470065ba
cmd/lncli: move commands and export
We want to export some of our CLI code to re-use in other projects. But
in Golang you cannot import code from a `main` package.
So we need to move the actual code into its own package and only have
the `func main()` in the `main` package.
2024-10-11 14:04:00 +02:00
Olaoluwa Osuntokun
41ca01a1b7
funding: use atomic.Uint64 for chanIDNonce
This lets us get rid of the mutex usage there. We also shift the algo slightly to increment by 1, then use that as the next value, which plays nicer with the atomics.
2024-10-11 14:03:59 +02:00
Olaoluwa Osuntokun
cd5fa5976a
funding: add new type alias for PendingChanID = [32]byte
This'll be useful for new interface definitions that use the contents of the package.
2024-10-11 14:03:59 +02:00
ffranr
b59ecc9270
htlcswitch: add missing method doc 2024-10-11 14:03:59 +02:00
ffranr
cc2b7b6fda
multi: improve comment grammar 2024-10-11 14:03:59 +02:00
ffranr
58ed8e751d
lnwire: add type CustomRecords
This commit introduces the `CustomRecords` type in the `lnwire` package,
designed to hold arbitrary byte slices. Each entry in this map can
associate with TLV type values that are greater than or equal to 65536.
2024-10-11 14:03:59 +02:00
Oliver Gugger
1893104392
mod: bump tlv to v1.2.6 2024-10-11 14:03:59 +02:00
Olaoluwa Osuntokun
213618adcc
lnwallet/chanfunding: rename assembler.go to interface.go
In this commit, we rename the files as assembler.go houses the primary
interfaces/abstractions of the package. In the rest of the codebase,
this file is near uniformly called interface.go, so we rename the file
to make the repo more digestible at a scan.
2024-10-11 14:03:59 +02:00
Oliver Gugger
7e656257d1
Merge branch '0-18-4-branch-rc1-9007' into 0-18-4-branch-rc1 2024-10-11 14:02:44 +02:00
Oliver Gugger
c849f91590
.golangci: fix config, update new-from-rev 2024-10-11 14:02:31 +02:00
Oliver Gugger
03493d491b
multi: update linter, fix new issues 2024-10-11 14:02:30 +02:00
Oliver Gugger
7502bf3ad9
.golangci: remove or rename old and deprecated linters 2024-10-11 14:01:44 +02:00
Olaoluwa Osuntokun
e735f77d43
build: set min build version to Go 1.22.6
Go 1.23 was released this week, so with this PR we update the build
system to officially support the last two releases.
2024-10-11 14:01:44 +02:00
Oliver Gugger
3b5e1fa764
Merge branch '0-18-4-branch-rc1-8520' into 0-18-4-branch-rc1 2024-10-11 14:01:29 +02:00
Olaoluwa Osuntokun
8eae1eec4a
peer: don't stop global msg router
In this commit, we fix a bug that would cause a global message router to
be stopped anytime a peer disconnected. The global msg router only
allows `Start` to be called once, so afterwards, no messages would
properly be routed.
2024-10-11 14:01:29 +02:00
Olaoluwa Osuntokun
35e48838c3
multi: make MsgRouter available in the ImplementationCfg
With this commit, we allow the `MsgRouter` to be available in the
`ImplementationCfg`. With this, programs outside of lnd itself are able
to now hook into the message processing flow to direct handle custom
messages, and even normal wire messages.
2024-10-11 14:01:29 +02:00
Olaoluwa Osuntokun
e257188017
peer: update readHandler to dispatch to msgRouter if set
Over time with this, we should be able to significantly reduce the size
of the peer.Brontide struct as we only need all those deps as the peer
needs to recognize and handle each incoming wire message itself.
2024-10-11 14:01:29 +02:00
Olaoluwa Osuntokun
a888573fcc
msgmux: add new abstract message router
In this commit, we add a new abstract message router. Over time, the
goal is that this message router replaces the logic we currently have in
the readHandler (the giant switch for each message).

With this new abstraction, can reduce the responsibilities of the
readHandler to *just* reading messages off the wire and handing them off
to the msg router. The readHandler no longer needs to know *where* the
messages should go, or how they should be dispatched.

This will be used in tandem with the new `protofsm` module in an
upcoming PR implementing the new rbf-coop close.
2024-10-11 14:01:29 +02:00
Oliver Gugger
0719c808dd
Merge branch '0-18-4-branch-rc1-8996' into 0-18-4-branch-rc1 2024-10-11 11:42:24 +02:00
Keagan McClelland
8344699a0d
lntypes: Add Dual[A] primitive type
This commit introduces a new type Dual[A] to make it easier to
manage symmetric configurations or state for lightning channels.
2024-10-11 11:42:23 +02:00
Oliver Gugger
d72a3aaf26
Merge pull request #9088 from Roasbeef/0-18-3-branch
build: bump version to v0.18.3
2024-09-11 05:22:27 -06:00
Olaoluwa Osuntokun
6eea5f3b13
build: bump version to v0.18.3 2024-09-10 19:44:13 -07:00
Olaoluwa Osuntokun
4f40e43b26
Merge pull request #9061 from Roasbeef/0-18-3-branch
release: create branch for v0.18.3 rc3
2024-09-06 15:34:20 -07:00
Olaoluwa Osuntokun
d85ce8415b
build: bump version to v0.18.3 rc3 2024-09-06 12:59:37 -07:00
Olaoluwa Osuntokun
e1351eaa0a Merge branch '0-18-3-branch-9050' into 0-18-3-branch 2024-09-06 12:59:32 -07:00
Olaoluwa Osuntokun
ce442a5083 Merge branch '0-18-3-branch-9046' into 0-18-3-branch 2024-09-06 12:59:32 -07:00
Andras Banki-Horvath
d4fbc815c6 docs: update docs/release-notes/release-notes-0.18.3.md 2024-09-06 12:59:32 -07:00
Olaoluwa Osuntokun
2341019016 lnwallet: expand chan sync tests to cover taproot channels
In this commit, we expand some of the existing chan sync tests to cover
taproot channels (the others already did). Along the way, we always
assert that the `PartialSig` is populated on retransmission. In
addition, we now send the new commit sig rather than the existing
in-memory one to test the new logic that re-signs the commitment.
2024-09-06 12:59:32 -07:00
Andras Banki-Horvath
b62db3733d sqldb: fix end date filter when querying invoices
Previously, the SQL implementation of the invoice query simply
converted the start and end timestamps to time and used them
in SQL queries to check for inclusivity. However, this logic
failed when the start and end timestamps were equal.

This commit addresses and corrects this issue.
2024-09-06 12:59:32 -07:00
Andras Banki-Horvath
9298133614 sqldb+invoices: synchronize SQL invoice updater behavior with KV version
Previously SQL invoice updater ignored the set ID hint when updating an
AMP invoice resulting in update subscriptions returning all of the AMP
state as well as all AMP HTLCs. This commit synchornizes behavior with
the KV implementation such that we now only return relevant AMP state
and HTLCs when updating an AMP invoice.
2024-09-06 12:59:32 -07:00
Andras Banki-Horvath
b3dc3ed5c8 channeldb: filter AMP state to relevant set IDs
When fetching an AMP invoice we sometimes filter HTLCs to selected set
IDs, however we always kept the full AMP state which is irrelevant as it
contains state for all AMP payments. This was a side effect of
UpdateInvoice needing to serialize the whole invoice when storing after
an update but it is an unwanted "feature" as users will need to filter
to relevant set when listing an AMP payment or subsribing to an update.
2024-09-06 12:59:32 -07:00
Alex Akselrod
cadce23b47 invoices: ensure AMP subinvoices are correctly updated w/nativesql 2024-09-06 12:59:32 -07:00
Alex Akselrod
8c6e24346a itest: check that AMP subinvoices are correctly updated w/nativesql 2024-09-06 12:59:32 -07:00
Alex Akselrod
e152a52625 invoices/sqldb: query by ChanID when updating AMP invoice preimage 2024-09-06 12:59:32 -07:00
Olaoluwa Osuntokun
d13908881c lnwallet: extract initMusigNonce from initRevocationWindows
This'll be useful later to make some enhancements to the existing unit
tests.
2024-09-03 17:26:06 -07:00
Olaoluwa Osuntokun
c7300f452c lnwallet: ensure we re-sign retransmitted commits for taproot channels
In this commit, we fix an existing bug with the taproot channel type
that can cause force closes if a peer disconnects while attempting to
send the commitment signature.

Before this commit, since the `PartialSig` we send is never committed to
disk, the version read wouldn't contain the musig2 partial sig. We never
write these signatures to disk, as each time we make a new session, we
need to generate fresh nonces to avoid nonce-reuse.

Due to the above interaction, if we went to re-send a signature after a
disconnection, the `CommitSig` message we sent wouldn't actually contain
a `PartialSigWithNonce`, causing a protocol error.
2024-09-03 17:26:06 -07:00
Olaoluwa Osuntokun
3bb4d6d370
Merge pull request #9036 from Roasbeef/0-18-3-branch
release: bump version to v0.18.3 rc2
2024-08-28 18:48:05 -05:00
Olaoluwa Osuntokun
d111d8d53c
build: bump version to v0.18.3 rc2 2024-08-27 18:52:44 -05:00
Olaoluwa Osuntokun
e69fdf5b83 Merge branch '0-18-3-branch-9009' into 0-18-3-branch 2024-08-27 18:52:20 -05:00
Eugene Siegel
6111ac3468 release-notes: update for 0.18.3 2024-08-27 18:52:10 -05:00
Eugene Siegel
53a8d37df7 discovery: implement ChannelAnnouncement banning
This commit hooks up the banman to the gossiper:
- peers that are banned and don't have a channel with us will get
  disconnected until they are unbanned.
- peers that are banned and have a channel with us won't get
  disconnected, but we will ignore their channel announcements until
  they are no longer banned. Note that this only disables gossip of
  announcements to us and still allows us to open channels to them.
2024-08-27 18:52:10 -05:00
Eugene Siegel
ae33b760f8 graph: export NewErrf and ErrorCode for upcoming gossiper unit tests 2024-08-27 18:52:09 -05:00
Eugene Siegel
de58e3e98e discovery: clean up scid variable usage 2024-08-27 18:51:38 -05:00
Eugene Siegel
3e318b4187 multi: extend lnpeer.Peer interface with Disconnect function
This will be used in the gossiper to disconnect from peers if their
ban score passes the ban threshold.
2024-08-27 18:51:38 -05:00
Eugene Siegel
b7c4a3cd18 discovery: add banman for channel announcements
This commit introduces a ban manager that marks peers as banned if
they send too many invalid channel announcements to us. Expired
entries are purged after a certain period of time (currently 48 hours).
2024-08-27 18:51:38 -05:00
Eugene Siegel
4558eb04d0 channeldb: add PutClosedScid and IsClosedScid
This commit adds the ability to store closed channels by scid in
the database. This will allow the gossiper to ignore channel
announcements for closed channels without having to do any
expensive validation.
2024-08-27 18:51:38 -05:00
Olaoluwa Osuntokun
e431e5b71f Merge branch '0-18-3-branch-9026' into 0-18-3-branch 2024-08-26 20:19:31 -05:00
ziggie
72929079c9 docs: add release-notes. 2024-08-26 20:19:31 -05:00
ziggie
59355b17a5 blindedpath: minHTLC for blinded path change.
We will not add a buffer to the chan policy for blinded paths in case
the sender amount violates the minHTLC restriction in the first place.

Moreover we disgard a route fast if the payment amount is smaller than
the minHTLC along the route.
2024-08-26 20:19:31 -05:00
ziggie
89ef3737b1 blindedpath: fix log output. 2024-08-26 20:19:31 -05:00
ziggie
38c81516ec blindedpath: remove blockexpiry check.
Removes a check where we would NOT allow to create a blinded invoice
with an expiry (invoice expiry in seconds considered as block time)
lower than the min_final_ctlv_delta.
2024-08-26 20:19:31 -05:00
Olaoluwa Osuntokun
dbe4ca3efe Merge branch '0-18-3-branch-9011' into 0-18-3-branch 2024-08-26 20:19:11 -05:00
ziggie
4102e33670 docs: update release-notes. 2024-08-26 20:19:11 -05:00
ziggie
d906010508 discovery: add detailed comment.
Describe why it is ok to resurrect zombie channels based on the
timestamp of the `ReplyChannelRange` msg although its not verifiable
data.
2024-08-26 20:19:11 -05:00
ziggie
44413868c7 multi: fix time.Time initialization.
ChanUpdate timestamps are now restircted so that they cannot be
more than two weeks into the future. Moreover channels with both
timestamps in the ReplyChannelRange msg either too far in the past
or too far in the future are not queried.

Moreover fix unitests.
2024-08-26 20:19:11 -05:00
ziggie
b23e69c0b7 discovery: fix log line.
if we use %x here we would get the hex representation of the
String() method of the vertex, which is wrong.
2024-08-26 20:19:11 -05:00
Olaoluwa Osuntokun
53799e9f91 Merge branch '0-18-3-branch-9002' into 0-18-3-branch 2024-08-26 20:18:47 -05:00
Olaoluwa Osuntokun
57221bd760 discovery: fix bug that can lead to sending invalid chan_ann msgs
Initially in lnd, we didn't store the extra TLV data that could be
dangling off of gossip messages. This was fixed initially in lnd v0.5
with this PR: https://github.com/lightningnetwork/lnd/pull/1825.

Within the PR, we incorrect set the `ExtraOpaqueData` (extra TLV blob)
of the `ChannelAnnouncement` to the value stored in `edge`, which is
actually our channel update. As 6-ish years ago we didn't yet have
anything that used the TLV gossip fields, this went unnoticed.

Fast forward to 2024, we shipped an experimental version of inbounbd
fees. This starts to store additional data in the `ExtraOpaqueData`
field, the TLV for the inbound fee. Initially, everything is valid when
the first `ChannelAnnouncement` is sent, but as soon as a user attempts
to set an inbound fee policy, we'd incorrectly swap in that new
serialized TLV for the _channel announcement_:
841e24399c (diff-1eda595bbebe495bd74a6a0431c46b66cb4e8b53beb311067c010feac2665dcbR2560).

Since we're just trying to generate a new `channel_update`, we don't
also regenerate the signature for the `channel_announcement` message. As
a result, we end up storing a `channel_announcement` with an invalid sig
on disk, continuing to broadcast that to peers.
2024-08-26 20:18:29 -05:00
Oliver Gugger
8f25de054d
Merge pull request #9023 from ellemouton/testHTLCPersistenceAcrossRestart
lnwallet: correctly set UpdateAddHTLC.BlindingPoint on reload from disk
2024-08-22 07:29:50 -06:00
Elle Mouton
e99b09d38a
docs: update release notes 2024-08-22 14:21:30 +02:00
Elle Mouton
fcbd1e14d3
lnwallet+itest: fix PaymentDescriptor creation for blinded path htlc
This commit fixes the instantiation of the BlindingPoint member of
PaymentDescriptor during the conversion from persisted LogUpdates.
Previously, the blinding point was not set correctly. The test from the
previous commit is also updated to now assert that this behaviour is now
correct.
2024-08-22 14:21:30 +02:00
Elle Mouton
58fa379cc7
itest: demonstrate UpdateAddHTLC reloading bug
This commit adds a new route blinding itest that demonstrates that the
reloading and re-forwarding of an UpdateAddHTLC message on restart
currently is done incorrectly for a blinded path payment. This is due to
the fact that the blinding point member is not currently set correctly.
This is fixed in the next commit which will also change the test to
assert that the behaviour is now correct.
2024-08-22 14:21:30 +02:00
Olaoluwa Osuntokun
8d5f66b5fc
Merge pull request #8995 from Roasbeef/0-18-3-branch-rc1
build: bump to v0.18.3-beta.rc1
2024-08-09 13:58:50 -07:00
Olaoluwa Osuntokun
7c2cf49d66
build: bump to v0.18.3-beta.rc1 2024-08-09 13:58:05 -07:00
Olaoluwa Osuntokun
57a5e4912b
Merge pull request #8994 from ellemouton/rbMicroFixes
Rb micro fixes
2024-08-08 11:17:16 -07:00
Elle Mouton
ab28cde240
routing: correct initial finalPaddedSize
This purely affects logging. This makes sure that the `padStat`
finalPaddedSize field is initilised correctly with the given minSize.
2024-08-08 16:46:04 +02:00
Elle Mouton
5e84ba92af
multi: add IsBlinded to lnrpc.Invoice for nicer UX
The BlindedPathConfig struct is nice for invoice creation but when we
use the Invoice message for viewing an invoice, it would be nicer to see
an "is_blinded" field.
2024-08-08 16:46:01 +02:00
Oliver Gugger
bbd313dcca
Merge pull request #8992 from guggero/estimate-fee-cli
cmd/lncli: add min relay fee to `lncli wallet estimatefeerate`
2024-08-08 01:43:56 -06:00
Oliver Gugger
eac54601fb
cmd/lncli: add min relay fee to lncli wallet estimatefeerate
This commit adds the new value that was added to the RPC response to the
CLI output as well.
2024-08-08 09:24:49 +02:00
Olaoluwa Osuntokun
5a84ca8032
Merge pull request #8986 from Roasbeef/min-relay-fee-rpc
lnrpc: add new min_relay_fee response to EstimateFee
2024-08-07 21:01:54 -07:00
Olaoluwa Osuntokun
51f3577ef9
Merge pull request #8963 from Roasbeef/always-send-chan-upd
peer: always send channel update on reconnect
2024-08-07 18:50:34 -07:00
Olaoluwa Osuntokun
459ee9b245
Merge pull request #8976 from ellemouton/rb-follow-ups
route blinding: follow ups
2024-08-07 17:54:31 -07:00
Olaoluwa Osuntokun
7f96d10dd3
lnrpc: add new min_relay_fee response to EstimateFee
We also start using a pattern of making new messages for types/units
instead of adding a suffix to a field.
2024-08-07 17:51:35 -07:00
Olaoluwa Osuntokun
9acad37f57
peer: always send channel update on reconnect
We have existing logic to attempt to reliably send a channel update to
the remote peer. In the wild, we've seen this fail, as it's possible
right when we send the update the peer disconnects.

In this commit, we implement a simple fix which is just to send the chan
update each time we connect to the remote party.

Fixes https://github.com/lightningnetwork/lnd/issues/6870.
2024-08-07 17:48:50 -07:00
Elle Mouton
f1a58dcab1
lnwire: update Bolt11 blinded path feature bits
so that they dont clash with the htlc-endorsement feature bits.
2024-08-07 20:13:34 +02:00
Yong
a449a5d132
Merge pull request #8174 from yyforyongyu/fix-inflight-payments
routing: fix stuck inflight payments
2024-08-07 23:23:27 +08:00
Elle Mouton
d47ff3af79
docs: add release note 2024-08-07 17:03:12 +02:00
Elle Mouton
697f514d09
blindedpath: log chosen blinded paths
In this commit, we log selected blinded paths.
2024-08-07 17:03:12 +02:00
Elle Mouton
95477390a4
log: register blindedpath pkg logger 2024-08-07 17:03:12 +02:00
Elle Mouton
48a9a8d20e
zpay32: add functional opt to error out on unknown feature bit
This commit adds two functional options to the zpay32.Decode function.
`WithKnownFeatureBits` allows the caller to overwrite the default set of
known feature bits used by the function.
`WithErrorOnUnknownFeatureBit` allows the caller to instruct the
function to error out if the invoice that is decoded contaijns unknown
feature bits. We then use this new error-out option from the
`rpcServer`'s `extractPaymentIntent` method.
2024-08-07 17:03:12 +02:00
Elle Mouton
e4619afc08
multi: add node omission list for blinded paths 2024-08-07 17:03:11 +02:00
Elle Mouton
b490deefdf
routing/blindedpath: dont error out unless all paths fail
In this commit, we adjust BuildBlindedPaymentPaths to only error out
completely if none of the paths it received from FindRoutes resulted in
a usable blinded path.
2024-08-07 17:02:56 +02:00
Elle Mouton
3de6c5415a
multi: let blinded path invoice options be set per addinvoice call
Extend the configurability of blinded paths in invoices by adding the
ability to change the global config options on a per-RPC basis.
2024-08-07 17:02:55 +02:00
Elle Mouton
ca91e17115
invoicesrpc: move blinded path config to AddInvoiceData
since `AddInvoiceData` is config _per invoice_ where as `AddInvoiceConfig`
is config for the invoice server itself and so pretty much should stay
the same for the lifetime of LND. This change sets us up for moving some
of the blinded path config options to be changeable per AddInvoice call
rather that having fixed config values in the config file.
2024-08-07 17:01:21 +02:00
Elle Mouton
e47160d257
routing: fix MC probability order for blinded paths
Fix the blinded path probability sorting function.
Also fix the test assertion function.
2024-08-07 17:01:21 +02:00
Oliver Gugger
d77617461d
Merge pull request #8955 from yyforyongyu/cr-8516-240729-sendcoins
Allow selecting coins in `sendcoins`
2024-08-07 08:42:25 -06:00
yyforyongyu
bc31a8b36f
routing: fix doc string 2024-08-07 22:19:23 +08:00
yyforyongyu
677f2c390a
lntest: re-define CleanupForceClose
To reflect the new sweeping behavior, also makes it easier to be used as
we need to method to quickly cleanup force closes without concerning the
details when we are not testing the force close behavior.
2024-08-07 22:19:23 +08:00
yyforyongyu
7aba5cbc0a
routing: fix linter complains 2024-08-07 22:19:23 +08:00
yyforyongyu
188aa9a4d4
routing+lnd: prepare closed channel SCIDs in server
The method `FetchClosedChannels` sometimes prematurely mark a pending
force closing channel as finalized, therefore we need to furthur check
`FetchPendingChannels` to make sure the channel is indeed finalized.
2024-08-07 22:19:23 +08:00
yyforyongyu
e8f292edf4
docs: update release notes re stuck payment fix 2024-08-07 22:19:22 +08:00
yyforyongyu
c2f7e6a66f
routing: fail stale HTLC attempts during startup
This commit adds a check during router's startup and fails the inflight
HTLCs if they are routing using channels unknown to us. The channels are
unknown because they are already closed, usually long time ago.
2024-08-07 22:19:21 +08:00
yyforyongyu
b998ce11f1
routing+htlcswitch: add new interface method HasAttemptResult 2024-08-07 22:18:51 +08:00
yyforyongyu
bbf58ab444
routing: add new method resumePayments to handle payments during
startup
2024-08-07 22:18:49 +08:00
yyforyongyu
3b6e28d19b
channeldb+htlcswitch: make sure circuit is not nil in teardownCircuit 2024-08-07 22:17:59 +08:00
yyforyongyu
2fc79d8946
htlcswitch: handle forwarding settle and fail seperately
This commit adds two methods, `handlePacketFail` and
`handlePacketSettle` to handle the settle and fail packets differently.
2024-08-07 22:17:59 +08:00
yyforyongyu
6cb374aea6
htlcswitch: add new method handlePacketAdd
Simply moves the code into a new method so it's easier to follow the
method `handlePacketForward`.
2024-08-07 22:17:59 +08:00
yyforyongyu
d28d5d7a47
itest: add testSendToRouteFailHTLCTimeout to check SendToRouteV2 2024-08-07 22:17:58 +08:00
yyforyongyu
21112cfdf8
htlcswitch: rename paymentID to attemptID for clarity 2024-08-07 22:17:58 +08:00
yyforyongyu
941716d60e
lntest+itest: add new test testPaymentHTLCTimeout
This commit adds a new test case to validate that when an HTLC has timed
out, the corresponding payment is marked as failed.
2024-08-07 22:17:58 +08:00
yyforyongyu
0928ba0149
routing: fix and enhance logging 2024-08-07 22:17:58 +08:00
Oliver Gugger
b63e5decad
Merge pull request #8886 from bitromortac/buildroute-inbound-fees
routing: inbound fees support for BuildRoute
2024-08-07 08:11:17 -06:00
yyforyongyu
dcd8269050
docs: update release notes 2024-08-07 20:42:58 +08:00
yyforyongyu
e542351149
itest: add testSendSelectedCoins to check selected utxos 2024-08-07 20:42:58 +08:00
yyforyongyu
0041426e7e
itest+lntest: return the error from SendCoinsAssertErr
Also rename the send all coins test for clarity.
2024-08-07 20:42:28 +08:00
Ononiwu Maureen
018484628a
lncli: Add outpoints flag to sendcoins command
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-08-07 20:42:28 +08:00
Ononiwu Maureen
900d7fdd17
cmd: Export and move utxosToOutpoint.
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-08-07 20:42:28 +08:00
Ononiwu Maureen
b50a1e6360
lnd: modify sendcoin rpc impl for select utxos
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-08-07 20:42:28 +08:00
Ononiwu Maureen
13bad2c20c
sweep: Add selectUtxos to CraftSweepAllTx args 2024-08-07 20:42:28 +08:00
Ononiwu Maureen
99339f706f
multi: expand SendOutputs and CreateSimpleTx to take utxos
This commit updates the interface methods from
`lnwallet.WalletController` to take optional input set which can be used
to create the tx.
2024-08-07 20:42:27 +08:00
Ononiwu Maureen
468ca87499
lnrpc: Add Outpoint field in SendCoinsRequest
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-08-07 20:42:27 +08:00
bitromortac
f622b43b5d
docs: add to release notes 2024-08-07 14:25:27 +02:00
bitromortac
b0e1a722c6
routerrpc: add check for empty hops 2024-08-07 14:24:59 +02:00
bitromortac
452db01ad7
lnrpc+routing: convert amt pointer to fn.Option 2024-08-07 14:24:56 +02:00
bitromortac
8b32e3e785
routing: add inbound fee support for BuildRoute 2024-08-07 14:23:54 +02:00
bitromortac
36cd03669b
routing: add outgoingFromIncoming amount calc
Adds a utility function to be able to compute the outgoing routing
amount from the incoming amount by taking inbound and outbound fees into
account. The discussion was contributed by user feelancer21, see
f6f05fa930.
2024-08-07 12:40:42 +02:00
bitromortac
2c79bf9635
routing: refactor backward and forward pass 2024-08-07 12:40:42 +02:00
Oliver Gugger
75ec6da177
Merge pull request #8979 from ProofOfKeags/refactor/useless-args
[NANO]: Remove useless appendages from lnwallet/channel.go
2024-08-07 01:37:56 -06:00
Oliver Gugger
9271b5ebbe
Merge pull request #8984 from guggero/make-rpc
lnrpc: avoid needing to download Golang
2024-08-07 01:36:00 -06:00
Oliver Gugger
94b9b50a42
mod: update comment what to change on Go version bump 2024-08-07 09:16:37 +02:00
ProofOfKeags
747abb4a0e
Merge pull request #8980 from ProofOfKeags/refactor/modified-htlcs-fn-set
[NANO]: lnwallet: update updateLog.modifiedHtlcs to use fn.Set
2024-08-06 11:56:57 -06:00
Keagan McClelland
c3c4e79593
lnwallet: update updateLog.modifiedHtlcs to use fn.Set 2024-08-06 10:05:20 -07:00
Oliver Gugger
63af63dfa8
lnrpc: avoid needing to download Golang
Because the Go version used to run the `go list` commands is below the
minimum version specified in the main go.mod file, every time the `make
rpc` command is executed, the Golang runtime is downloaded twice, which
looks like this and takes a couple of seconds at least:

go: downloading go1.21.4 (linux/amd64)
go: downloading go1.21.4 (linux/amd64)

We fix this by using the correct minimum version.
2024-08-06 18:38:10 +02:00
Yong
ab96de3f07
Merge pull request #8967 from ProofOfKeags/feature/stfu-wire
[MICRO]: add wire messages for quiescence
2024-08-06 13:52:12 +08:00
Keagan McClelland
935e7f1bee
lnwallet: remove unused parameters in LightningChannel methods 2024-08-05 18:14:11 -07:00
Keagan McClelland
14e371948b
lnwallet: remove unnecessary duplicate definition 2024-08-05 18:14:11 -07:00
Keagan McClelland
2ddc3db5f8
peer: add message summary for Stfu 2024-08-05 17:23:19 -07:00
Keagan McClelland
b172227cb3
lnwire: add Stfu to LinkUpdater interface 2024-08-05 17:23:19 -07:00
Keagan McClelland
0176fca826
lnwire: add wire type for stfu 2024-08-05 17:22:56 -07:00
Olaoluwa Osuntokun
c262b1b5a5
Merge pull request #8968 from ProofOfKeags/opening-party
[MICRO]: channeldb+lnwallet: add OpeningParty API
2024-08-05 16:42:22 -07:00
Keagan McClelland
a2b19afe59
channeldb+lnwallet: define Initiator for OpenChannel and LightningChannel
This commit introduces a new API to return information on which party opened
the channel using the new ChannelParty type. It does not change the underlying
structure of how we store this information.
2024-08-05 12:58:46 -07:00
Elle
4e5728f58a
Merge pull request #8974 from ellemouton/falafelUpdate
lnrpc: update falafel version
2024-08-05 19:20:06 +02:00
Elle
f341d4c65f
Merge pull request #8977 from ellemouton/fixTestRace
routing: fix race in TestNewRouteRequest
2024-08-05 18:36:56 +02:00
Elle Mouton
6ab34665fb
routing: fix race in TestNewRouteRequest
The `err` variable was being shared by the parallel threads.
2024-08-05 16:07:03 +02:00
Elle Mouton
2d00859b75
mobile: correct output directory for generated files 2024-08-05 16:00:00 +02:00
Elle Mouton
66e10fda06
docs: update release notes 2024-08-05 16:00:00 +02:00
Elle Mouton
e8da2fa0bd
lnrpc/gen_protos: remove manual_imports
With the updated falafel version, there is no longer a need to specify
manual imports.
2024-08-05 16:00:00 +02:00
Elle Mouton
58317e66d3
lnrpc/Dockerfile: update falafel version
Update the falafel version.
2024-08-05 15:59:50 +02:00
Oliver Gugger
7e1e054511
Merge pull request #8959 from guggero/bump-kvdb
mod: bump kvdb to v1.4.10
2024-08-05 03:18:17 -06:00
Oliver Gugger
11c7e20d0a
Merge pull request #8953 from ProofOfKeags/refactor/lnwallet-channel-channel-constraints-partition
[MICRO]: multi: break ChannelConstraints into two sub-structures
2024-08-05 02:08:52 -06:00
Oliver Gugger
6e63dcd6f9
Merge pull request #8952 from ProofOfKeags/refactor/lnwallet-channel-typed-list
[MICRO]: lnwallet: refactor channel to use new typed List
2024-08-05 02:07:50 -06:00
Oliver Gugger
546c8ebb99
Merge pull request #8954 from ffranr/check-go-versions
Linter checks go versions in Dockerfile and YAML files
2024-08-05 02:01:00 -06:00
Oliver Gugger
2cc668838c
mod: bump kvdb to v1.4.10
To support the new comma-separated list of etcd hosts in db.etcd.host,
we need to bump the `kvdb` submodule version.
This also fixes a leader election bug in the etcd code.
2024-08-05 09:33:42 +02:00
Oliver Gugger
e0b8892290
mod: remove local replace for healthcheck 2024-08-05 09:32:52 +02:00
Oliver Gugger
05c786f775
mod: remove local replace for sqldb 2024-08-05 09:29:03 +02:00
Olaoluwa Osuntokun
c46b1a467a
Merge pull request #8836 from hieblmi/payment-failure-reason-cancel
routing: add payment failure reason `FailureReasonCancel`
2024-08-01 16:52:06 -07:00
Olaoluwa Osuntokun
4a3c4e4ba7
Merge pull request #8497 from ziggie1984/shutdown-bugfix
routing: shutdown chanrouter correctly.
2024-08-01 16:48:50 -07:00
ProofOfKeags
e3dd886580
Merge pull request #8962 from ProofOfKeags/refactor/quiescence-micro-spinoffs
[NANO]: Refactor/quiescence micro spinoffs
2024-08-01 13:57:29 -06:00
Keagan McClelland
22e34702d8
funding: replace newly edited log values with lazier variants 2024-08-01 12:11:52 -07:00
Keagan McClelland
e3a9d0acbe
multi: break ChannelConstraints into two sub-structures
This commit breaks the ChannelConstraints structure into two
sub-structures that reflect the fundamental differences in how
these parameters are used. On its face it may not seem necessary,
however the distinction introduced here is relevant for how we
will be implementing the Dynamic Commitments proposal.
2024-08-01 12:00:32 -07:00
Keagan McClelland
dc03637ae3
htlcswitch: rename for test parameters for accuracy 2024-08-01 11:56:50 -07:00
Olaoluwa Osuntokun
6e9eb1d0f7
Merge pull request #8938 from bhandras/etcd-leader-election-fixups
multi: check leader status with our health checker to correctly shut down LND if network partitions
2024-08-01 11:26:29 -07:00
Andras Banki-Horvath
037161ee6c
docs: add release notes for 0.18.3 2024-08-01 19:04:11 +02:00
Andras Banki-Horvath
f63bccb575
config: update sample-lnd.conf 2024-08-01 19:04:11 +02:00
Andras Banki-Horvath
91d9fb4764
lncfg: increase default leader session TTL to 90 seconds 2024-08-01 19:04:11 +02:00
Andras Banki-Horvath
8e49eb652d
itest: add itest covering the leader healthcheck 2024-08-01 19:04:10 +02:00
Andras Banki-Horvath
8e0534f756
multi: add leader check to the healthcheck monitor
This commit extends our healtcheck with an optional leader check. This
is to ensure that given network partition or other cluster wide failure
we act as soon as possible to avoid a split-brain situation where a new
leader is elected but we still hold onto our etcd client.
2024-08-01 19:04:10 +02:00
Andras Banki-Horvath
7784d6abf6
build: pin healthcheck and kvdb modules temporarily
This is to ensure that the added functionality works correctly and
should be removed once these changes are merged and the packages are
tagged.
2024-08-01 19:04:10 +02:00
Andras Banki-Horvath
2c8d1c878e
kvdb: make etcd calls timeout to ensure liveness
Previously our RPC calls to etcd would hang even in the case of properly
set dial timeouts and even if there was a network partition. To ensure
liveness we need to make sure that calls fail correctly in case of
system failure. To fix this we add a default timeout of 30 seconds to
each etcd RPC call.
2024-08-01 19:04:10 +02:00
Andras Banki-Horvath
0fd4c7d5f9
healthcheck: improve logging of observers 2024-08-01 19:04:09 +02:00
ffranr
2a6e54016f
Makefile: add lint check for Go version in Dockerfile and YAML
Implemented linter scripts to ensure consistency of the Go version
specified in Dockerfiles and YAML files. These scripts verify that the
Go version used across these files is uniform, enhancing maintainability
and reducing configuration errors.

This commit also introduces a `GO_VERSION` Makefile variable to control
the Go version used throughout the project.
2024-08-01 14:09:58 +01:00
bitromortac
c18694ff5e
routing: backward pass determines unified edges
We shift the duty of determining the policies to the backward pass as
the forward pass will only be responsible for finding the corrected
receiver amount.

Note that this is not a pure refactor as demonstrated in the test, as
the forward pass doesn't select new policies anymore, which is less
flexible and doesn't lead to the highest possible receiver amount. This
is however neccessary as we otherwise won't be able to compute
forwarding amounts involving inbound fees and this edge case is unlikely
to occur, because we search for a min amount for a route that was most
likely constructed for a larger amount.
2024-08-01 11:16:18 +02:00
bitromortac
e4c7c10618
routing: handle both amounts equally
We duplicate the function calls to handle the min amount and known
amount cases in a similar manner, to make the next diff easier to
parse.
2024-08-01 11:16:15 +02:00
Slyghtning
808d958c9c
docs: update release notes 2024-08-01 10:25:23 +02:00
Slyghtning
0273eac4b2
itest: payment failure reason canceled 2024-08-01 10:25:22 +02:00
Slyghtning
653226d29c
itest: format and typo fixes 2024-08-01 10:24:08 +02:00
Slyghtning
2e3c96f986
routing: new failure reason for cancelled payments 2024-08-01 10:24:08 +02:00
Slyghtning
d18c4d61ce
lnrpc: payment failure reason canceled 2024-08-01 10:24:07 +02:00
Olaoluwa Osuntokun
04dde98edc
Merge pull request #8764 from ellemouton/rb-send-via-multi-path
[3/4] Route Blinding: send MPP over multiple blinded paths
2024-07-31 19:21:49 -07:00
Keagan McClelland
f54c9ea8f7
htlcswitch: replace errors package implementation 2024-07-31 17:54:21 -07:00
Olaoluwa Osuntokun
b21521ff14
Merge pull request #8949 from ProofOfKeags/fn/req
[MICRO]: fn: Add new Req type to abstract the pattern of remote processing.
2024-07-31 17:31:35 -07:00
Olaoluwa Osuntokun
14ff12aa81
Merge pull request #8951 from ProofOfKeags/refactor/lnwallet-channel-channel-party
[MILLI]: Introduce and use ChannelParty
2024-07-31 17:30:32 -07:00
Keagan McClelland
1f9cac5f80
htlcswitch: refactor dust handling to use ChannelParty 2024-07-31 14:50:27 -07:00
Keagan McClelland
1d65f5bd12
peer: refactor createChanCloser to use ChannelParty 2024-07-31 14:50:27 -07:00
Keagan McClelland
0996e4f163
multi: refactor lnwallet/channel.go to use ChannelParty in select places
We also include changes to contractcourt, htlcswitch and peer to stitch the
boundaries together.
2024-07-31 14:50:26 -07:00
Keagan McClelland
33934449ac
multi: refactor select methods within channeldb to use ChannelParty
Also in this commit is a small adjustment to the call-sites to get
the boundaries stitched back together.
2024-07-31 14:50:26 -07:00
Keagan McClelland
3a15085014
input+lnwallet: refactor select methods in input to use ChannelParty 2024-07-31 14:50:26 -07:00
Keagan McClelland
1a5b5c5f62
lntypes: Add a ChannelParty type.
This commit introduces a ChannelParty type to LND. It is useful for
consolidating all references to the duality between the local and
remote nodes. This is currently handled by having named struct rows
or named boolean parameters, named either "local" or "remote". This
change alleviates the programmer from having to decide which node
should be bound to `true` or `false`. In an upcoming commit we will
change callsites to use this.
2024-07-31 14:50:23 -07:00
Keagan McClelland
04c37344ae
lnwallet: refactor channel to use new typed List 2024-07-31 13:03:34 -07:00
Keagan McClelland
2c6d229a69
fn: harden and refine the Req[I,O] API.
In this commit we opt to make the internal response channel fully
private and instead expose methods for doing resolution. This
prevents internal implementation details from leaking a little bit
better than the previous iteration.
2024-07-31 12:59:10 -07:00
Keagan McClelland
4835fdf237
fn: Add new Req type to abstract the pattern of remote processing.
It is common throughout the codebase to send data to a remote
goroutine for processing. Typically, along with the data we are
processing, we also send a one-shot channel where we intend to
listen for the response. This type encapsulates that pattern.
2024-07-31 12:59:03 -07:00
ffranr
077e6682fa
Makefile: rename variable to ACTIVE_GO_VERSION
Renamed the Makefile variable `GO_VERSION` to `ACTIVE_GO_VERSION` for
improved clarity. This change also frees up the name `GO_VERSION` to be
used for defining the global Go version for reproducible binaries in a
subsequent commit.
2024-07-31 16:53:47 +01:00
ffranr
d7a81a1fe3
multi: use Go version 1.22.5 throughout 2024-07-31 16:53:47 +01:00
Oliver Gugger
16d80f5b5b
Merge pull request #8845 from bitbandi/multiple-etcd-host
Allow multiple etcd host
2024-07-31 08:55:48 -06:00
elbandi
6043ced572
Add configuration description 2024-07-31 15:31:56 +02:00
elbandi
a0ec4f24d6
docs: Add release note item 2024-07-31 15:31:55 +02:00
elbandi
3d48dbdd55
Allow multiple etcd hosts to be specified in db.etcd.host. 2024-07-31 15:31:17 +02:00
Oliver Gugger
72a36da9c6
Merge pull request #8950 from ProofOfKeags/refactor/lnwallet-channel-move-only
[NANO]: Move definitions into their own file
2024-07-31 06:53:19 -06:00
ziggie
0adcb5c316
docs: add release notes for 18.3. 2024-07-31 14:43:34 +02:00
ziggie
02c1264c53
multi: prevent nil panics in stop methods.
With this PR we might call the stop method even when the start
method of a subsystem did not successfully finish therefore we
need to make sure we guard the stop methods for potential panics
if some variables are not initialized in the contructors of the
subsystems.
2024-07-31 14:43:34 +02:00
Elle Mouton
be4c3dd9e4
zpay32: enforce a cipher text upper limit
To prevent an attacker from causing us to assign a huge in-memory
buffer, we place a cap on the maximum cipher text size of a blinded path
hop.
2024-07-31 14:11:00 +02:00
ziggie
e19f891453
graph: add log lines for stop and start func. 2024-07-31 13:12:20 +02:00
ziggie
598d6e23bc
lnd: change startup order of authGossiper. 2024-07-31 13:12:19 +02:00
ziggie
653e2f3667
multi: Allow interrupt of server startup.
This commit does two things. It starts up the server in a way that
it can be interrupted and shutdown gracefully.
Moreover it makes sure that subsystems clean themselves up when
they fail to start. This makes sure that depending subsytems can
shutdown gracefully as well and the shutdown process is not stuck.
2024-07-31 13:12:19 +02:00
ziggie
08b68bbaf7
multi: Add atomic start/stop functions.
Make sure that each subsystem only starts and stop once. This makes
sure we don't close e.g. quit channels twice.
2024-07-31 13:12:19 +02:00
Oliver Gugger
ac4ef28926
Merge pull request #8824 from Crypt-iQ/precise_dust_limit
multi: include commitment fees in dust calculation
2024-07-31 03:13:31 -06:00
Elle Mouton
b271922501
routing: dont use InPolicy for blinded paths
We only need the ChannelID, so no need to use the InPolicy which might
be nil.
2024-07-31 09:36:06 +02:00
Elle Mouton
8a14955a0a
docs: add release note 2024-07-31 09:36:06 +02:00
Elle Mouton
e416501802
itest: test sending MP payment over multiple blinded paths 2024-07-31 09:36:06 +02:00
Elle Mouton
e87110317b
routing: final changes to BlindedPaymentPathSet
Continue adding some complexity behind the BlindedPaymentPathSet. What
we do here is add a new IntroNodeOnlyPath method. The assumption we
make here is: If multiple blinded paths are provided to us in an invoice
but one of those paths only includes an intro node, then there is no
point in looking at any other path since we know that the intro node is
the destination node. So in such a case, we would have discarded any
other path in the `NewBlindedPaymentPathSet` constructor. So then we
would only have a single blinded path made up of an introduction node
only. In this specific case, in the `newRoute` function, no edge passed
to the function would have a blindedPayment associated with it (since
there are no blinded hops in this case). So we will have a case where
`blindedPathSet` passed to `newRoute` is not nil but `blindedPayment` is
nil since nonce was extacted from any edge. If this happens then we can
assume that this is the Intro-Node-Only situation described above. And
so we grabe the associated payment from the path set.
2024-07-31 09:15:43 +02:00
Elle Mouton
daaa24b69c
routing: let BlindedPaymentPathSet handle FinalCLTV logic
Instead of needing to remember how to handle the FinalCLTV value of a
blinded payment path at various points in the code base, we hide the
logic behind a unified FinalCLTVDelta method on the blinded path.
2024-07-31 09:15:24 +02:00
Elle Mouton
8df03de3e9
routing: swap out final hop blinded route pub keys
If multiple blinded paths are provided, they will each have a different
pub key for the destination node. This makes using our existing
pathfinding logic tricky since it depends on having a single destination
node (characterised by a single pub key). We want to re-use this logic.
So what we do is swap out the pub keys of the destinaion hop with a
pseudo target pub key. This will then be used during pathfinding. Later
on once a path is found, we will swap the real destination keys back in
so that onion creation can be done.
2024-07-31 09:14:31 +02:00
Elle Mouton
4a22ec8413
routing: pass BlindedPaymentPathSet around everywhere
Building on from the previous commit, here we pass the PathSet around
everywhere where we previously passed around the single BlindedPayment.
2024-07-31 09:14:28 +02:00
Elle Mouton
3d5f20b70f
multi: introduce BlindedPaymentPathSet
This commit introduces a new type, `BlindedPaymentPathSet`. For now, it
holds only a single `BlindedPayment` but eventually it will hold and
manage a set of blinded payments provided for a specific payment. To
make the PR easier to follow though, we start off just letting it hold a
single one and do some basic replacements.
2024-07-31 09:11:49 +02:00
ProofOfKeags
67c5fa9478
Merge pull request #8946 from ziggie1984/fix-bumpforceclose-behaviour
Fix bumpforceclose behavior for force closes without htlcs.
2024-07-30 14:42:19 -06:00
ziggie
da7b95d4a4
docs: add release-notes. 2024-07-30 20:31:29 +02:00
ziggie
cac5b32d88
itest: adapt itest for the new anchor behavior.
Now we also register anchors when no HTLCs are at stake.
2024-07-30 20:31:29 +02:00
ziggie
e413759669
contractcourt: Always register anchors with sweeper.
Even if no HTLCs are at stake we are going to register the anchor
outputs with the sweeper subsystem with a default high deadline.
We need to do this, because otherwise we are not able to bump the
fee of the closing transaction manually.
2024-07-30 20:31:29 +02:00
Keagan McClelland
82ff360ad2
lnwallet: fix linter errors resulting from commitmentChain move. 2024-07-30 10:22:23 -07:00
Keagan McClelland
4cf7555922
lnwallet: move commitChain to its own file. 2024-07-30 10:18:28 -07:00
Keagan McClelland
3e7866d85c
lnwallet: fix linter errors introduced by updateLog move 2024-07-30 10:17:47 -07:00
Oliver Gugger
7f9fbbe7c4
Merge pull request #8941 from bitromortac/fee-limit-inbound
routing: fix fee limit condition
2024-07-30 10:09:33 -06:00
Oliver Gugger
a1af505df4
Merge pull request #8948 from Filiprogrammer/docs-fix-leader-readiness-probe
docs: fix leader node readiness probe example
2024-07-30 08:54:54 -06:00
bitromortac
2edbe6b878
routing: extract getEdgeUnifiers
We split up the functionality in getRouteUnifiers into checking that all
edges exist via getEdgeUnifiers and then add a backward pass that will
be responsible for determining the sender amount.

We remove the node pub key from the error string, as in route building
this is duplicate info, which can be determined from the input keys,
further it's not available in the backward pass anymore.

We refactor the BuildRoute test to use the require library and add a
test case for a max HTLC violation on the last hop.
2024-07-30 15:49:50 +02:00
bitromortac
16f6284d97
routing: reorganize BuildRoute 2024-07-30 15:49:50 +02:00
bitromortac
0358b3a0fa
routing: use amount to send for time lock weight
The time lock weight for a hop is supposed to be proportional to the
amount that is sent/locked, but in a previous change we switched to the
net amount, where inbound fees aren't yet applied. This is corrected in
this commit.
2024-07-30 08:53:10 +02:00
bitromortac
b0f0715813
routing: fix fee limit condition
When iterating edges, pathfinding checks early whether using an edge
would violate the requested total fee limit for a route. This check is
done on the net amount (an amount the inbound fee is calculated with).
However, a possible next hop's fee discount leads to a reduction in fees
and as such using the net amount leads to assuming a higher cumulative
fee than the route really has, excluding the path erroneously. We
perform the fee limit check on the amount to send, which includes both
inbound and outbound fees. This should be possible as the first hop's
outbound fee is zero and therefore doesn't have to be checked in the
end.
2024-07-30 08:53:09 +02:00
bitromortac
557b33733c
itest: add test for failing send after queryroutes 2024-07-30 08:52:50 +02:00
bitromortac
9b3b309f2d
routing: remove unused param, log 2024-07-30 08:52:49 +02:00
Olaoluwa Osuntokun
9decf80a68
Merge pull request #8735 from ellemouton/rb-receives
[2/4] Route Blinding Receives: Receive and send to a single blinded path in an invoice.
2024-07-29 19:00:06 -07:00
Keagan McClelland
51060aed45
lnwallet: move updateLog to its own file. 2024-07-29 15:26:35 -07:00
Keagan McClelland
39db0221f0
lnwallet: move PaymentDescriptor definition to its own file 2024-07-29 15:26:35 -07:00
Filiprogrammer
060befd027
docs: fix leader node readiness probe example [skip ci]
Add the missing SERVER_ACTIVE state to the readiness probe. Without
this, a node that is ready to accept RPC calls would be incorrectly
considered not ready.
2024-07-29 21:31:24 +02:00
Eugene Siegel
74636e9bdd
release-notes: update for 0.18.3 2024-07-29 14:13:22 -04:00
Eugene Siegel
c1138af4ab
itest: modify async_bidirectional_payments itest to pass 2024-07-29 14:13:22 -04:00
Eugene Siegel
d6001d033b
htlcswitch+lnwallet: calculate fee exposure as commit fees + dust
This commit expands the definition of the dust limit to take into
account commitment fees as well as dust HTLCs. The dust limit is now
known as a fee exposure threshold. Dust HTLCs are fees anyways so it
makes sense to account for commitment fees as well. The link has
been modified slightly to calculate dust. In the future, the switch
dust calculations can be removed.
2024-07-29 14:13:21 -04:00
Oliver Gugger
b7c59b36a7
Merge pull request #8896 from ziggie1984/batchopen-feerate-fix
Fix batchopen fee calculation
2024-07-26 05:52:48 -06:00
Elle Mouton
c490279002
blindedpath: smarter dummy hop policy selection
This commit introduces more sophisticated code for selecting dummy hop
policy values for dummy hops in blinded paths.

For the case where the path does contain real hops, the dummy hop policy
values are derived by taking the average of those hop polices. For the
case where there are no real hops (in other words, we are the
introduction node), we use the default policy values used for normal
ChannelUpdates but then for the MaxHTLC value, we take the average of
all our open channel capacities.
2024-07-26 13:03:07 +02:00
ziggie
eb7818a633
docs: add release-notes. 2024-07-26 10:48:00 +02:00
ziggie
bf38aed87f
lnd: unify the default setting behaviour.
Setting default values for the channel opening fee rate is already
done elsewhere therefore we remove on of those checks and return
an error if no fee rate is specified.
2024-07-26 10:48:00 +02:00
ziggie
d0a7765c68
rpcserver: include fee calc. for psbt flow.
Include the fee calculaltion for the psbt flow. Moreover include
fee rate testing in the itest environment.
2024-07-26 10:48:00 +02:00
Elle Mouton
60a856ab65
record/routing: set minimum padding size 2024-07-26 10:32:47 +02:00
Elle Mouton
398623bde5
blindedpath: move blinded path logic to own pkg 2024-07-26 09:54:59 +02:00
Elle Mouton
c62a9c235e
itest: test blinded paths over private channels 2024-07-26 09:54:38 +02:00
Elle Mouton
74e45ec4bf
docs: update release notes 2024-07-26 09:54:38 +02:00
Elle Mouton
66765de413
itest: add route blinding dummy hops test
Add an itest that tests the addition of dummy hops to a blinded path. By
testing that invoices containing such a path can be paid, it also tests
the peeling of dummy hops by the receiver.
2024-07-26 09:54:38 +02:00
Elle Mouton
f0558babf3
multi: send MPP payment to blinded path
Make various sender side adjustments so that a sender is able to send an
MP payment to a single blinded path without actually including an MPP
record in the payment.
2024-07-26 09:54:38 +02:00
Elle Mouton
64a99d4a8e
itest: end to end route blinding invoices test
Update one of the route blinding itests to do a full end-to-end test
where the recipient generates and invoice with a blinded path and the
sender just provides that invoice to SendPayment.

The tests also covers the edge case where the recipient is the
introduction node.
2024-07-26 09:54:38 +02:00
Elle Mouton
735d7d9738
multi: send to a blinded path in an invoice
Update the SendPayment flow so that it is able to send to an invoice
containing a blinded path.
2024-07-26 09:54:37 +02:00
Elle Mouton
34d8fff5f9
itest: update route blind tests
The route blinding itests are now updated so that recipient logic is
tested. The creation of a blinded route is also now done through the
AddInvoice API instead of manually.
2024-07-26 09:54:18 +02:00
Elle Mouton
65aef6a69c
htlcswitch: handle blinded path dummy hops
If a blinded path payload contains a signal that the following hop on
the path is a dummy hop, then we iteratively peel the dummy hops until
the final payload is reached.
2024-07-26 09:54:18 +02:00
Elle Mouton
b0d3e4dc0d
multi: extract path ID and total amt from received payment
We've covered all the logic for building a blinded path to ourselves and
putting that into an invoice - so now we start preparing to actually be
able to recognise the incoming payment as one from a blinded path we
created.

The incoming update_add_htlc will have an `encrypted_recipient_data`
blob for us that we would have put in the original invoice. From this we
extract the PathID which we wrote. We consider this the payment address
and we use this to derive the associated invoice location.

Blinded path payments will not include MPP records, so the payment
address and total payment amount must be gleaned from the pathID and new
totalAmtMsat onion field respectively.

This commit only covers the final hop payload of a hop in a blinded
path. Dummy hops will be handled in the following commit.
2024-07-26 09:54:18 +02:00
Elle Mouton
3d9c77d1fc
htlcswitch+refactor: add rHash and sphinx.Router to sphinxHopIterator
This will be required to construct a new hop iterator for when peeling
of dummy hops is done for route blinding.
2024-07-26 09:54:18 +02:00
Elle Mouton
c1c2e1c6ce
htlcswitch+refactor: continue modularising extractTLVPayload
We further break up the extracTLVPayload into more modular pieces. The
pieces are structured in such a way as to prepare for extracTLVPayload
being called in a recursive manner from within
`deriveBlindedRouteForwardingInfo` when we add the logic for handling
dummy hops in a later commit. With this refactor, we completey remove
the BlindingKit's DecryptAndValidateFwdInfo method.
2024-07-26 09:54:18 +02:00
Elle Mouton
55c25f427f
htlcswitch+refactor: continue modularising extractTLVPayload
In this refactor commit, we extract all the steps from extractTLVPayload
that have to do with parsing the payload from the sender and verifying
the presence of various fields from the sender.
2024-07-26 09:54:18 +02:00
Elle Mouton
a15e4bb55f
refactor+htlcswitch: method for TLV payload parsing logic
In preparation for calling the TLV payload parsing logic recursively for
when we need to peel dummy hops from an onion, this commit creates a new
extractTLVPayload function. This is a pure refactor.
2024-07-26 09:54:18 +02:00
Elle Mouton
18cb7f0b87
lncli: add --blind option to addinvoice
In this commit, we expose the option to create an invoice containing
blinded paths to lncli.
2024-07-26 09:54:18 +02:00
Elle Mouton
de975334cd
multi: add blinded paths to invoices
Expose the ability to add blinded paths to an invoice. Also expose
various configuration values.

We also let the lncfg.Invoices struct satisfy the Validator interface so
that we can verify all its config values in one place.
2024-07-26 09:54:17 +02:00
Elle Mouton
e12a226272
routing: use mission control to select blinded paths
Add a `FindBlindedPaths` method to the `ChannelRouter` which will use
the new `findBlindedPaths` function to get a set of candidate blinded
path routes. It then uses mission control to select the best of these
paths.

Note that as of this commit, the MC data we get from these queries won't
mean much since we wont have data about a channel in the direction
towards us. But we do this now in preparation for a future PR which will
start writing mission control success pairs for successful receives from
blinded route paths.
2024-07-26 09:54:17 +02:00
Elle Mouton
1039aedd0c
routing: find blinded paths to a destination node
This commit adds a new function, `findBlindedPaths`, that does a depth
first search from the target node to find a set of blinded paths to the
target node given the set of restrictions. This function will select and
return any candidate path. A candidate path is a path to the target node
with a size determined by the given hop number constraints where all the
nodes on the path signal the route blinding feature _and_ the
introduction node for the path has more than one public channel. Any
filtering of paths based on payment value or success probabilities is
left to the caller.
2024-07-26 09:54:17 +02:00
Elle Mouton
9787ae9c89
lnrpc/invoicesrpc: prep AddInvoice for blinded routes
Here we add a new `Blind` option to the `AddInvoiceData` which will
signal that the new invoice should encode a blinded route.

Certain other changes are also made in the case that this invoice
contains a blinded route:
1) the payment address/secret no longer needs to be in the invoice
   itself since it will be put in the `PathID` recored of the encrypted
   recipient record for our hop.
2) When we sign the invoice, we now use an ephemeral key since we dont
   want the sender to be able to derive our real node pub key from the
   invoice signature.
3) The invoice's FinalCLTV field should be zero for blinded invoices
   since the CLTV delta info will be communicated in the accumulated
   route policy values.
2024-07-26 09:54:17 +02:00
Elle Mouton
4b5327f057
lnrpc/invoicesrpc: build blinded path
This commit adds all the logic for building a blinded path (from a given
route) and packaging it up in a zpay32.BlindedPaymentPath struct so that
it is ready for adding to an invoice. It also includes logic for padding
a path with dummy hops.

Note that in this commit, the logic for choosing an actual path to us
that can then be used in a blinded path is abstracted away. This logic
will be fleshed out in a future commit.
2024-07-26 09:54:17 +02:00
Elle Mouton
0855e3e71a
lnrpc/invoicesrpc: add blinded path policy buffer
This commit adds a helper function that will be used to adjust a hops
policy values by certain given increase and decrease multipliers. This
will be used in blinded paths to give policy values some buffer to avoid
easy probing of blinded paths.
2024-07-26 09:54:17 +02:00
Elle Mouton
3b2a6042ff
lnrpc/invoicesrpc: blinded path total path policy calc
This commit adds a function that can be used to compute the accumulated
path policy for a blinded path as defined in the spec:

db278ab9b2/04-onion-routing.md (L255)
2024-07-26 09:54:17 +02:00
Elle Mouton
f87cc6274f
lnrpc/invoicesrpc: add function for padding encrypted data
This commit adds a helper function called `padHopInfo` along with a test
for it. This function will be used later on when building a blinded
path. It is used to ensure that all encrypted blobs of a blinded path
that we construct are padded to the same size.
2024-07-26 09:54:16 +02:00
Elle Mouton
4457ca2e66
record: stricter type for PaymentRelayInfo.BaseFee
In this commit, we update the PaymentRelayInfo struct's BaseFee member
to use a stricter type (lnwire.MilliSatoshi) instead of an ambigious
uint32.
2024-07-26 09:53:49 +02:00
Elle Mouton
62a97f86dd
record: add NextNodeID type to BlindedRouteData
Add the NextNodeID TLV (tlv type 4) to the BlindedRouteData TLV stream.
This will be used during the dummy hop payload construction.
2024-07-26 09:53:49 +02:00
Elle Mouton
9192c165ff
feature: define new feature bit for bolt11 blinded paths
We need a new feature bit for BOLT11 invoices in order to indicate that
they contain the new blinded path tagged field. Tagged fields pre-date
TLV and so nodes who dont understand them will simply skip them.
Therefore the feature bit helps them to fail fast.
2024-07-26 09:53:49 +02:00
Elle Mouton
188dd44b42
zpay32: improve readability of blinded path encoding 2024-07-26 09:53:49 +02:00
Elle Mouton
4f5dd20f7e
go.mod: update lightning-onion dep 2024-07-26 09:53:48 +02:00
Olaoluwa Osuntokun
8c0d7862c2
Merge pull request #8937 from Roasbeef/go-1-22-5
build: update to Go 1.22.5
2024-07-25 13:14:57 -07:00
Olaoluwa Osuntokun
bc2922232c
build: remove old Travis references
We no longer use Travis.
2024-07-25 13:14:26 -07:00
Oliver Gugger
b40f165310
Merge pull request #8891 from yyforyongyu/fix-fee-estimator
chainfee: allow specifying min relay feerate from the API source
2024-07-25 11:40:18 -06:00
yyforyongyu
d992cf94d6
multi: add SpewLogClosure to avoid code repetition 2024-07-25 22:18:49 +08:00
yyforyongyu
b6049ff94b
multi: add NewLogClosure in lnutils to avoid repetition
And replaces all usage of `logClosure` with `lnutils.LogClosure`.
2024-07-25 21:25:23 +08:00
Olaoluwa Osuntokun
9e2b308f93
build: update to Go 1.22.5 2024-07-24 14:21:13 -07:00
yyforyongyu
7e60d41898
chainfee: make sure web API has been started before estimating
Previously we may get a floor feerate when calling `EstimateFeePerKW`
due to the fee estimator not finishing its startup process, which gives
us an empty fee map.

This is now fixed to return an error if the estimator is not started.
2024-07-24 20:05:00 +08:00
yyforyongyu
0a0d51ce22
docs: update release notes 2024-07-24 20:05:00 +08:00
yyforyongyu
a1d71afde8
lntest: allow specifying min relay feerate in itest 2024-07-24 20:05:00 +08:00
yyforyongyu
ce43e4bab7
chainfee: allow specifying min relay feerate from API source
This commit adds a new expected field, `min_relay_feerate`, in the
response body returned from the API source, allowing the API to specify
a min relay feerate to be used instead of the FeePerKwFloor.

This change is backwards compatible as for an old API source which
doesn't specify the `min_relay_feerate`, it will be interpreted as zero.
2024-07-24 20:05:00 +08:00
Oliver Gugger
b10ebb2692
Merge pull request #8923 from yyforyongyu/fix-test-interface
chainntnfs+lntest: fix `TestInterfaces`
2024-07-24 05:57:07 -06:00
yyforyongyu
48a0efe40c
bitcoindnotify: add debug logs in unit test 2024-07-24 18:05:06 +08:00
yyforyongyu
9fee656d70
chainntnfs+lntest: fix TestInterfaces
This commit upgrades the test to always use a segwit v0 witness program
when creating testing txns.
2024-07-24 17:43:27 +08:00
Olaoluwa Osuntokun
6f37db3a92
Merge pull request #8927 from guggero/fix-release-script
GitHub: update vendored release script
2024-07-23 15:16:09 -07:00
Oliver Gugger
f27f9f2799
Merge pull request #8892 from lightningnetwork/yy-itest-miner
Beat [0/4]: improve itest miner
2024-07-23 12:12:36 -06:00
Oliver Gugger
0387a1edfb
mod: bump fn to v1.2.0
This fixes the Coverage CI step by making sure the file system is in
sync with the files pulled in through a Go submodule.
2024-07-23 20:02:47 +02:00
yyforyongyu
91807625bb
itest: fix testUnconfirmedChannelFunding for neutrino
This test was previously working because we'd mine an extra block to
confirm the coins inside `FundCoinsUnconfirmed` when it's a neutrino
backend, as shown in
fdd28c8d88/lntest/harness.go (L1431)
Since neutrino has trouble seeing unconfirmed balance, we now send some
coins to the wallet, confirm those, then do a self-transfer so the node
will have unconfirmed outputs to perform the test.
2024-07-23 21:53:51 +08:00
yyforyongyu
2d21aa3718
docs: update release notes 2024-07-23 21:30:09 +08:00
yyforyongyu
4dcce9df69
lntest+itest: fix flakes found using neutrino backend
This commit makes sure the sweep requests are received before mining
blocks to trigger the actual sweeping.

In addition, `testFundingExpiryBlocksOnPending` is updated to deal with
the old `channel link not found` issue.
2024-07-23 21:30:09 +08:00
yyforyongyu
2608c0893e
multi: make sure missionControlStore catches done signal
This commit makes sure `missionControlStore` catches the shutdown signal
when draining the ticker. A few debug logs are added to aid the process.
2024-07-23 21:30:08 +08:00
yyforyongyu
50279464ad
itest: remove unused param in chanRestoreViaRPC 2024-07-23 21:30:08 +08:00
yyforyongyu
623f816f8e
lntest: remove redundant nodes shutdown
The nodes are already shut down in the `Cleanup` in `ht.Subtest` so
there's no need to shutdown them again.
2024-07-23 21:30:08 +08:00
yyforyongyu
8240a87c2b
itest: fix misuse of MineBlocks and replace it with
`MineBlocksAndAssertNumTxes`
2024-07-23 21:30:08 +08:00
yyforyongyu
f1f341095e
lntest+itest: add new method CurrentHeight 2024-07-23 21:30:08 +08:00
yyforyongyu
14e7b134d9
lntest+itest: make Miner a private instance 2024-07-23 21:30:08 +08:00
yyforyongyu
be4dba5da6
lntest+itest: finalize moving miner methods 2024-07-23 21:30:07 +08:00
yyforyongyu
6bd8baea38
lntest+itest: continue removing direct call to Miner 2024-07-23 21:30:07 +08:00
yyforyongyu
976bb37972
lntest+itest: add method AssertNumTxsInMempool and AssertTxInBlock
in harness

Prepare to make `HarnessTest.Miner` a private instance to sync height.
2024-07-23 21:30:07 +08:00
yyforyongyu
e553895ddd
lntest+itest: strictly define the behavior of MineBlocks
This commit adds more assertion to `MineBlocks` so the caller won't
misuse it.
2024-07-23 21:30:07 +08:00
yyforyongyu
91b20e661b
lntest: move mining methods into one file 2024-07-23 21:30:07 +08:00
yyforyongyu
a881477404
lntest: create new package lntest/miner for itest miner
This commit moves the `HarnessMiner` into a new package to avoid
confusion about incoming changes.
2024-07-23 21:30:07 +08:00
Oliver Gugger
154a8af078
GitHub: update vendored release script
This fixes the problem where releases wouldn't be created anymore due to
the GitHub Action for creating the draft release being out of date.
2024-07-23 14:49:05 +02:00
Oliver Gugger
578e1d4965
Merge pull request #8881 from mwaite-codes/fix-doc-grammar
Fix various typos in docs for readability
2024-07-23 00:25:17 -06:00
Marcia Waite
e6dca0ce6e multi: Fix typos and grammar in multiple docs 2024-07-22 20:08:12 -07:00
Oliver Gugger
fa9929cd43
Merge pull request #8925 from guggero/remove-coin-join
docs: update safety.md, remove specific CoinJoin implementations
2024-07-22 01:05:05 -06:00
LeoSpyke
ec1c42677a
docs: update safety.md, remove specific CoinJoin impl
Remove dead conjoin implementations.

[skip ci]
2024-07-22 08:54:33 +02:00
Oliver Gugger
608c0c41b9
Merge pull request #8921 from guggero/wallet-update
btcwallet: bump dependency to fix duplicate address creation
2024-07-19 02:43:58 -06:00
Oliver Gugger
9d4ed6d6e6
docs: update release notes 2024-07-19 08:33:56 +02:00
Oliver Gugger
19a4b51a92
mod: bump btcwallet dependency 2024-07-19 08:33:56 +02:00
Olaoluwa Osuntokun
6dea86428d
Merge pull request #8879 from ProofOfKeags/bugfix/taproot-coop-sequence
contractcourt: Taproot Channel Bugfixes
2024-07-18 16:24:44 -07:00
Keagan McClelland
09f5e08d32
contractcourt: Fix heuristic for identifying STC commit broadcaster.
This commit fixes the heuristic we use for identifying the party
that broadcast a Simple Taproot Channel commitment transaction.

Prior to this change we checked if the last script element was an
OP_DROP. However, both the local and remote commitment outputs
have an OP_DROP at the end.

The new approach checks the resolver's SignDescriptor and compares
that key to the keys in the channel's local ChannelConfig. If the
key is the delay key, we know that it is our commitment transaction.
2024-07-17 14:57:28 -07:00
Keagan McClelland
31d45757a4
contractcourt: properly detect RBF coop close transactions
This commit fixes an issue where we did not properly detect and
therefore record the coop close transaction if it used the newer
RBF coop close v2 scheme. This only affects coop closes of
taproot channels today.
2024-07-17 14:48:20 -07:00
Oliver Gugger
fdd28c8d88
Merge pull request #8915 from linghuying/master
chore: fix some comments for struct field
2024-07-16 08:40:33 -06:00
Oliver Gugger
fae7e0c5b0
Merge pull request #8848 from ellemouton/graphManager
refactor: move graph responsibilities from routing.ChannelRouter to new graph.Builder
2024-07-16 00:54:00 -06:00
linghuying
91930d4ab8 chore: fix some comments for struct field
Signed-off-by: linghuying <1599935829@qq.com>
2024-07-16 11:44:35 +08:00
Elle Mouton
b112e10bf2
docs: update release notes
Also move incorrect entry from 18.2 to 18.3
2024-07-15 15:56:33 +02:00
Elle Mouton
d1c54d74a8
routing: close graph session if getBandwidthHints fails
Ensure that the graph session used during pathfinding is properly closed
if the call to getBandwidthHints fails.
2024-07-15 15:56:33 +02:00
Elle Mouton
90dff730ce
graph: updated builder to use atomic ints
Instead of relying on devs to remember that they must only be accessed
atomically.
2024-07-15 15:56:33 +02:00
Elle Mouton
fe34d62eb1
graph+routing: address linter errors
This is done in a separate commit so as to keep the original code-move
commit mostly a pure code move.
2024-07-15 15:56:33 +02:00
Elle Mouton
743502f99d
funding: rename from router graph to graph 2024-07-15 15:56:33 +02:00
Elle Mouton
9327a83cd2
discovery: rename Gossiper graph dep 2024-07-15 15:56:33 +02:00
Elle Mouton
7f1be39d45
refactor: move various duties from ChannelRouter to graph.Builder
This commit is a large refactor that moves over various responsibilities
from the ChannelRouter to the graph.Builder. These include all graph
related tasks such as:
- graph pruning
- validation of new network updates & persisting new updates
- notifying topology update clients of any changes.

This is a large commit but:
- many of the files are purely moved from `routing` to `graph`
- the business logic put in the graph Builder is copied exactly as is
  from the ChannelRouter with one exception:
- The ChannelRouter just needs to be able to call the Builder's
  `ApplyChannelUpdate` method. So this is now exported and provided to
the ChannelRouter as a config option.
- The trickiest part was just moving over the test code since quite a
  bit had to be duplicated.
2024-07-15 15:56:33 +02:00
Elle Mouton
0b7364f54b
graph+server: add template for new graph Builder sub-system
This is preparation for an upcoming commit that will move over various
responsibilities from the ChannelRouter to the graph Builder. So that
that commit can be a pure code-move commit, the template for the new
sub-system is added up front here.
2024-07-15 15:56:33 +02:00
Elle Mouton
30e6671a13
routing: use new graph.DB interface in ChannelRouter 2024-07-15 15:13:58 +02:00
Elle Mouton
be84d6974e
channeldb: add a graph.DB interface
..which describes the database methods that are required for graph
maintaining and building.
2024-07-15 15:13:58 +02:00
Elle Mouton
c1d7a9d2e7
multi: move ChannelGraphSource interface
... to the new `graph` package in preparation for the implementation of
the interface being moved to this new package.
2024-07-15 15:13:58 +02:00
Elle Mouton
e9c89ae0ec
multi+refactor: create ForEachNodeChannel with no tx param
In prep for a clean Graph DB interface, we add a version of
ForEachNodeChannel that does not take in an existing db transaction.
2024-07-15 15:13:58 +02:00
Elle Mouton
c20d759d41
refactor: create FetchLightningNode with no tx param
In preparation for adding a clean Graph DB interface, we create a
version of FetchLightningNode that doesnt allow a caller to provide in a
transaction.
2024-07-15 15:13:57 +02:00
Elle Mouton
71e93526d6
multi+refactor: let FetchChanInfos not take tx
In preparation for having a clean graph DB interface, refactor
FetchChanInfos so that no transaction can be provided.
2024-07-15 15:13:57 +02:00
Elle Mouton
cf3de72503
routing: let SelfNode be passed via config
Instead of querying it from the graph since this will be removed in a
future commit.
2024-07-15 15:13:57 +02:00
Elle Mouton
8c0df98439
multi: add abstraction for Router and SessionSource graph access
In this commit, we completely remove the Router's dependence on a Graph
source that requires a `kvdb.RTx`. In so doing, we are more prepared for
a future where the Graph source is backed by different DB structure such
as pure SQL.

The two areas affected here are: the ChannelRouter's graph access that
it uses for pathfinding. And the SessionSource's graph access that it
uses for payments.

The ChannelRouter gets given a Graph and the SessionSource is given a
GraphSessionFactory which it can use to create a new session. Behind the
scenes, this will acquire a kvdb.RTx that will be used for calls to the
Graph's `ForEachNodeChannel` method.
2024-07-15 15:13:57 +02:00
Elle Mouton
90d6b863a8
routing+refactor: remove the need to give CachedGraph source node access
In preparation for the next commit.
2024-07-15 13:10:24 +02:00
Elle Mouton
3f121cbe81
routing: rename and export routingGraph
In preparation for structs outside of the `routing` package implementing
this interface, export `routingGraph` and rename it to `Graph` so as to
avoid stuttering.
2024-07-15 13:10:24 +02:00
Elle Mouton
5a903c270f
routing: remove sourceNode from routingGraph interface
In this commit, we further reduce the routingGraph interface and this
time we make it more node-agnostic so that it can be backed by any graph
and not one with a concept of "sourceNode".
2024-07-15 13:10:24 +02:00
Elle Mouton
5c18b5a042
routing: remove un-used method from routingGraph interface
We really want to narrow down the interface we provide the router, so
let's start here.
2024-07-15 13:10:23 +02:00
Olaoluwa Osuntokun
09b38aaa01
Merge pull request #8653 from ProofOfKeags/fn-prim
DynComms [0/n]: `fn` package additions
2024-07-12 17:30:15 -07:00
Olaoluwa Osuntokun
f464dac1cd
Merge pull request #8752 from ellemouton/rb-receives-setup
[1/4] Route Blinding Receives: Groundwork
2024-07-10 18:27:11 -07:00
Keagan McClelland
eaa5e4a039
fn: remove redundant Reduce function
This commit removes Reduce since we already have both Foldl and Foldr.
2024-07-10 17:06:09 -07:00
Keagan McClelland
fa2e25d5f4
fn: remove lru dependency 2024-07-10 17:06:04 -07:00
Keagan McClelland
364d79e552
fn: add generic version of List 2024-07-10 16:55:29 -07:00
Keagan McClelland
fb1437cb6d
fn: add Elem function for set membership 2024-07-10 15:37:27 -07:00
Keagan McClelland
9c30bce10c
fn: add curried (in)equality functions 2024-07-10 15:37:27 -07:00
Keagan McClelland
c4df2f1dce
fn: reimplement internals of either, add tests 2024-07-10 15:37:27 -07:00
Keagan McClelland
1dd56f1b2a
fn: fix and finish the either API 2024-07-10 15:37:27 -07:00
Keagan McClelland
c3603ccf96
fn: add FindIdx function 2024-07-10 15:34:57 -07:00
Keagan McClelland
5902aa5159
fn: add concurrent map operation for slices 2024-07-10 15:29:16 -07:00
Keagan McClelland
94acbe90a8
fn: add fundamental functional primitives 2024-07-10 14:42:11 -07:00
Oliver Gugger
f2759dcb1a
Merge pull request #8759 from largemouth/master
chore: fix some function names
2024-07-10 12:16:49 -06:00
Elle Mouton
85ddffb17d
docs: update release notes 2024-07-10 17:51:56 +02:00
Elle Mouton
cd3da40fb9
routing: dont include final hop cltv in blinded path
Only include the final hop's cltv delta in the total timelock
calculation if the route does not include a blinded path. This is
because in a blinded path, the final hops final cltv delta will be
included in the blinded path's accumlated cltv delta value.

With this commit, we remove the responsibility of remembering not to set
the `finalHop.cltvDelta` from the caller of `newRoute`. The relevant
test is updated accordingly.
2024-07-10 17:51:56 +02:00
Elle Mouton
93f89512ae
lnrpc+rpcserver: Add blinded payment paths to PayReq
This commit adds a blinded_paths field to the PayReq proto message. A
new helper called `CreateRPCBlindedPayments` is then added to convert
the zpay32 type to the existing `lnrpc.BlindedPaymentPath` type and add
this to the `PayReq` in the `DecodePayReq` rpc method.
2024-07-10 17:51:55 +02:00
Elle Mouton
f6a54c2ede
zpay: encoding and decoding of a BlindedPaymentPath
In this commit, the ability is added to encode blinded payment paths and
add them to a Bolt 11 invoice.
2024-07-10 17:51:55 +02:00
Elle Mouton
9ada4a9068
record: add Padding field to BlindedRouteData
When we start creating blinded paths to ourselves, we will want to be
able to pad the data for each hop so that the `encrypted_recipient_data`
for each hop is the same. We add a `PadBy` method that allows a caller
to add a certain number of bytes to the padding field. Note that adding
n bytes won't always mean that the encoded payload will increase by size
n since there will be overhead for the type and lenght fields for the new
TLV field. This will also be the case when the number of bytes added
results in a BigSize bucket jump for TLV length field. The
responsibility of ensuring that the final payloads are the same size is
left to the caller who may need to call PadBy iteratively to achieve the
goal. I decided to leave this to the caller since doing this at the
actual TLV level will be quite intrusive & I think it is uneccessary to
touch that code for this unique use case.
2024-07-10 09:12:40 +02:00
Elle Mouton
15f3cce27d
record: add PathID to BlindedRouteData
Add the PathID (tlv type 6) field to BlindedRouteData. This will be used
for the final hop of a blinded route. A new constructor is also added
for BlindedRouteData which can specifically be used for the final hop.
2024-07-10 09:12:40 +02:00
Elle Mouton
ad0905f10e
record+htlcswitch: convert BlindedRouteData fields to optional
For the final hop in a blinded route, the SCID and RelayInfo fields will
_not_ be set. So these fields need to be converted to optional records.

The existing BlindedRouteData constructor is also renamed to
`NewNonFinalBlindedRouteData` in preparation for a
`NewFinalBlindedRouteData` constructor which will be used to construct
the blinded data for the final hop which will contain a much smaller set
of data. The SCID and RelayInfo parameters of the constructor are left
as non-pointers in order to force the caller to set them in the case
that the constructor is called for non-final nodes. The other option
would be to create a single constructor where all parameters are
optional but I think this makes it easier for the caller to make a
mistake.
2024-07-10 09:12:39 +02:00
Elle Mouton
925b68c1ed
routing: add BlindedPayment to unifiedEdge
Later on in this series, we will need to know during path finding if an
edge we are traversing was derived from a blinded payment path. In
preparation for that, we add a BlindedPayment member to the
`unifiedEdge` struct.

The reason we will need this later on is because: In the case where we
receive multiple blinded paths from the receipient, we will first swap
out the final hop node of each path with a single unified target node so
that path finding can work as normal. Once we have selected a route
though, we will want to know which path an edge belongs to so that we
can swap the correct destination node back in.
2024-07-10 09:12:39 +02:00
Elle Mouton
1ec2a1be11
routing+refactor: add a constructor for unifiedEdge
Add a constructor for unified edge. In upcoming commits, we will add a
new member to unifiedEdge and a constructor forces us to not forget to
populate a required member.
2024-07-10 09:12:39 +02:00
Elle Mouton
28d1227c04
routing: add BlindedPayment() method to AdditionalEdges
Expand the AdditionalEdges interface with a BlindedPayment method. In
upcoming commits, we will want to know if an AdditionalEdge was derived
from a blinded payment or not and we will also need some information
from the blinded payment it was derived from. So we expand the interface
here to avoid needing to do type casts later on. The new method may
return nil if the edge was not derived from a blinded payment.
2024-07-10 09:12:39 +02:00
Elle Mouton
f7a9aa875e
routing+refactor: let BlindedEdge carry BlindedPayment
This commit is purely a refactor. In it, we let the `BlindedEdge` struct
carry a pointer to the `BlindedPayment` that it was derived from. This
is done now because later on in the PR series, we will need more
information about the `BlindedPayment` that an edge was derived from.

Since we now pass in the whole BlindedPayment, we swap out the
`cipherText` member for a `hopIndex` member so that we dont carry around
two sources of truth in the same struct.
2024-07-10 09:12:39 +02:00
Oliver Gugger
a9655357ca
Merge pull request #8855 from bhandras/invoice-expiry-migration
sqldb+invoices: fix incorrectly stored invoice expiries when using native SQL
2024-07-09 02:06:28 -06:00
Andras Banki-Horvath
053faa6229
docs: update release notes for 0.18.3-beta 2024-07-09 08:39:58 +02:00
Andras Banki-Horvath
d0c1cec8c1
sqldb: switch away from pq to pgx for Postgres
Completely switch to the better maintained pgx driver.
2024-07-09 08:39:58 +02:00
Andras Banki-Horvath
95b99420fa
sqldb: add unit test for the invoice expiry migration 2024-07-09 08:39:57 +02:00
Andras Banki-Horvath
ed36598504
sqldb: add helpers to create test DBs migrated up to a select version 2024-07-09 08:39:57 +02:00
Andras Banki-Horvath
5292c76e10
sqldb: extract migration into method
Based on: https://github.com/lightninglabs/taproot-assets/pull/707
2024-07-09 08:39:57 +02:00
Andras Banki-Horvath
323af946e0
sqldb+invoices: add migration to fix incorrectly stored invoice expiries
Previously, when using the native schema, invoice expiries were incorrectly
stored as 64-bit values (expiry in nanoseconds instead of seconds), causing
overflow issues. Since we cannot determine the original values, we will set
the expiries for existing invoices to 1 hour with this migration.
2024-07-09 08:39:57 +02:00
Yong
3526f82b5d
Merge pull request #8887 from yyforyongyu/fix-err-match
multi: fix `lnwallet.ErrDoubleSpend`
2024-07-08 14:09:07 +08:00
rockstardev
d946972ac8 Updating README 2024-07-07 08:18:03 -05:00
rockstardev
c28190c73b Documenting LND update process 2024-07-07 08:11:14 -05:00
rockstardev
a309bbbbf0 Merge branch 'lnd/v0.18.1-beta' and Update README
# Conflicts:
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
2024-07-07 08:05:27 -05:00
rockstardev
fc7b2c1d59 Merge branch 'lnd/v0.18.0-beta' and Update README
# Conflicts:
#	.github/workflows/main.yml
#	Makefile
#	README.md
#	build/version.go
#	contractcourt/channel_arbitrator.go
#	docs/release-notes/release-notes-0.17.4.md
#	go.mod
#	go.sum
#	htlcswitch/link.go
#	itest/list_on_test.go
#	itest/lnd_channel_backup_test.go
#	itest/lnd_channel_force_close_test.go
#	itest/lnd_multi-hop_test.go
#	itest/lnd_onchain_test.go
#	itest/lnd_open_channel_test.go
#	itest/lnd_psbt_test.go
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
#	lncfg/config.go
#	lncfg/dev.go
#	lncfg/dev_integration.go
#	lnrpc/walletrpc/walletkit.pb.go
#	lntest/harness.go
#	lnwallet/channel.go
#	lnwallet/channel_test.go
#	peer/brontide.go
#	peer/brontide_test.go
#	peer/test_utils.go
#	server.go
#	sweep/sweeper.go
#	sweep/tx_input_set.go
#	sweep/txgenerator.go
2024-07-07 08:04:55 -05:00
rockstardev
6495ab7066 Updating README 2024-07-07 08:03:26 -05:00
rockstardev
9f94d045ae Adding BtcPayServer related files and resources 2024-07-07 06:11:06 -05:00
yyforyongyu
e27a656c07
docs: add release notes for 0.18.3 2024-07-06 14:01:40 +08:00
yyforyongyu
26a365eb32
docs: update release notes 2024-07-06 13:59:28 +08:00
yyforyongyu
8f4bcd0b3a
lnwallet: fix ErrDoubleSpend 2024-07-06 13:59:28 +08:00
yyforyongyu
ddf46f435c
multi: update RPC error import path
These errors are now defined in `btcwallet/chain` instead of
`btcd/rpcclient`.
2024-07-06 13:59:28 +08:00
yyforyongyu
e0a506ab26
multi: use chain.MapRPCErr instead of rpcclient.MapRPCErr 2024-07-06 13:59:25 +08:00
yyforyongyu
1d40c55550
gomod: update btcwallet to include RPC errors 2024-07-06 13:55:12 +08:00
Elle
d7e0f69f34
Merge pull request #8854 from bhandras/invoices-limit-offset-fixup
invoices: fix SQL invoice query pagination
2024-07-04 21:26:56 +02:00
Andras Banki-Horvath
b35f0606ba
docs: update release notes for 0.18.2-beta 2024-07-04 17:32:12 +02:00
Andras Banki-Horvath
892561f8f0
sqldb: bump modernc.org/sqlite to 1.29.10 which fixes init data race
Tracking issue: https://gitlab.com/cznic/sqlite/-/issues/180
2024-07-04 17:32:12 +02:00
Andras Banki-Horvath
e45ed86263
invoices: fix and correctly cover paginated queries
Previously paginated queries offseted the add_index_get, add_index_let,
settle_index_get and settle_index_let parameters with the paginators
current page offset, however this was incorrect as we can just use
SQL's LIMIT/OFFSET to paginate. This commit fixes this issue and adds an
optional parameter to the constructor of the invoice SQL store to set
page size. This is useful when testing as we can now cover pagination
correctly with our existing unit tests.
2024-07-04 17:32:11 +02:00
Elle
71ba355d90
Merge pull request #8796 from ellemouton/acceptImplicitZeroConf
multi: allow min-depth of zero for non-zero conf channels
2024-06-28 07:19:46 -07:00
Elle Mouton
9d1320a2d0
docs: add release notes entry 2024-06-27 15:27:23 -07:00
Elle Mouton
1c65c3d072
funding: allow AcceptChannel with min depth of zero
Even if the channel type is not zero conf. We will still use a min depth
of at least 1. We just dont fail if our peer indicates trust.
2024-06-27 15:26:34 -07:00
Oliver Gugger
c34c0426fa
Merge pull request #8874 from ellemouton/assumeTLV2
routing: remove left over TLV feature bit checks
2024-06-27 01:34:54 -06:00
Oliver Gugger
3ceb7d5887
docs: update release notes 2024-06-26 14:30:28 -07:00
Oliver Gugger
b300da8446
routing: assume TLV payloads everywhere
This commit removes another check for TLV payload support of the
destination node. We assume TLV payloads as the default everywhere else,
so we just remove two checks that were previously forgotten.
2024-06-26 14:28:51 -07:00
Olaoluwa Osuntokun
42b856dbb9
Merge pull request #8866 from ellemouton/0-18-1-fix
build: create v0.18.1-beta release branch
2024-06-25 15:34:32 -07:00
Oliver Gugger
f695451da0
build: bump version to v0.18.1-beta 2024-06-25 13:54:50 -07:00
yyforyongyu
362182bd88
docs: update release notes for 0.18.1-beta 2024-06-25 13:46:56 -07:00
yyforyongyu
e34702ab5b
mod: update btcd and btcwallet versions 2024-06-25 13:46:56 -07:00
Oliver Gugger
ce813276d5
Merge pull request #8862 from yyforyongyu/fix-publish-err
Fix an error string match between different `btcd` versions
2024-06-25 12:40:39 -06:00
yyforyongyu
7fd099b146
docs: update release notes and add notes for 0.18.2 2024-06-26 01:44:00 +08:00
yyforyongyu
3b4106ca00
mod: update btcd and btcwallet versions 2024-06-26 00:41:17 +08:00
Elle
6b64703db4
Merge pull request #8791 from ellemouton/assumeTLV
routing: assume TLV onion feature bit
2024-06-24 11:03:33 -07:00
Elle Mouton
738206fa96
docs: add release notes entry 2024-06-24 10:01:41 -07:00
Elle Mouton
99b3c57b7f
routing: assume TLV onion during route construction 2024-06-24 10:01:23 -07:00
Elle Mouton
738253f5e1
routing: assume TLV onion during path finding 2024-06-24 10:01:21 -07:00
Oliver Gugger
fb416c2fa2
Merge pull request #8856 from AbelLykens/patch-1
[docs] Update go instructions
2024-06-22 02:15:42 -06:00
AbelLykens
04f9a4faa4
[docs] Update go instructions
Building current lnd `0.18` fails with older go (`1.19.7`).

* Updated go download path to 1.22.4
* Updated hashes
* Added `rm -rf` instructions as per [go.dev instructions](https://go.dev/doc/install)
2024-06-21 19:27:52 +02:00
Olaoluwa Osuntokun
376b8cedc4
Merge pull request #8853 from Roasbeef/result-utils
fn: add additional utility methods for Result[T]
2024-06-20 16:11:26 -07:00
Olaoluwa Osuntokun
f1a38714d4
fn: add additional utility methods for Result[T]
`NewResult` makes it easy to wrap a normal function call in a result
value.

`Err` can be used to check the error case of the result without
unpacking the entire thing.

`AndThen2` allows a caller to compose a function on two results values,
with the closure only executing if both values are non-error.
2024-06-20 15:05:28 -07:00
Oliver Gugger
390f0723d3
Merge pull request #8838 from yyforyongyu/update-pendingsweeps
cli: update `pendingsweeps` response
2024-06-20 07:13:00 -06:00
Elle
2477bd756f
Merge pull request #8549 from matheusdtech/mc-store-perf-improv
Misson Control Store: Improve performance
2024-06-19 09:15:07 -07:00
Elle
2979afdc19
Merge pull request #8811 from hieblmi/fix-inbound-fee-typo
lncli: fix typo in inbound fee help text
2024-06-19 08:48:47 -07:00
Matheus Degiovani
f39edaa19a
docs: update release notes 2024-06-19 07:35:46 -03:00
Matheus Degiovani
0c7a173354
missioncontrolstore: remove duplication of in-memory data
This removes duplication of in-memory data during the periodic flushing
stage of the mission control store.

The existing code entirely duplicates the in-memory cache of the store,
which is very wasteful when only a few additional results are being
rotated into the store.

This has a significant performance penalty specially for wallets that
remain online for a long time with a low volume of payments. The worst
case scenario are wallets that see at most 1 new payment a second, where
the entire in-memory cache is recreated every second.

This commit improves the situation by determining what will be the
actual changes that need to be committed before initiating the db
transaction and only keeping track of these to update the in-memory
cache if the db tx is successful.
2024-06-19 07:34:35 -03:00
Matheus Degiovani
9059a655db
missioncontrolstore: avoid ticker when there is no work to be done.
This modifies the mission control store to avoid running the one second
ticker for flushing data when there is no work to be done.

This improves performance of a quiscent LN node by avoiding a one second
interval busy loop that does nothing when there are no payments flowing
through the node.
2024-06-19 07:34:35 -03:00
Matheus Degiovani
637ac85d1d
missioncontrolstore: skip work when there are no new entries
This modifies the mission control store to avoid doing any work when no
new payment result entries are in the queue to be processed.

The mission control store maintains keeps the latest N (in production:
1000) entries in its DB, evicting older entries when new ones are added.
Currently, its implementation is somewhat less performant than it could
be.

This commit adds an early return to the storeResults function to avoid
doing any DB or memory operations when its outstanding queue is empty,
improving the performance during quiescent periods of the LN node's
execution.
2024-06-19 07:34:34 -03:00
Matheus Degiovani
6a27bc29ba
missioncontrolstore: add additional tests and benchmarks
These will be useful in the next commits.
2024-06-19 07:33:14 -03:00
Slyghtning
b66e361afa
lncli: fix typo in inbound fee help text 2024-06-19 07:33:32 +02:00
Olaoluwa Osuntokun
c0f7c2849d
Merge pull request #8822 from michael1011/fix-config-error-handling
cfg: fail startup on flags.Error parsing error
2024-06-18 17:51:24 -07:00
michael1011
01f5af0a28
cfg: fail startup on flags.Error parsing error 2024-06-17 16:48:34 +02:00
Yong
e6f7a2d6a7
Merge pull request #8734 from hieblmi/cancel-estimateroutefee
routing: cancelable payment loop
2024-06-17 18:06:52 +08:00
Slyghtning
4568dfceee
docs: update release notes 2024-06-17 09:32:27 +02:00
Slyghtning
7bfa616371
lncli: cancelable flag for SendPaymentRequest 2024-06-17 09:32:26 +02:00
Slyghtning
bba01cf634
routing+routerrpc: cancelable context in SendPaymentV2
In this commit we set up the payment loop context
according to user-provided parameters. The
`cancelable` parameter indicates whether the user
is able to interrupt the payment loop by cancelling
the server stream context. We'll additionally wrap
the context in a deadline if the user provided a
payment timeout.
We remove the timeout channel of the payment_lifecycle.go
and in favor of the deadline context.
2024-06-17 09:32:26 +02:00
Slyghtning
e729084149
lnrpc: cancelable sendpayment request 2024-06-17 09:32:26 +02:00
Slyghtning
06bff6f81a
routing: fix typos and wrap errors 2024-06-17 09:32:25 +02:00
Elle
68494fd91d
Merge pull request #8839 from ellemouton/abandonChanItestFix
itest+lntest: let abandoned channel be either not found or in zombie
2024-06-14 15:55:36 -04:00
Elle Mouton
f3cdbbed2f
itest+lntest: let abandoned channel be either not found or in zombie
index

When abandoning a channel, we remove it from the graph and then add it
to the zombie channel index. However, if we then process a ChannelUpdate
for this channel it will result in us calling `processZombieUpdate`
which will delete the edge from the zombie index. The abandon channel
itest currently asserts that a channel is no longer in the graph by
asserting that when querying for the channel we get a "marked as zombie"
error but to account for the above series of operations, we now also
allow it to just not be found at all ("edge not found").
2024-06-14 14:33:43 -04:00
Olaoluwa Osuntokun
cbe1c150da
Merge pull request #8841 from yyforyongyu/temp-fix-neutrino
itest: provide a temporary fix to unblock CI
2024-06-14 11:27:41 -07:00
yyforyongyu
955670fcc2
itest: provide a temporary fix to unblock CI 2024-06-14 15:18:20 +08:00
Elle
83b1c22e79
Merge pull request #8829 from ellemouton/rebaseItestBeforeRun
.github: rebase before running itests & unit tests
2024-06-13 10:40:13 -04:00
Elle Mouton
e326e242ff
.github: rebase before running itests & unit tests 2024-06-13 08:11:02 -04:00
Elle Mouton
20be40df7b
.github: make the rebase step re-usable 2024-06-13 08:11:02 -04:00
Elle Mouton
8b31a37ec9
.github: only fetch the base branch when rebasing
Update the "check commits" action to only fetch the base branch that we
will be rebasing on. Otherwise every upstream branch is fetched.
2024-06-13 08:11:01 -04:00
yyforyongyu
0f7c641f92
cli: update pendingsweeps response 2024-06-13 19:17:16 +08:00
Yong
cf88a8ae04
Merge pull request #8828 from yyforyongyu/increase-itest-timeout
lntest: increase timeout for postgres backend
2024-06-13 19:00:49 +08:00
yyforyongyu
84e58d6f02
workflows: decrease TRANCHES to 8 2024-06-13 17:54:34 +08:00
yyforyongyu
6de1b026dd
chainntnfs: add verbose logging in unit test 2024-06-13 17:54:34 +08:00
yyforyongyu
9f34a4dc54
itest: skip error assertion when parent context finishes
We may get a flake like the following,
```
lnd_route_blinding_test.go:468:
            Error Trace:    /Users/runner/work/lnd/lnd/itest/lnd_route_blinding_test.go:468
                                        /Users/runner/hostedtoolcache/go/1.22.3/arm64/src/runtime/asm_arm64.s:1222
            Error:          Received unexpected error:
                            rpc error: code = Canceled desc = context canceled
            Test:           TestLightningNetworkDaemon/tranche15/144-of-156/bitcoind/disable_introduction_node
```

This happens when the test successfully finishes, the parent context is
canceled, causing the child context to return an error. We fix it by
ignoring it in the goroutine.
2024-06-13 17:54:30 +08:00
yyforyongyu
ddceb2b15b
lntest: increase timeout for postgres backend
Also decrease timeout values for other builds.
2024-06-13 17:54:30 +08:00
Elle
26892a2645
Merge pull request #8730 from feelancer21/lncli-wallet-estimatefee
lncli: new command `wallet estimatefeerate`
2024-06-12 10:43:50 -04:00
feelancer21
fc90bc9b0f
lncli: new command wallet estimatefeerate
`lncli wallet estimatefeerate` returns the fee rate estimate for on-chain
transactions in sat/kw and sat/vb to achieve a given confirmation target.
2024-06-11 21:56:06 +02:00
Yong
286ee95735
Merge pull request #8800 from ProofOfKeags/bugfix/8535
contractcourt: consider delivery addresses when evaluating toSelfAmount
2024-06-12 01:06:36 +08:00
Oliver Gugger
931b3dc0c3
Merge pull request #8815 from yyforyongyu/fix-edge-policy
trivial: fix linter errors and return verbose errors
2024-06-10 12:48:59 -06:00
Keagan McClelland
1fea14f69f docs: update release notes 2024-06-10 11:38:22 -07:00
Keagan McClelland
30e10322b2 contractcourt: consider delivery addresses when evaluating toSelfAmount
This commit fixes #8535 by changing how we assess toSelfAmount inside
the chainWatcher.

In certain cases users may wish to close out channel funds to external
delivery addresses set either during open or close.

Prior to this change we only consider addresses that our wallet is
aware of.

This change now identifies outputs as to_self outputs if the delivery
script matches OR if our wallet is aware of the address. In certain
edge cases it can be possible for there to be more than one output
that matches these criteria and in that case we will return the sum
of those values.
2024-06-10 11:38:17 -07:00
Oliver Gugger
3549d719ee
Merge pull request #8823 from bhandras/fixup-sendpayment-amp
lncli: fix parsing of --amp when sending a payment
2024-06-10 10:23:45 -06:00
Andras Banki-Horvath
59c8bafda7
lncli: fix parsing of --amp when sending a payment 2024-06-10 17:33:28 +02:00
yyforyongyu
e61cba8d22
multi: return verbose errors when fetching edges 2024-06-10 08:40:18 +08:00
yyforyongyu
78cc1619d7
multi: fix complaints from IDE and linter
Fixed unused param and nilness cond.
2024-06-07 00:45:15 +08:00
Oliver Gugger
98c52df4d2
Merge pull request #8813 from hieblmi/chaninfo-per-outpoint
Allow for a channel point in `GetChanInfo`
2024-06-06 14:47:31 +02:00
Slyghtning
cc902e3d8a
docs: update release notes 2024-06-06 14:15:46 +02:00
Slyghtning
9f83f48d78
lncli: channel point for getchaninfo 2024-06-06 14:15:44 +02:00
Slyghtning
7923ca0de4
rpcserver: retrieve channel info for channel point 2024-06-06 13:37:58 +02:00
Slyghtning
1936aa7261
lnrpc: channel point for GetChanInfo 2024-06-06 13:28:41 +02:00
Keagan McClelland
56048133f2 itest+lntest: add itest to reproduce bug #8535 2024-06-05 12:56:04 -07:00
Oliver Gugger
0fadf97e72
Merge pull request #8808 from ProofOfKeags/fn/predicate-combinators
fn: add predicate combinators for && and ||
2024-06-05 14:03:19 +02:00
Oliver Gugger
a832371d61
Merge pull request #8491 from davidgumberg/invoice_cltv_expiry
Expose `cltv_expiry` flag of `addinvoice` to cli
2024-06-04 13:59:50 +02:00
Oliver Gugger
14bed1d1e7
Merge pull request #8795 from guggero/itest-parallel
GitHub: increase itest parallelization to more tranches
2024-06-04 13:16:20 +02:00
David Gumberg
3c1b7ad59c Release note for cltv_expiry flag to addinvoice 2024-06-04 06:19:12 -04:00
David Gumberg
4646afb366 lnrpc: Fix bug in 'cltv below minimum' error msg
Previously the error message produced when `CltvExpiry` is less
than the minimum final cltv (18 at present) set by
`routing.MinCLTVDelta` inserted the values into the wrong spots of the
formatted string.
2024-06-04 06:19:12 -04:00
David Gumberg
80b60d34aa lncli: Expose cltv_expiry flag of addinvoice
Allows users of the RPC CLI to set the `min_final_cltv_expiry_delta`
described in BOLT's 11, 7, and 2 by setting the `cltv_expiry` flag when
calling either of the `addinvoice` or `addholdinvoice` RPC's from
`lncli`.
2024-06-04 06:19:12 -04:00
yyforyongyu
d9498a9d13
lntest: increase DefaultTimeout for postgres 2024-06-04 09:07:44 +02:00
yyforyongyu
c9cad6ab81
itest+sweep: refactor testSignPsbt to use Subtest and add logs 2024-06-04 09:07:44 +02:00
yyforyongyu
55452f64e8
lntest: wait for mempool update after mining txns 2024-06-04 09:07:43 +02:00
Oliver Gugger
a5c04bbd14
GitHub: increase itest parallelization to 16 tranches 2024-06-04 09:07:34 +02:00
Keagan McClelland
cd3c17e1c0 fn: add predicate combinators for && and || 2024-06-03 12:24:02 -07:00
Oliver Gugger
a2266c6c73
Merge pull request #8802 from saubyk/suheb-pgp
scripts: add pgp key for suheb [skip ci]
2024-06-03 17:53:53 +02:00
Oliver Gugger
d7714efc88
Merge pull request #8779 from bufo24/chore/allow-zero-fail-amt-import-mc
Allow 0 failure amt on importmc
2024-06-03 13:02:37 +02:00
Bufo
4a3af519b8
chore: allow 0 failure amount on import mission control 2024-06-03 11:28:26 +02:00
saubyk
ab00c8ad18
scripts: add gpg key for suheb [skip ci] 2024-06-01 11:25:46 -07:00
Oliver Gugger
613bfc07fb
Merge pull request #8798 from zoupingshi/master
chore: fix some comments
2024-05-31 18:03:54 +02:00
Oliver Gugger
a02c6b6194
Merge pull request #8799 from ellemouton/release-notes-0.18.1
docs: add release notes template for 0.18.1
2024-05-31 17:19:05 +02:00
rockstardev
c841954c51 Bumping golang to 1.22.3 2024-05-31 08:51:13 -05:00
Elle Mouton
401e74c568
docs: add release notes template for 0.18.1 2024-05-31 09:44:48 -04:00
rockstardev
b3aecc7ac5 Bumping loop to 0.28.2 2024-05-31 08:35:44 -05:00
rockstardev
0faa1f4de2 Adding BtcPayServer related files and resources 2024-05-31 08:33:46 -05:00
rockstardev
f6f5e312f3 Merge commit '3da3d28064d2712400f1b579bd4dfa34e04fd227' 2024-05-31 08:25:35 -05:00
rockstardev
8fca329810 Merge basedon-v0.17.3-beta
# Conflicts:
#	docker-initunlocklnd.sh
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
2024-05-31 08:25:24 -05:00
rockstardev
9b43b0aa1a Merge commit 'b8c6baa94a949297397faba034a0979fd365609a' 2024-05-31 08:24:06 -05:00
rockstardev
6de26dc8ad Merge basedon-v0.17.1-beta
# Conflicts:
#	build/version.go
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
2024-05-31 08:23:52 -05:00
zoupingshi
30047feb35 chore: fix some comments
Signed-off-by: zoupingshi <hellocatty@tom.com>
2024-05-31 15:16:33 +08:00
Olaoluwa Osuntokun
fed760913f
Merge pull request #8794 from Roasbeef/v0-18-0-branch
build: bump version to v0.18.0 beta
2024-05-30 22:52:10 +09:00
Olaoluwa Osuntokun
1a8d196607
build: bump version to v0.18.0 beta 2024-05-30 17:49:17 +09:00
Oliver Gugger
b137892ceb
Merge pull request #8788 from ProofOfKeags/proofofkeags-pgp
scripts: add gpg key for proofofkeags [skip ci]
2024-05-29 20:55:17 +02:00
Olaoluwa Osuntokun
cd23265537
Merge pull request #8784 from lightningnetwork/0-18-rc4
build: bump version to v0.18.0-beta.rc4
2024-05-29 17:00:12 +09:00
Oliver Gugger
a8b679cd60
Merge pull request #8789 from guggero/fn-result
fn: add Result type
2024-05-29 09:55:52 +02:00
Oliver Gugger
c95505db1e
fn: add Result type
In this commit, we add a new result type, which is just Either[A, error]. This is useful as we can always pass around/accept a single value. We add an Unpack() method which is the most idiomatic way of handling errors in Go, as we revert back to (A, error) when necessary.
2024-05-29 09:39:39 +02:00
Keagan McClelland
fce2ef15a5 scripts: add gpg key for proofofkeags [skip ci] 2024-05-28 17:29:36 -07:00
Olaoluwa Osuntokun
1b6f42a107
build: bump version to v0.18.0-beta.rc4 2024-05-28 10:46:15 +09:00
Olaoluwa Osuntokun
ff85328050
Merge pull request #8774 from yyforyongyu/fix-size-calc
lnwallet+sweep: fix wrong unit used in fee calculation
2024-05-27 18:44:29 -07:00
yyforyongyu
2e40a23146
lnrpc: fix linter 2024-05-25 13:37:16 +08:00
yyforyongyu
5e8452cc5d
sweep: make sure the full input is accounted
Fix the case where previously only the witness data is taken into
account when calculating the fees.
2024-05-25 13:37:16 +08:00
yyforyongyu
17a089c899
input+lnwallet: apply the new type lntypes.VByte 2024-05-25 13:37:16 +08:00
yyforyongyu
8da68bb7db
multi: apply the new type lntypes.WeightUnit 2024-05-25 13:37:13 +08:00
yyforyongyu
dc9a0b31c0
lntypes: add new units WeightUnit and VByte 2024-05-24 23:56:28 +08:00
yyforyongyu
634967c5c8
chainfee: add FeeForVByte on SatPerKWeight 2024-05-24 22:49:20 +08:00
Olaoluwa Osuntokun
bc6292f8bd
Merge pull request #8758 from feelancer21/preserve-inbound-fees
multi: Inbound fees are retained when not provided
2024-05-23 13:58:52 -07:00
Olaoluwa Osuntokun
4417229bc8
Merge pull request #8773 from lightningnetwork/0-18-rc3
build: bump verison to v0.18.0-beta.rc3
2024-05-22 13:19:13 -07:00
feelancer21
dc4ec45423
itest: add more tests related to inbound fees
Add tests for setting inbound fees in channel policies, including tests
where no inbound fees are set in the PolicyUpdateRequest.
2024-05-22 20:48:52 +02:00
feelancer21
f62c00fe34
multi: Inbound fees are retained when not provided
Fixes the problem that inbound base fee and fee rate are overwritten
with 0 if they are not specified in PolicyUpdateRequest. This ensures
backward compatibility with older rpc clients that do not yet support
the inbound feature.
2024-05-22 20:48:42 +02:00
Olaoluwa Osuntokun
74237f2c24
build: bump verison to v0.18.0-beta.rc3 2024-05-22 11:44:24 -07:00
Olaoluwa Osuntokun
64639fb771
Merge pull request #8762 from ProofOfKeags/bugfix/ping-stability
Adjust ping parameters to improve tor stability
2024-05-21 19:34:57 -07:00
Keagan McClelland
1148e572bf peer: triple timeout parameters to give tor more grace 2024-05-21 13:36:46 -07:00
Keagan McClelland
61191a576d peer: make PingManager.Stop infallible 2024-05-21 13:29:31 -07:00
Keagan McClelland
94a9baefeb peer: reduce upper bound of pong bytes to ease bandwidth load 2024-05-21 13:27:56 -07:00
Oliver Gugger
68ea8d5312
Merge pull request #8750 from Chinwendu20/fnd
fn: Added `HasDuplicates` function to slice
2024-05-21 17:08:05 +02:00
Oliver Gugger
01e3ac61d8
Merge pull request #8631 from Chinwendu20/brontidetest
[code-health]: reduce duplication in brontide test.
2024-05-21 12:46:16 +02:00
Olaoluwa Osuntokun
e1c5fe2f9e
Merge pull request #8751 from yyforyongyu/fix-sweeper-18
contractcourt+sweep: fix fee function and deadline issue
2024-05-20 18:11:26 -07:00
yyforyongyu
347537791e
sweep: improve loggings based on feedback
This commit changes the logging levels and add a few more loggings based
on the testing results from the testnet/mainnet.
2024-05-21 00:53:24 +08:00
yyforyongyu
e45db07a10
contractcourt+itest: make sure ChannelArbitrator has the latest htlcs 2024-05-21 00:53:23 +08:00
yyforyongyu
71ee50f87c
lncli: add missing SatPerVbyte field in bumpfee cli 2024-05-21 00:53:23 +08:00
yyforyongyu
4079f61d7e
itest+sweep: fix current itest re anchor deadline 2024-05-21 00:53:20 +08:00
Oliver Gugger
2a8ca878fd
Merge pull request #8663 from Filiprogrammer/funding-manager-log-errors
funding: add absent error logs for failed inbound funding requests
2024-05-20 15:23:32 +02:00
Ononiwu Maureen
95016b849a
fn: Added HasDuplicates function to slice
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-05-20 11:54:33 +01:00
yyforyongyu
e68c0235c6
itest: add new itests to check CPFP anchor sweeping behavior
Replaced `testSweepAnchorCPFPLocalForceClose` with dedicated tests.
2024-05-18 07:45:10 +08:00
yyforyongyu
38184e88c8
sweep: check all states in TestMarkInputsPublishFailed 2024-05-18 07:45:09 +08:00
yyforyongyu
ac5af48319
sweep: make sure the budget is used up at deadlineHeight-1 2024-05-18 07:45:09 +08:00
yyforyongyu
1470adbed2
contractcourt: share deadlines between CPFP anchors and HTLCs
This commit changes how the deadline is calculated for CPFP anchor
sweeping. In order to sweep the second-level HTLCs, we need to first
get the FC tx confirmed. If we use a larger conf target for CPFP, we'd
end up having few blocks to sweep the HTLCs, as these two sweeping txns
share the deadline of the HTLC, as shown below,
```
More aggressive on the CPFP part.
|-CPFP-|-----HTLC-----|

Share the deadlines evenly.
|---CPFP---|---HTLC---|

More aggressive on the HTLC part.
|-----CPFP-----|-HTLC-|
```
In this commit, we decide to share the deadlines evenly as a starting
point so neither side will have a short of deadlines.
2024-05-18 07:45:09 +08:00
yyforyongyu
2906b8b20c
sweep: update and fix README 2024-05-18 07:45:09 +08:00
Oliver Gugger
87d5170dec
Merge pull request #8744 from orbitalturtle/custom-protocol-cfg
cfg: move experimental options to main protocol cfg
2024-05-17 08:45:34 +02:00
Oliver Gugger
3c4ebeb994
Merge pull request #8765 from hieblmi/fix-logging
routing: log edge when skipping it
2024-05-17 08:42:11 +02:00
Orbital
e8196c6feb
cfg: move experimental options to main protocol cfg 2024-05-16 17:16:50 -05:00
Oliver Gugger
2845c6497a
Merge pull request #8746 from Roasbeef/go-1-22-3
build: update release builds and CI to Go 1.22.3
2024-05-16 17:22:53 +02:00
Slyghtning
c9713e0ddb
routing: log edge when skipping it 2024-05-16 13:54:54 +02:00
largemouth
a1f36e48d3 chore: fix some function names
Signed-off-by: largemouth <largemouth@aliyun.com>
2024-05-15 11:41:23 +08:00
Oliver Gugger
9d358bc649
Merge pull request #8748 from guggero/custom-tlv-types
tlv: generate TLV types for custom ranges
2024-05-14 09:02:32 +02:00
Oliver Gugger
454f56d4a8
tlv: generate TLV types for custom ranges 2024-05-14 08:16:42 +02:00
Olaoluwa Osuntokun
130c4999c6
Merge pull request #8723 from bufo24/add-inbound-fees-to-channel-notifications
add inbound fees channel updates to notifications
2024-05-13 12:52:50 -07:00
Filiprogrammer
593a564332
funding: enhance error logs for failed inbound funding requests
For failed inbound funding requests, add missing error logs and make
sparse error logs more descriptive.
2024-05-11 14:56:37 +02:00
Ononiwu Maureen
b741132a81
peer: Add startPeer test function
Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-10 10:23:31 +01:00
Oliver Gugger
4256260544
Merge pull request #8729 from Chinwendu20/fn
Add new  functions to the fn package
2024-05-10 11:17:46 +02:00
Ononiwu Maureen
30c9b86d62
fn: Added new slice functions.
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-05-10 10:06:24 +01:00
Ononiwu Maureen
f88f120e91
fn: Added map functions
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-05-10 09:55:16 +01:00
Olaoluwa Osuntokun
a585833fb5
build: update release builds and CI to Go 1.22.3 2024-05-09 15:24:19 -07:00
Oliver Gugger
4a9ab6e538
Merge pull request #8739 from ellemouton/addInstallAll
makefile+dev.Dockerfile: add install-all command
2024-05-08 16:26:46 +02:00
Ononiwu Maureen
2ec0fe0717
peer: Add new function to create test peer.
Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-08 13:17:14 +01:00
Ononiwu Maureen
8f76c5eeef
peer: Create mockswitch, publTx, notifier in ..
test_utils

Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-08 12:04:30 +01:00
Ononiwu Maureen
536c69b793
peer: createTestPeerWithChannel returns a struct
The `createTestPeerWithChannel` function is made to return this newly
created struct and error.

This is useful because upcoming commits would require us returning more
objects from the function.

Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-08 11:59:08 +01:00
Ononiwu Maureen
389ecb535b
peer: Change createTestPeer name.
In this function `createTestPeer` is changed to
`createTestPeerWithChannel`. This is useful in coming commits where we
decouple the process of creating test peer from the function.

Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-08 11:57:15 +01:00
Elle Mouton
c577dae372
makefile+dev.Dockerfile: add install-all command
Add a new `make install-all` command that will perform all `make
install` actions along with generating the manpages. The `manpages`
command is then removed from the existing `make install` command. The
docker build is then updated to use the new `make install-all` command.
This is done because some users running `make install` may be doing so
in environments where they do not have write access to the directory
where the man pages need to be written to.
2024-05-08 09:30:46 +02:00
Olaoluwa Osuntokun
3e36df42e5
Merge pull request #8733 from lightningnetwork/0-18-branch-rc2
build: bump version to v0.18.0-beta.rc2
2024-05-07 14:20:36 -07:00
Oliver Gugger
c68778d2f3
Merge pull request #7364 from guggero/itest-coverage
Add test coverage for integration tests
2024-05-07 21:05:35 +02:00
Bufo
af9858c3ed
feat: add inbound fees to channel notifications 2024-05-07 18:58:25 +02:00
Oliver Gugger
f523f52ab4
Merge pull request #8732 from ellemouton/guardNewTestSqliteDB
invoices: ensure synchronous access to NewTestSqliteDB
2024-05-07 08:40:56 +02:00
Olaoluwa Osuntokun
954ad4a329
build: bump version to v0.18.0-beta.rc2 2024-05-06 18:10:52 -07:00
Olaoluwa Osuntokun
6bcbc8dd97
Merge pull request #8719 from yyforyongyu/merge-fee-cache
Merge fee cache and fix sample conf
2024-05-06 18:09:06 -07:00
Elle Mouton
d4f63662c1
invoices: ensure synchronous access to NewTestSqliteDB
Add a temporary mutex around the calls to sqldb.NewTestSqliteDB to
ensure that only a single thread can access it at a time. This is a
temporary work around that can be removed once this race condition in
the sqlite repo has been resolved:
https://gitlab.com/cznic/sqlite/-/issues/180
2024-05-06 19:10:44 +02:00
Oliver Gugger
b4e4e9447a
Merge pull request #8731 from yyforyongyu/fix-payinvoice
cli: add `--amp` to `SendPaymentRequest` in `payinvoice`
2024-05-06 11:20:07 +02:00
yyforyongyu
187b0b1f80
cli: add --amp to SendPaymentRequest in payinvoice 2024-05-06 16:01:35 +08:00
Tom Kirkpatrick
c8a40b67e9
docs: add missing release notes credit 2024-05-04 14:44:14 +08:00
yyforyongyu
6bbbfd3327
docs: add missing fee section sample-lnd.conf 2024-05-04 14:41:41 +08:00
Tom Kirkpatrick
3837c3f12e
lnwallet: add configurable cache for web fee estimator
Add fee.min-update-timeout and fee.max-update-timeout config options to
allow configuration of the web fee estimator cache.
2024-05-04 14:41:41 +08:00
Tom Kirkpatrick
fa616ee059
config: remove deprecated neutrino.feeurl config option 2024-05-04 14:41:40 +08:00
Olaoluwa Osuntokun
399ea864da
Merge pull request #8703 from carlaKC/flake-blindedchainerr
itest/flake: add more comprehensive assertions before HTLC cleared check
2024-05-02 12:09:04 -05:00
Oliver Gugger
90bff71db9
Merge pull request #8716 from yyforyongyu/temp-fix-height-race
sweep: make `TxPublisher.currentHeight` atomic
2024-05-02 17:19:33 +02:00
Oliver Gugger
fb632bb945
Merge pull request #8712 from djkazic/invoice-gc-noop
invoices: if there are no invoices make gc noop
2024-05-01 08:31:56 +02:00
yyforyongyu
3f8da16b77
sweep: make TxPublisher.currentHeight atomic 2024-05-01 12:16:54 +08:00
djkazic
1542424782
invoices: if there are no invoices make gc noop 2024-04-30 11:58:18 -04:00
Oliver Gugger
e8a1d4876e
Merge pull request #8705 from yyforyongyu/fix-typo
lnrpc: fix typo
2024-04-30 12:11:25 +02:00
Olaoluwa Osuntokun
9f4e92c518
Merge pull request #8706 from guggero/release-notes-fix
0.18: add contributors from git log, polish release notes
2024-04-29 16:09:28 -07:00
Oliver Gugger
6159d41970
docs: remove entry for fix within release
This commit removes an entry that was fixed in the same release as it
was introduced. So nobody should've been running into it yet.
2024-04-29 19:17:52 +02:00
Oliver Gugger
9dbf7e2133
docs: cleanup release notes
This commit removes a duplicate, fixes some typos and grammar issues and
removes an empty section/heading.
2024-04-29 19:17:52 +02:00
Oliver Gugger
3d56ffd0e4
Merge pull request #8662 from fuyangpengqi/master
chore: fix function names in comment
2024-04-29 15:10:20 +02:00
Oliver Gugger
be6b9b4b47
docs: update contributor list from git log
This commit adds contributors that didn't add themselves to the release
notes by extracting their GitHub username (or, if available their
name and surname from GitHub) from the git log manually.
2024-04-29 13:45:51 +02:00
yyforyongyu
9f2995251e
lnrpc: fix typo 2024-04-29 19:14:27 +08:00
Oliver Gugger
0419074ab8
Merge pull request #8695 from bitromortac/linter-cache
make: add cache directory for linter
2024-04-29 11:14:06 +02:00
Carla Kirk-Cohen
6e3a46ee91 itest: add more comprehensive assertions before HTLC cleared check
We mine quite a few blocks in this test to trigger a htlc timeout,
so it can be pretty slow. This fix adds assertions for additional
"state steps" that happen in between the failing of the htlc on-chain
and asserting that we're fully cleared out so that slower running
machines won't timeout.
2024-04-27 11:42:35 -04:00
Olaoluwa Osuntokun
ded995a843
Merge pull request #8701 from Roasbeef/0-18-branch
build: bump version to v0.18.0-beta.rc1
2024-04-26 19:45:41 -07:00
Olaoluwa Osuntokun
3b6103d29f
build: bump version to v0.18.0-beta.rc1 2024-04-26 19:19:23 -07:00
Olaoluwa Osuntokun
b92216ea13
Merge pull request #8700 from Roasbeef/kvdb-update-1-4-8
build: update to kvdb v1.4.8
2024-04-26 19:09:13 -07:00
Olaoluwa Osuntokun
f536c9b608
build: update to kvdb v1.4.8 2024-04-26 16:17:19 -07:00
Olaoluwa Osuntokun
5148941ed9
Merge pull request #8699 from Roasbeef/kvdb-sqlite-update-4-26
build: update to sqldb v1.0.2
2024-04-26 16:10:49 -07:00
Olaoluwa Osuntokun
e80adcde8e
Merge pull request #8692 from guggero/tlv-types
tlv: add new types and functions
2024-04-26 16:10:24 -07:00
Olaoluwa Osuntokun
7302051f44
build: update to sqldb v1.0.2
In this commit, we update the project and relevant sub-modules to sqldb
v1.0.2. The next step is to tag a new version of kvdb, then update the
main module to use that.
2024-04-26 15:31:14 -07:00
Olaoluwa Osuntokun
abcad6218e
Merge pull request #8696 from Roasbeef/sqlite-update
sqldb+kvdb: update to sqlite v1.29.8
2024-04-26 15:25:33 -07:00
Olaoluwa Osuntokun
b0463124d0
Merge pull request #8694 from Roasbeef/fix-pkg-race
channeldb: fix race in TestPackager by removing global test var
2024-04-26 15:18:00 -07:00
Olaoluwa Osuntokun
675ae6e213
Merge pull request #8693 from yyforyongyu/add-default-conf
rpc: add default conf target back
2024-04-26 12:45:06 -07:00
Olaoluwa Osuntokun
add2691954
Merge pull request #8485 from carlaKC/7298-3-forwardblindedroutes
[3/3]: Blinded Route Error Handling
2024-04-26 12:39:11 -07:00
Olaoluwa Osuntokun
fe8784aa0c
channeldb: fix race in TestPackager by removing global test var
In this commit, we fix a race in the `TestPackager` series on channeldb.
A few tests were sharing the same global variable of the set of log
updates, which includes a pointer to an HTLC. The `ExtraData` value of
the HTLC would then be mutated once we go to encode the message on disk.

To fix this, we the global with a function that returns a new instance
of all the test data.

```
==================
WARNING: DATA RACE
Write at 0x0000021b0a48 by goroutine 2896:
  github.com/lightningnetwork/lnd/lnwire.(*ExtraOpaqueData).PackRecords()
      /home/runner/work/lnd/lnd/lnwire/extra_bytes.go:74 +0x546
  github.com/lightningnetwork/lnd/lnwire.EncodeMessageExtraData()
      /home/runner/work/lnd/lnd/lnwire/extra_bytes.go:121 +0x4d
  github.com/lightningnetwork/lnd/lnwire.(*UpdateAddHTLC).Encode()
      /home/runner/work/lnd/lnd/lnwire/update_add_htlc.go:164 +0x5af
  github.com/lightningnetwork/lnd/lnwire.WriteMessage()
      /home/runner/work/lnd/lnd/lnwire/message.go:330 +0x351
  github.com/lightningnetwork/lnd/channeldb.WriteElement()
      /home/runner/work/lnd/lnd/channeldb/codec.go:186 +0x1975
  github.com/lightningnetwork/lnd/channeldb.WriteElements()
      /home/runner/work/lnd/lnd/channeldb/codec.go:247 +0x14f
  github.com/lightningnetwork/lnd/channeldb.serializeLogUpdate()
      /home/runner/work/lnd/lnd/channeldb/channel.go:2529 +0x3c
  github.com/lightningnetwork/lnd/channeldb.putLogUpdate()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package.go:525 +0xae
  github.com/lightningnetwork/lnd/channeldb.(*ChannelPackager).AddFwdPkg()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package.go:489 +0x684
  github.com/lightningnetwork/lnd/channeldb_test.TestPackagerOnlyAdds.func1()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package_test.go:283 +0x4c
  github.com/btcsuite/btcwallet/walletdb/bdb.(*db).Update()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcwallet/walletdb@v1.4.2/bdb/db.go:429 +0xe5
  github.com/lightningnetwork/lnd/kvdb.Update()
      /home/runner/go/pkg/mod/github.com/lightningnetwork/lnd/kvdb@v1.4.6/interface.go:16 +0x258
  github.com/lightningnetwork/lnd/channeldb_test.TestPackagerOnlyAdds()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package_test.go:282 +0x17b
  testing.tRunner()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1595 +0x238
  testing.(*T).Run.func1()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1648 +0x44

Previous write at 0x0000021b0a48 by goroutine 2898:
  github.com/lightningnetwork/lnd/lnwire.(*ExtraOpaqueData).PackRecords()
      /home/runner/work/lnd/lnd/lnwire/extra_bytes.go:74 +0x546
  github.com/lightningnetwork/lnd/lnwire.EncodeMessageExtraData()
      /home/runner/work/lnd/lnd/lnwire/extra_bytes.go:121 +0x4d
  github.com/lightningnetwork/lnd/lnwire.(*UpdateAddHTLC).Encode()
      /home/runner/work/lnd/lnd/lnwire/update_add_htlc.go:164 +0x5af
  github.com/lightningnetwork/lnd/lnwire.WriteMessage()
      /home/runner/work/lnd/lnd/lnwire/message.go:330 +0x351
  github.com/lightningnetwork/lnd/channeldb.WriteElement()
      /home/runner/work/lnd/lnd/channeldb/codec.go:186 +0x1975
  github.com/lightningnetwork/lnd/channeldb.WriteElements()
      /home/runner/work/lnd/lnd/channeldb/codec.go:247 +0x14f
  github.com/lightningnetwork/lnd/channeldb.serializeLogUpdate()
      /home/runner/work/lnd/lnd/channeldb/channel.go:2529 +0x3c
  github.com/lightningnetwork/lnd/channeldb.putLogUpdate()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package.go:525 +0xae
  github.com/lightningnetwork/lnd/channeldb.(*ChannelPackager).AddFwdPkg()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package.go:489 +0x684
  github.com/lightningnetwork/lnd/channeldb_test.TestPackagerAddsThenSettleFails.func1()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package_test.go:490 +0x4c
  github.com/btcsuite/btcwallet/walletdb/bdb.(*db).Update()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcwallet/walletdb@v1.4.2/bdb/db.go:429 +0xe5
  github.com/lightningnetwork/lnd/kvdb.Update()
      /home/runner/go/pkg/mod/github.com/lightningnetwork/lnd/kvdb@v1.4.6/interface.go:16 +0x2cd
  github.com/lightningnetwork/lnd/channeldb_test.TestPackagerAddsThenSettleFails()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package_test.go:489 +0x1e7
  testing.tRunner()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1595 +0x238
  testing.(*T).Run.func1()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1648 +0x44

Goroutine 2896 (running) created at:
  testing.(*T).Run()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1648 +0x82a
  testing.runTests.func1()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:2054 +0x84
  testing.tRunner()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1595 +0x238
  testing.runTests()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:2052 +0x896
  testing.(*M).Run()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1925 +0xb57
  github.com/lightningnetwork/lnd/kvdb.RunTests()
      /home/runner/go/pkg/mod/github.com/lightningnetwork/lnd/kvdb@v1.4.6/test_utils.go:23 +0x26
  github.com/lightningnetwork/lnd/channeldb.TestMain()
      /home/runner/work/lnd/lnd/channeldb/setup_test.go:10 +0x308
  main.main()
      _testmain.go:321 +0x303

Goroutine 2898 (running) created at:
  testing.(*T).Run()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1648 +0x82a
  testing.runTests.func1()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:2054 +0x84
  testing.tRunner()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1595 +0x238
  testing.runTests()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:2052 +0x896
  testing.(*M).Run()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1925 +0xb57
  github.com/lightningnetwork/lnd/kvdb.RunTests()
      /home/runner/go/pkg/mod/github.com/lightningnetwork/lnd/kvdb@v1.4.6/test_utils.go:23 +0x26
  github.com/lightningnetwork/lnd/channeldb.TestMain()
      /home/runner/work/lnd/lnd/channeldb/setup_test.go:10 +0x308
  main.main()
      _testmain.go:321 +0x303
==================
```
2024-04-26 12:36:53 -07:00
Olaoluwa Osuntokun
eb605a02fd
sqldb+kvdb: update to sqlite v1.29.8
Updates to SQLite 3.45.3: https://www.sqlite.org/releaselog/3_45_3.html.

May also address https://github.com/lightningnetwork/lnd/issues/8666.
2024-04-26 12:26:59 -07:00
fuyangpengqi
5f22d97b51 chore: fix function names in comment
Signed-off-by: fuyangpengqi <995764973@qq.com>
2024-04-27 00:04:09 +08:00
Carla Kirk-Cohen
6572f5cb74
docs: add error handling link 2024-04-26 11:35:19 -04:00
Carla Kirk-Cohen
7867cb3a70
multi: turn on route blinding by default 2024-04-26 11:35:18 -04:00
Carla Kirk-Cohen
eaa85920ea
multi: enable optional route blinding feature 2024-04-26 11:35:17 -04:00
Carla Kirk-Cohen
75d4a4c295
itest: add coverage for blinded error resolution from on-chain failure
This itest adds a test that we still propagate blinded errors back
properly after a restart with an on-chain resolution. The test also
updates our sendpayment timeout to longer so that there's time to
resolve the on chain claim.
2024-04-26 11:35:17 -04:00
Carla Kirk-Cohen
2140f1940f
itest: manually set timeout on cancel payment and provide cancel
For tests where our payments require an on-chain resolution,
provide longer timeout and return cancel functions.
2024-04-26 10:56:33 -04:00
bitromortac
ba34f220b9
make: add cache directory for linter
Mounts a local temporary folder to the linter docker container in order
to persist the linter cache across runs.
2024-04-26 13:47:50 +02:00
yyforyongyu
db52e7e381
docs: update release notes 2024-04-26 10:42:46 +08:00
yyforyongyu
d0441a2a29
multi: add default conf targt in SendCoins/SendMany/OpenChannel/CloseChannel 2024-04-26 10:42:44 +08:00
Olaoluwa Osuntokun
e6d6789fd9
Merge pull request #8681 from Roasbeef/amp-flag-consistency
lnrpc: ensure parsing of the Amp flag for payments is consistent
2024-04-25 18:49:51 -07:00
Olaoluwa Osuntokun
e8031fdccf
lnrpc: ensure parsing of the Amp flag for payments is consistent
In this commit, we fix an inconsistent in the API related to AMP
payments. When a payment request isn't specified, we require the `--amp`
flag on the CLI to make an AMP payment. However, for payment requests,
we don't require this flag. To fix this inconsistency, we now require
the `--amp` flag to _also_ be set for payment requests.
2024-04-25 16:16:16 -07:00
Olaoluwa Osuntokun
ab2f34e13b
Merge pull request #8621 from ziggie1984/fix-sync-neutrino-nodes
fix sync neutrino nodes
2024-04-25 16:13:32 -07:00
Oliver Gugger
c6dae6c3c0
tlv: rename receivers, add ValOpt
ValOpt returns an Option of the underlying value.
2024-04-25 16:51:12 +02:00
Olaoluwa Osuntokun
956b00b599
tlv: add in new BigSizeT type
This type is useful when one wants to encode an integer as an underlying BigSize record. It wraps any integer, then handles the transformation into and out of the BigSize encoding on disk.
2024-04-25 16:48:29 +02:00
Olaoluwa Osuntokun
5b2869b0ec
tlv: add new Blob type alias
In this commit, we add a new type alias for a blob type. This type can be used in areas where a byte slice is used to store a TLV value, which may be a fully opaque nested TLV.
2024-04-25 16:48:06 +02:00
Carla Kirk-Cohen
d57c6fab47
itest: add coverage for disabling blinded forwards 2024-04-25 09:47:17 -04:00
Carla Kirk-Cohen
428a33fbda
itest: add coverage for failure at the introduction node 2024-04-25 09:47:16 -04:00
Carla Kirk-Cohen
4535cf6c65
itest: add coverage for failure within a blinded route 2024-04-25 09:47:15 -04:00
Carla Kirk-Cohen
d13a73a93a
itest: add test coverage for failure at blinded receiver 2024-04-25 09:47:14 -04:00
Carla Kirk-Cohen
43687181f7
htlcswitch: convert blinded failures for blinded payments 2024-04-25 09:47:13 -04:00
Carla Kirk-Cohen
de9c9c028c
htlcswitch: set packet obfuscator for failures through switch
Set obfuscator for use in blinded error handling when we forward
failures through the switch.
2024-04-25 09:47:12 -04:00
Carla Kirk-Cohen
72260adddb
htlcswitch: create error obfuscator with wrapped type for blinded
Create our error encrypter with a wrapped type if we have a blinding
point present. Doing this in the iterator allows us to track this
information when we have both pieces of information available to us,
compared to trying to handle this later down the line:
- Downstream link on failure: we know that we've set a blinding point
  for out outgoing HTLC, but not whether we're introduction or not
- Upstream link on failure: once the failure packet has been sent
  through the switch, we no longer know whether we were the introduction
  point (without looking it up / examining our payload again /
  propagating this information through the switch).
2024-04-25 09:47:11 -04:00
Carla Kirk-Cohen
9f038c6191
htlcswitch: introduce wrapper type error encrypter to identify blinded
Introduce two wrapper types for our existing SphinxErrorEncrypter
that are used to represent error encrypters where we're a part of a
blinded route. These encrypters are functionally the same as a sphinx
encrypter, and are just used as "markers" so that we know that we
need to handle our error differently due to our different role.

We need to persist this information to account for restart cases where
we've resovled the outgoing HTLC, then restart and need to handle the
error for the incoming link. Specifically, this is relevant for:
- On chain resolution messages received after restart
- Forwarding packages that are re-forwarded after restart

This is also generally helpful, because we can store this information
in one place (the circuit) rather than trying to reconstruct it in
various places when forwarding the failure back over the switch.
2024-04-25 09:47:10 -04:00
Carla Kirk-Cohen
776c889267
multi: return route role from HopPayload
We need to know what role we're playing to be able to handle errors
correctly, but the information that we need for this is held by our
iterator:
- Whether we had a blinding point in update add (blinding kit)
- Whether we had a blinding point in payload

As we're now going to use the route role return value even when our
err!=nil, we rename the error to signal that we're using less
canonical golang here.

An alternative to this approach is to attach a RouteRole to our
ErrInvalidPayload. The downside of that approach is:
- Propagate context through parsing (whether we had updateAddHtlc)
- Clumsy handling for errors that are not of type ErrInvalidPayload
2024-04-25 09:46:31 -04:00
Carla Kirk-Cohen
b81a6f3d2f
htlcswitch: split parsing and validation of TLV payloads
When handling blinded errors, we need to know whether there was a
blinding key in our payload when we successfully parsed our payload
but then found an invalid set of fields. The combination of
parsing and validation in NewPayloadFromReader means that we don't know
whether a blinding point was available to us by the time the error is
returned.

This commit splits parsing and validation into two functions so that
we can take a look at what we actually pulled of the payload in between
parsing and TLV validation.
2024-04-25 09:15:58 -04:00
Carla Kirk-Cohen
4d051b4170
multi: handle all blinding point validation in ValidateParsedPayloadTypes
This commit moves all our validation related to the presence of fields
into ValidateParsedPayloadTypes so that we can handle them in a single
place. We draw the distinction between:
- Validation of the payload (and the context within it's being parsed,
  final hop / blinded hop etc)
- Processing and validation of encrypted data, where we perform
  additional cryptographic operations and validate that the fields
  contained in the blob are valid.

This helps draw the line more clearly between the two validation types,
rather than splitting some payload-releated blinded hop processing
into the encrypted data processing part. The downside of this approach
(vs doing the blinded path payload check _after_ payload validation)
is that we have to pass additional context into payload validation
(ie, whether we got a blinding point in our UpdateAddHtlc - as we
already do for isFinalHop).
2024-04-25 09:15:57 -04:00
Carla Kirk-Cohen
c2c0158c84
htlcswitch: handle malformed HTLC with invalid onion blinding code
This commit adds handling for malformed HTLC errors related to blinded
paths. We expect to receive these errors _within_ a blinded path,
because all non-introduction nodes are instructed to return malformed
errors for failures.

Note that we may actually switch back to a malformed error later on if
we too are a relaying node in the route, but we handle that case the
incoming link.
2024-04-25 09:15:56 -04:00
Oliver Gugger
2089a88f4b
Merge pull request #7765 from ErikEk/retire-io-ioutil-dep
Remove io/ioutil package dependency
2024-04-25 13:17:15 +02:00
ziggie
f4b92eb3d4
docs: add release-notes. 2024-04-25 12:00:56 +01:00
ziggie
9f9d1c9e0b
itest: fix typo. 2024-04-25 12:00:26 +01:00
ziggie
fe829c2508
mod: bump neutrino version. 2024-04-25 12:00:26 +01:00
erik
0d94131fca doc: release note 2024-04-25 11:56:54 +02:00
erik
df4ddcc573 multi: replace ioutil.TempDir 2024-04-25 11:24:41 +02:00
erik
caf2419ff6 multi: replace ioutil.ReadDir 2024-04-25 11:24:17 +02:00
erik
c7f81d3142 multi: replace ioutil.Discard 2024-04-25 11:23:54 +02:00
erik
789c6bac8c multi: replace ioutil.WriteFile 2024-04-25 11:23:31 +02:00
erik
ab83343c87 multi: repleace ioutil.ReadFile 2024-04-25 11:22:43 +02:00
erik
619c8f4eb8 multi: repleace ioutil.ReadAll 2024-04-25 11:21:18 +02:00
Oliver Gugger
dcd8e16376
Merge pull request #8685 from ziggie1984/fix-bumpfee-immediate
fix lncli bumpfee flag parsing
2024-04-25 10:17:05 +02:00
Oliver Gugger
7f5f8065ca
Merge pull request #8672 from mohamedawnallah/makeDeleteAllPaymentsArgsRequired
rpcserver: Make sure the arguments are provided when calling `DeleteAllPayments` RPC
2024-04-25 10:02:59 +02:00
Oliver Gugger
8ce3622792
Merge pull request #8590 from ffranr/test-node-name-in-tmpdir
lntest: add test node name to tmp directory name
2024-04-24 20:06:04 +02:00
Oliver Gugger
fe26005228
Merge pull request #8592 from zhiqiangxu/master
itest: fix ascii
2024-04-24 11:05:21 -06:00
Oliver Gugger
5cf700d611
Merge pull request #8658 from hidewrong/master
chore: fix struct names
2024-04-24 10:56:20 -06:00
Mohamed Awnallah
b683b385cd
docs: update release-notes-0.18.0.md 2024-04-24 18:49:53 +02:00
Mohamed Awnallah
6e1d9b8d6a
lncli: update AllPayments in deletePayments 2024-04-24 18:49:01 +02:00
Mohamed Awnallah
3364d2f2d6
lntest: delete all payments in DeleteAllPayments 2024-04-24 18:48:59 +02:00
Mohamed Awnallah
5c3015b223
rpcserver: validate DeleteAllPayments options 2024-04-24 18:48:57 +02:00
Mohamed Awnallah
4f48cc69fb
lnrpc: add all_payments opt to DeleteAllPayments 2024-04-24 18:48:52 +02:00
ziggie
0ea45efe28
docs: add release-notes. 2024-04-24 16:56:09 +01:00
ziggie
64601a9bbe
wallet lncli: fix bumpfee parsing bug. 2024-04-24 16:56:09 +01:00
zhiqiangxu
64740e18cb itest: fix ascii 2024-04-24 23:30:03 +08:00
Oliver Gugger
acc595195c
Merge pull request #8545 from ziggie1984/dont-use-sweeper-unconfirmed-utxos
dont use sweeper unconfirmed utxos
2024-04-24 08:29:06 -06:00
ziggie
58e12884dc
docs: add release-notes. 2024-04-24 13:58:20 +01:00
ziggie
351e9a68dd
multi: Add tests to psbt and normal open channel flow.
Itests were added to the normal channel funding flow and the psbt
funding flow using unstable (unconfirmed sweeper inputs).
2024-04-24 13:58:20 +01:00
ziggie
b954ee4c72
rpcserver: allow unconf. inputs for psbt shim.
Allow unconfirmed inputs to be used when funding a channel via
the psbt channel opening flow. We do now check for unstable utxos.
2024-04-24 13:58:20 +01:00
ziggie
ab7634b276
multi: Add utxo restriction for batchchannel openings.
Add utxo restrictions for psbt internal wallet funded lightning
channels. This also includes batchopening channels backed by the
internal wallet.
2024-04-24 13:58:20 +01:00
ziggie
62a52b4d7c
multi: Utxo restriction single funding case.
Restrict the utxo selection when opening a single internal wallet
funded backed channel.
2024-04-24 13:58:19 +01:00
ziggie
2a88cf8eef
mod: update btcwallet version. 2024-04-24 13:58:19 +01:00
Oliver Gugger
39b7f1c4f4
GitHub: give tag to each cover job 2024-04-23 19:16:56 +02:00
Oliver Gugger
7468eb3416
GitHub: only run cover on some itests, send completion
We only want to run the coverage on some select tests, since we don't
want to make tests with slow backends even slower.
And because we use "parallel: true" when uploading the coverage results,
those will only be assembled once we send "parallel-finished: true"
using the goveralls action.
So we do that with a new "finish" job.
2024-04-23 19:16:56 +02:00
Oliver Gugger
8a5160e1de
multi: add test coverage for integration tests 2024-04-23 19:15:33 +02:00
Oliver Gugger
7fb233326e
Merge pull request #8674 from yyforyongyu/sweeper-remove-and-docs
sweep: add docs and remove dead code
2024-04-23 11:12:24 -06:00
yyforyongyu
e855421095
docs: update release notes 2024-04-23 23:19:41 +08:00
yyforyongyu
83024585bb
sweep: add README 2024-04-23 23:17:44 +08:00
Oliver Gugger
2b74a34301
Merge pull request #8678 from hieblmi/add-hieblmi-to-verify-install
Add hieblmi to verify install script
2024-04-23 06:16:43 -06:00
Slyghtning
ffaf4da1da
release: add hieblmi to verify install script 2024-04-23 10:03:23 +02:00
yyforyongyu
9c5124e117
sweep: remove unused param Fee 2024-04-23 04:44:00 +08:00
yyforyongyu
54aaeea491
sweep: remove dead code and dead tests 2024-04-23 04:44:00 +08:00
Olaoluwa Osuntokun
7af195768a
Merge pull request #8667 from lightningnetwork/elle-new-sweeper
Merge new sweeper branch to master
2024-04-22 11:20:49 -07:00
Oliver Gugger
73fd389e9a
Merge pull request #8627 from feelancer21/inbound-fees-reject
lnrpc: rejects positive inbound fees by default
2024-04-22 01:56:02 -06:00
Oliver Gugger
a201d5e365
Merge pull request #8661 from ProofOfKeags/feature/record-producer-axiom
tlv: add axiomatic RecordProducer implementation for Record
2024-04-22 01:42:06 -06:00
feelancer21
a2319e4313 lnrpc: rejects positive inbound fees by default
Positive inbound are now rejected by default. The user can enable positive
inbound fees with the option 'accept-positive-inbound-fees'.
2024-04-20 00:11:36 +02:00
yyforyongyu
4d96f9c4c1
docs: add release notes 2024-04-20 04:41:31 +08:00
yyforyongyu
d854c80aa7
itest+lntest: fix itest re the new sweeping behavior 2024-04-20 04:41:29 +08:00
yyforyongyu
e0f0f5c6a9
sweep: skip wallet inputs in isThirdPartySpent 2024-04-19 21:33:40 +08:00
yyforyongyu
a50cdd64c5
sweep: assign deadline values to inputs in handleNewInput
This commit changes how we transform from a deadline option to a
concrete deadline value - previously this is done when we decide to
cluster inputs, and we now move it to a step earlier - once an input is
received via `SweeperInput`, we will immediately transform its optional
deadline into a real value. For inputs that come with a deadline option,
since the Some will be used, it makes no difference. For inputs with
None as their deadlines, we need this change to make sure the default
deadlines are assigned accurately.
2024-04-19 21:33:39 +08:00
yyforyongyu
96883f307c
itest+sweep: add itest testSweepCommitOutputAndAnchor
This commit adds a test case to check the no deadline sweeping behavior.
The sweeper is updated to make sure it can handle the case for neutrino
backend.
2024-04-19 21:33:39 +08:00
yyforyongyu
f5a321d0d3
contractcourt: remove unused param to please linter 2024-04-19 21:33:39 +08:00
yyforyongyu
871cab4bc0
sweep: make sure inputs with different locktime values are not grouped 2024-04-19 21:33:39 +08:00
yyforyongyu
49cfb91af1
contractcourt: make sure sweep happens immediately on startup
This commit makes sure the time-sensitive outputs are swept immediately
during startup.
2024-04-19 21:33:39 +08:00
yyforyongyu
7abefa7760
cmd: update bumpfee, bumpclosefee and bumpforceclosefee 2024-04-19 21:33:38 +08:00
yyforyongyu
6f55a7af05
itest: add new test to check BumpFee and PendingSweeps 2024-04-19 21:33:38 +08:00
yyforyongyu
11a276e222
walletrpc+sweep: update PendingSweeps to return the new params 2024-04-19 21:33:38 +08:00
yyforyongyu
8804947179
walletrpc+sweep: refactor BumpFee to properly handle sweep request 2024-04-19 21:33:38 +08:00
yyforyongyu
94159e8950
walletrpc: update walletkit.proto to use the new sweep params 2024-04-19 21:33:38 +08:00
yyforyongyu
9be5b370a7
sweep+contractcourt: replace ParamsUpdate with Params 2024-04-19 21:33:38 +08:00
yyforyongyu
b6a2984167
sweep: allow specifying starting fee rate for fee func 2024-04-19 21:33:37 +08:00
yyforyongyu
db3aad31aa
lnrpc+sweep: rename Force to Immediate for clarity 2024-04-19 21:33:37 +08:00
yyforyongyu
19a599a1a9
sweep: catch third party spent in fee bumper for neutrino
This commit adds a new check for neutrino backend - when the inputs in
the sweeping tx are spent by a third party, we will send back a
`TxFailed` event to free the rest of the inputs for re-grouping.
2024-04-19 21:33:37 +08:00
yyforyongyu
563a5caed5
itest: fix watchtower test 2024-04-19 21:33:37 +08:00
yyforyongyu
d4de6dd236
itest+lntest: fix onchain tests 2024-04-19 21:33:37 +08:00
yyforyongyu
9c34eb7a56
itest: fix revocation itest 2024-04-19 21:33:37 +08:00
yyforyongyu
30c2b9f2df
itest: fix channel backup tests 2024-04-19 21:33:36 +08:00
yyforyongyu
f68c14321b
itest: fix multi-hop itest 2024-04-19 21:33:36 +08:00
yyforyongyu
ce58175314
itest+lntest: fix channel force close itest 2024-04-19 21:33:36 +08:00
yyforyongyu
6933c5a86c
itest: remove old CPFP tests
The old commitment deadline is removed as it's no longer relevant.
2024-04-19 21:33:36 +08:00
yyforyongyu
a1a480a81c
itest+lntest: add itest testSweepHTLCs to check HTLC sweepings 2024-04-19 21:33:36 +08:00
yyforyongyu
94e0e32c74
multi: add itest testSweepAnchorCPFPLocalForceClose
This commit adds an itest case that focuses on validating the CPFP logic
in anchor sweeping.
2024-04-19 21:33:36 +08:00
yyforyongyu
a2b8f4e19c
sweep: allow published input to be marked as PublishFailed
If anything happens during the fee bumping process, and causes the input
to be failed, we should be able to mark it as `PublishFailed`.
2024-04-19 21:33:35 +08:00
yyforyongyu
acde08c65a
contractcourt: offer second-level outputs at CSV-1
This commit moves the offering of second-level outputs one block
earlier. The sweeper will check the required locktime and wait until it
matures. This is needed so the second-level outputs can be aggregated
properly.
2024-04-19 21:33:35 +08:00
yyforyongyu
c644deb49f
contractcourt: add locks in SubscribeChannelEvents 2024-04-19 21:33:35 +08:00
yyforyongyu
07466c4f8c
multi: query circuit map inside contractcourt
This commit adds a new config method `QueryIncomingCircuit` that can be
used to query the payment's incoming circuit for giving its outgoing
circuit key.
2024-04-19 21:33:35 +08:00
yyforyongyu
4134b1c00a
sweep: make sure max fee rate can be reached
Previously we don't allow confTarget to be 0, which ended up the final
position being never reached. We fix it here by allowing confTarget to
be 0 in case the deadline has already been passed for a given input.
2024-04-19 21:33:35 +08:00
yyforyongyu
dc7d90c16f
contractcourt+sweep: offer direct-preimage spend via SweepInput
This commit removes the method `CreateSweepTx` and makes sure when
sweeping the htlc output via the direct-preimage spend, it's offered via
the `SweepInput` interface.
2024-04-19 21:33:35 +08:00
yyforyongyu
9c1e6941c3
contractcourt: specify deadline and budget for nursery 2024-04-19 21:33:34 +08:00
yyforyongyu
33abbe1942
contractcourt+lnd: make IncubateOutputs take fn.Option
`IncubateOutputs` never takes more than one HTLC, so we change the
params to be optional, which helps with the following commit where we
pass the deadline height when incubating outgoing HTLCs.
2024-04-19 21:33:34 +08:00
yyforyongyu
6f0c2b5bab
contractcourt: specify deadline and budget for anchor output 2024-04-19 21:33:34 +08:00
yyforyongyu
f4035ade05
contractcourt: calculate value left when searching for commit deadline
This commit changes `findCommitmentDeadline` to
`findCommitmentDeadlineAndValue` to calculate the value left from all
the time-sensitive HTLCs after subtracting their budgets. This value is
then used to calculate the budget to be used when sweeping the anchor
output.
2024-04-19 21:33:34 +08:00
yyforyongyu
cab180a52e
contractcourt: specify deadline and budget for htlc timeout 2024-04-19 21:33:34 +08:00
yyforyongyu
d1ad07fa21
contractcourt+lnwallet: specify deadline and budget for htlc success 2024-04-19 21:33:33 +08:00
yyforyongyu
01fd4e5642
contractcourt: specify deadline and budget for commit sweep 2024-04-19 21:33:33 +08:00
yyforyongyu
aa44197f88
contractcourt: init BudgetConfig in unit tests 2024-04-19 21:33:33 +08:00
yyforyongyu
0a611aae00
multi: add new config option BudgetConfig and NoDeadlineConfTarget
This commit adds a new group config `BudgetConfig` to allow users
specifying their own preference when sweeping outputs. And a new config
option `NoDeadlineConfTarget` is added in case the user wants to use a
different "lazy" conf target.
2024-04-19 21:33:33 +08:00
yyforyongyu
c44b8a4b45
lnd: start using BudgetAggregator 2024-04-19 21:33:33 +08:00
yyforyongyu
54ade99ce2
sweep: apply fn.NewSet and fn.Map in validateInputs 2024-04-19 21:33:33 +08:00
yyforyongyu
4c13ea1747
sweep: pass default deadline height when clustering inputs
This commit changes the method `ClusterInputs` to also take a default
deadline height. Previously, when calculating the default deadline
height for a non-time sensitive input, we would first cluster it with
other non-time sensitive inputs, then give it a deadline before we are
about to `sweep`. This is now moved to the step where we decide to
cluster inputs, allowing time-sensitive and non-sensitive inputs to be
grouped together, if they happen to share the same deadline heights.
2024-04-19 21:33:32 +08:00
yyforyongyu
15588355b3
sweep: exit when handleNewInput fails
When `handleNewInput` fails, it means there's something terribly wrong
with the chain backend, which means we need to stop the current process
and let user handle it.
2024-04-19 21:33:32 +08:00
yyforyongyu
e771993785
multi: make input.OutPoint return wire.OutPoint 2024-04-19 21:33:32 +08:00
yyforyongyu
fce86f9b22
sweep: cancel rebroadcasting of failed/replaced/confirmed txns 2024-04-19 21:33:32 +08:00
yyforyongyu
106b97ce33
sweep: improve loggings 2024-04-19 21:33:32 +08:00
yyforyongyu
59526988cf
sweep: add a dedicated method to create sweeping txns
This takes the old `createSweepTx` and refactors it to be
sweep-specific. A sweeping txns differs from a normal tx as it doesn't
need to take outputs as params.
2024-04-19 21:33:32 +08:00
yyforyongyu
59fbcb18d5
sweep: rename fee() to feeWithParent() for clarity
To make sure the caller has a better idea about what this method is
doing.
2024-04-19 21:33:31 +08:00
yyforyongyu
370e4ce98d
lnd+sweep: remove unused config MaxSweepAttempts 2024-04-19 21:33:31 +08:00
yyforyongyu
0b30d4ba3e
lnrpc+sweep: make FeeEstimateInfo an optional param
This is needed as we soon will remove the usage of the fee preference
when sweeping inputs.
2024-04-19 21:33:31 +08:00
yyforyongyu
658ba445ea
sweep: delay sweeping inputs with future locktimes
This commit fixes an edge case that the sweeper's best known block
height is behind arbitrator's, which may cause an issue when creating
sweeping tx, as we may end up using an old block height from
arbitrator's view.
2024-04-19 21:33:31 +08:00
yyforyongyu
0527b2d7a6
sweep: make sure exclusive inputs are not grouped
This commit fixes the grouping logic in `BudgetAggregator` to make sure
the exclusive inputs are never grouped.
2024-04-19 21:33:31 +08:00
yyforyongyu
0fc5301d12
lnwallet+sweep: cap conf target used in fee estimator 2024-04-19 21:33:31 +08:00
yyforyongyu
1fa8ca72ee
sweep: fix handlePendingSweepsReq linter issue
Turns out the param was never used, we now fix it by sending the
response in the method and also catch the quit channel.
2024-04-19 21:33:30 +08:00
yyforyongyu
28df2d7327
lnrpc+sweep: make sure public interface takes public types as params
This commit exports and renames the following variable names:
- `PendingInput` is now `PendingInputResponse` as it's responding to a
  request.
- `pendingInput` is now renamed and exported as `SweeperInput`.
- `pendingInputs` is now renamed and exported as `InputsMap`.

This commit is first made from running:
```
gofmt -d -w -r 'PendingInput -> PendingInputResponse' .
gofmt -d -w -r 'pendingInput -> SweeperInput' .
gofmt -d -w -r 'pendingInputs -> InputsMap' .
```
And followed by some docs and variable names fixes.
2024-04-19 21:33:30 +08:00
yyforyongyu
9e7d4b7e0b
sweep: rename pendingInputs to inputs on sweeper
There's no need use the prefix `pending` as the inputs in the sweeper
can only be pending, so it's renamed, also to avoid the confusion with
the type `pendingInputs`.
2024-04-19 21:33:30 +08:00
yyforyongyu
0063770cb7
sweep: remove the prefix used in SweepState types
Don't prefix with `State` we already have information to determine what
the type is. Generated this commit using,
```
gofmt -d -w -r 'StateInit -> Init' .
gofmt -d -w -r 'StatePendingPublish -> PendingPublish' .
gofmt -d -w -r 'StatePublished -> Published' .
gofmt -d -w -r 'StatePublishFailed -> PublishFailed' .
gofmt -d -w -r 'StateSwept -> Swept' .
gofmt -d -w -r 'StateExcluded -> Excluded' .
gofmt -d -w -r 'StateFailed -> Failed' .
```

and some string matching to fix the docs.
2024-04-19 21:33:30 +08:00
yyforyongyu
19265ac8ed
sweep: make sure non-fee related errors are notified
So these inputs can be retried by the sweeper.
2024-04-19 21:33:30 +08:00
yyforyongyu
b76ccab17b
docs: update release notes for fee bumper 2024-04-19 21:33:30 +08:00
yyforyongyu
94390fc775
itest: fix existing itests 2024-04-19 21:33:29 +08:00
yyforyongyu
7fb18bc0d5
sweep: increase delta fee rate precision in fee function
This commit adds a private type `mSatPerKWeight` that expresses a given
fee rate in millisatoshi per kw. This is needed to increase the
precision of the fee function. When sweeping anchor inputs, if using a
deadline delta of over 1000, it's likely the delta will be 0 sat/kw due
to precision.
2024-04-19 21:33:29 +08:00
yyforyongyu
23feef7e6c
lnd: init publisher when creating new server 2024-04-19 21:33:29 +08:00
yyforyongyu
90e727a776
sweep: add monitor loop to TxPublisher
This commit finishes the implementation of `TxPublisher` by adding the
monitor process. Whenever a new block arrives, the publisher will check
all its monitored records and attempt fee bumping them if necessary.
2024-04-19 21:33:29 +08:00
yyforyongyu
11f7e455d1
lnwallet+sweep: introduce TxPublisher to handle fee bump
This commit adds `TxPublisher` which implements `Bumper` interface. This
is part one of the implementation that focuses on implementing the
`Broadcast` method which guarantees a tx can be published with
RBF-compliant. It does so by leveraging the `testmempoolaccept` API,
keep increasing the fee rate until an RBF-compliant tx is made and
broadcasts it.

This tx will then be monitored by the `TxPublisher` and in the following
commit, the monitoring process will be added.
2024-04-19 21:33:29 +08:00
yyforyongyu
ecd471ac75
lnwallet+sweep: calculate max allowed feerate on BumpResult
This commit adds the method `MaxFeeRateAllowed` to calculate the max fee
rate. The caller may specify a large MaxFeeRate value, which cannot be
cover by the budget. In that case, we default to use the max feerate
calculated using `budget/weight`.
2024-04-19 21:33:29 +08:00
yyforyongyu
f85661d94a
lnwallet+sweep: add new method CheckMempoolAcceptance 2024-04-19 21:33:28 +08:00
yyforyongyu
cd5d074099
sweep: add FeeFunction interface and a linear implementation
This commit adds a new interface, `FeeFunction`, to deal with
calculating fee rates. In addition, a simple linear function is
implemented, hence `LinearFeeFunction`, which will be used to calculate
fee rates when bumping fees. Check #4215 for other type of fee functions
that can be implemented.
2024-04-19 21:33:28 +08:00
yyforyongyu
f7bc82a22d
sweep: remove FeeRate() from InputSet interface
As shown in the following commit, fee rate calculation will now be
handled by the fee bumper, hence there's no need to expose this on
`InputSet` interface.
2024-04-19 21:33:28 +08:00
yyforyongyu
6d6c544414
sweep: remove RBF related tests
As there will be dedicated new tests for them.
2024-04-19 21:33:28 +08:00
yyforyongyu
21aff324a3
sweeper: fix existing sweeper tests 2024-04-19 21:33:28 +08:00
yyforyongyu
1187b868ad
sweep: introduce Bumper interface to handle RBF
This commit adds a new interface, `Bumper`, to handle RBF for a given
input set. It's responsible for creating the sweeping tx using the input
set, and monitors its confirmation status to decide whether a RBF should
be attempted or not.

We leave implementation details to future commits, and focus on mounting
this `Bumper` interface to our sweeper in this commit.
2024-04-19 21:33:27 +08:00
yyforyongyu
a088501e47
sweep: introduce BudgetAggregator to cluster inputs by deadlines
This commit adds `BudgetAggregator` as a new implementation of
`UtxoAggregator`. This aggregator will group inputs by their deadline
heights and create input sets that can be used directly by the fee
bumper for fee calculations.
2024-04-19 21:33:27 +08:00
yyforyongyu
e7400f6a94
sweep: introduce BudgetInputSet to manage budget-based inputs
This commit adds `BudgetInputSet` which implements `InputSet`. It
handles the pending inputs based on the supplied budgets and will be
used in the following commit.
2024-04-19 21:33:27 +08:00
yyforyongyu
bd5eec8e1f
sweep: refactor markInputsPendingPublish to take InputSet
This commit changes `markInputsPendingPublish` to take `InputSet` only.
This is needed for the following commits as we won't be able to know the
tx being created beforehand, yet we still want to make sure these inputs
won't be grouped to another input set as it complicates our RBF process.
2024-04-19 21:33:27 +08:00
yyforyongyu
6202c59cb3
sweep: change markInputsPublishFailed to take outpoints
This way it's easier to pass values to this method in various callsites.
2024-04-19 21:33:27 +08:00
yyforyongyu
db7eae97ff
sweep: expand InputSet with more interface methods
This commit adds more interface methods to `InputSet` to prepare the
addition of budget-based aggregator.
2024-04-19 21:33:27 +08:00
yyforyongyu
d0a8f27d84
sweep: change MaxInputsPerTx from int to uint32 2024-04-19 21:33:26 +08:00
yyforyongyu
521b1fc34a
itest+lntest: fix itest re the new block driven behavior 2024-04-19 21:33:26 +08:00
yyforyongyu
558d9bd3ce
walletrpc: pass Force flag when sweeping via BumpFee 2024-04-19 21:33:26 +08:00
yyforyongyu
d8f976f8fc
trivial: fix comments and docs 2024-04-19 21:33:26 +08:00
yyforyongyu
465332f409
multi: deprecate batchwindowduration config option 2024-04-19 21:33:26 +08:00
yyforyongyu
c03509397f
sweep: add mocks and patch unit test for sweepPendingInputs 2024-04-19 21:33:26 +08:00
yyforyongyu
210b7838c7
sweep: move mocks into one file 2024-04-19 21:33:25 +08:00
yyforyongyu
ae43764e31
sweep: remove deprecated rand.Seed 2024-04-19 21:33:25 +08:00
yyforyongyu
0110a09595
sweep: decrease coin selection lock scope
This commit changes how `WithCoinSelectLock` is used - previously the
lock is held when creating the input sets, now it's only be held after
the input sets have been created and explicitly signal they need wallet
inputs.
2024-04-19 21:33:25 +08:00
yyforyongyu
b536e9bd3f
sweep: deepen the interface Aggregator
This commit makes the `ClusterInputs` directly returning the `InputSet`
so the sweeper doesn't know about the existence of `Cluster` interface.
This way we can have a deeper interface as the sweeper only needs to
interact with `Aggregator` only to get the final input sets, leaving the
implementation details being managed by `SimpleAggregator` and future
aggregators.
2024-04-19 21:33:25 +08:00
yyforyongyu
1530fee9b3
sweep: add new inteface InputSet to manage inputs in a tx
Previously the fee rate is tracked at cluster level, which may not be
accurate as each cluster is then divided into input sets. And these sets
are what's actually included in the final sweeping tx. To properly
reflect the final fee rate used in the sweeping tx, `InputSet` is added
so more customized clustering logic can be implemented in the future.
For intance, atm it's clustered by fee rates, while we may also cluster
by deadlines, urgencies, etc.
2024-04-19 21:33:25 +08:00
yyforyongyu
9d5ddf29f3
sweep: add new interface Cluster to manage grouping inputs
This commit adds a new interface `Cluster` to manage cluster-level
inputs grouping. This new interface replaces the `inputCluster` and will
be futher refactored so the sweeper can use a much smaller coin
selection lock.
2024-04-19 21:33:25 +08:00
yyforyongyu
a7e9c08baf
sweep: make sweeper block-driven instead of time-driven
This commit changes the source that drives the state changes in the
sweeper. Previously we used a ticker with default interval of 30s to
trigger sweepings periodically. The assumption is, within this 30s we'd
batch multiple inputs into one transaction to maximize profits. However,
the efficacy of this batch is questionable.

At a high level, we can put our inputs into two categories - one that's
forced, and one that's not. For forced inputs, we should sweep them
immediately as the force flag indicates they are very urgent, eg,
CPFPing the force closing tx. For non-forced inputs, such as anchors
or HTLCs with CLTV that's far away, we can wait to sweep them till a new
block comes in and triggers the sweeping process.

Eventually, all inputs will be deadline-aware, and the sweeper will
consult our fee bumper about the most economical fee rate to be used for
a given deadline. Since the deadlines here are blockstamp, it's also
easier to manage them if the sweeper is also using blockstamp instead of
timestamp.
2024-04-19 21:33:24 +08:00
yyforyongyu
df4e51e2e0
sweep: refactor attachAvailableRBFInfo to decideStateAndRBFInfo
Thus this method `decideStateAndRBFInfo` won't touch the state changes
of a given input.
2024-04-19 21:33:24 +08:00
yyforyongyu
6f5b7a9fd3
lntest+itest: fix testOpenChannelLockedBalance 2024-04-19 21:33:24 +08:00
yyforyongyu
536ac9f8a4
docs: update release notes 2024-04-19 21:33:24 +08:00
yyforyongyu
5fce91caf9
chainntnfs+sweep: add LookupInputMempoolSpend and use it in the
sweeper

This commit implements a new method, `LookupInputMempoolSpend` to do
lookups in the mempool. This method is useful in the case when we only
want to know whether an input is already been spent in the mempool by
the time we call.
2024-04-19 21:33:24 +08:00
yyforyongyu
ebef3679ac
btcdnotify: use chain.NewRPCClientWithConfig to init RPC client
So we can use the methods implemented on the chain RPC client.
2024-04-19 21:33:24 +08:00
yyforyongyu
b5e4384e24
lnd+sweep: remove unused NextAttemptDeltaFunc 2024-04-19 21:33:23 +08:00
yyforyongyu
5496d02b27
sweep: fix logging 2024-04-19 21:33:23 +08:00
yyforyongyu
124d1764f7
sweep: remove unused param testSpendChan 2024-04-19 21:33:23 +08:00
yyforyongyu
fd922942a7
sweep: patch unit tests for markInputsSwept and markInputsPendingPublish
Now that the refactor is done, we start patching unit tests for these
two methods. Minor changes are also made based on the feedback from the
tests.
2024-04-19 21:33:23 +08:00
yyforyongyu
34b6a3d718
sweep: add method markInputFailed 2024-04-19 21:33:23 +08:00
yyforyongyu
a8f5a09dea
sweep: don't give up an input based on number of attempts
This commit removes the logic where we remove an input when it's been
published more than 10 times. This is needed as in our future fee
bumper, we might start with a low fee and rebroadcast the same input for
hundred of blocks.
2024-04-19 21:33:23 +08:00
yyforyongyu
8b876be3b6
sweep: add fee info for published inputs
This commit attaches RBFInfo to an input before it's been published or
it's already been published.
2024-04-19 21:33:22 +08:00
yyforyongyu
a263d68fb9
sweep: delete pending inputs based on their states
This commit uniforms and put the deletion of pending inputs in a single
point.
2024-04-19 21:33:22 +08:00
yyforyongyu
47478718d4
multi: query mempool spend when a new input is received
This commit changes how a new input sweep request is handled - now we
will query the mempool and see if it's already been spent. If so, we'll
update its state as we may need to RBF this input.
2024-04-19 21:33:22 +08:00
yyforyongyu
6a2e3fb203
sweep: make pending input stateful
This commit starts tracking the state of a pending input so it's easier
to control the sweeping flow and provide RBF awareness in the future.
2024-04-19 21:33:22 +08:00
yyforyongyu
1e6e443a0b
docs: update release notes 2024-04-19 21:33:22 +08:00
yyforyongyu
61e9c11881
rpcserver: skip calculating fee rate for PSBT funding 2024-04-19 21:33:22 +08:00
yyforyongyu
519a8749ef
lntest: reflect the updated fee estimator in tests 2024-04-19 21:33:21 +08:00
yyforyongyu
1870caf39c
sweep+lnd: introduce UtxoAggregator to handle clustering inputs
This commit refactors the grouping logic into a new interface
`UtxoAggregator`, which makes it easier to write tests and opens
possibility for future customized clustering strategies.

The old clustering logic is kept as and moved into `SimpleAggregator`.
2024-04-19 21:33:21 +08:00
yyforyongyu
3bcac318eb
sweep+lnrpc: add new interface FeePreference
This commit adds a new interface `FeePreference` which makes it easier
to write unit tests and allows more customized implementation in
following commits.
2024-04-19 21:33:21 +08:00
yyforyongyu
530eed92a0
multi: rename FeePreference to FeeEstimateInfo
Results from running,
```
gofmt -d -w -r 'FeePreference -> FeeEstimateInfo' .
```
2024-04-19 21:33:21 +08:00
yyforyongyu
6ff6c86155
multi: merge DetermineFeePerKw and Estimate
This commit moves `DetermineFeePerKw` into the `Estimate` method on
`FeePreference`. A few callsites previously calling `DetermineFeePerKw`
without the max fee rate is now also temporarily fixed by forcing them
to use `Estimate` with the default sweeper max fee rate.
2024-04-19 21:33:21 +08:00
yyforyongyu
18b06b7303
sweep: replace feeRateForPreference with Estimate
This commit refactors the sweeper so the method `feeRateForPreference`
is now moved to `FeePreference`, which makes our following refactor
easier to handle.
2024-04-19 21:33:20 +08:00
yyforyongyu
84a6fdcda3
sweep+contractcourt: track best height in UtxoSweeper
Thus we can use shorter method signatures. In doing so we also remove an
old TODO in one use case of `CreateSweepTx`.
2024-04-19 21:33:20 +08:00
yyforyongyu
ca0813b1bf
docs: update release docs 2024-04-19 21:33:20 +08:00
yyforyongyu
f13a3a8053
sweep: use testify/mock for MockSweeperStore 2024-04-19 21:33:20 +08:00
yyforyongyu
8b9d5e0548
sweep: add new methods GetTx and DeleteTx to manage TxRecord 2024-04-19 21:33:20 +08:00
yyforyongyu
b37444d0de
sweep: expand sweeper store to also save RBF-related info
This commit modifies the sweeper store to save a `TxRecord` in db
instead of an empty byte slice. This record will later be used to bring
RBF-awareness to our sweeper.
2024-04-19 21:33:20 +08:00
yyforyongyu
1ace1fdf4c
sweep: return fees from method createSweepTx
Which will be used to make the sweeper RBF-aware.
2024-04-19 21:33:19 +08:00
yyforyongyu
e86843da6e
sweep: rename NotifyPublishTx to StoreTx
To properly reflect what the method really does. We also changes the
method signature so only a hash is used.
2024-04-19 21:33:19 +08:00
Olaoluwa Osuntokun
d4c1937572
Merge pull request #8573 from guggero/bitcoind-27
GitHub: use bitcoind v27.0 for CI
2024-04-18 14:36:58 -07:00
Olaoluwa Osuntokun
63ef2f8433
Merge pull request #8643 from Roasbeef/kvdb-top-level-module-bump
build: bump top level module to kvdb v1.4.6
2024-04-18 14:22:08 -07:00
Keagan McClelland
6257df31e0 tlv: add axiomatic RecordProducer implementation for Record
This commit introduces a RecordProducer implementation for Record
that serves as the identity function. This makes it easier for us
to mix Primitive and Dynamic records in the same RecordProducer
collections.
2024-04-18 12:03:27 -06:00
Oliver Gugger
a42fc24220
docs: add release notes 2024-04-18 18:13:02 +02:00
Oliver Gugger
f41d6087d1
mod: bump btcd to fix sendrawtransaction max fee issue 2024-04-18 17:44:04 +02:00
Oliver Gugger
817ddb807b
GitHub+scripts: use bitcoind v27.0 2024-04-18 17:44:04 +02:00
hidewrong
8afb978c81 chore: fix struct names
Signed-off-by: hidewrong <hidewrong@outlook.com>
2024-04-17 11:19:31 +08:00
Oliver Gugger
2ccf58e2af
Merge pull request #8630 from guggero/addr-master-fingerprint
mod: bump btcwallet to latest version
2024-04-16 07:00:13 +00:00
Olaoluwa Osuntokun
2162c943de
build: bump top level module to kvdb v1.4.6 2024-04-12 15:32:22 -07:00
Olaoluwa Osuntokun
07b6af41db
Merge pull request #8642 from Roasbeef/kvdb-update
kvdb: bump to sqldb/v1.0.1
2024-04-12 15:29:28 -07:00
Olaoluwa Osuntokun
06e4ffb3f3
kvdb: bump to sqldb/v1.0.1
Post merge module clean up after
https://github.com/lightningnetwork/lnd/pull/8611.
2024-04-12 15:16:26 -07:00
Oliver Gugger
f35ce0981d
docs: update release notes 2024-04-12 08:34:56 +02:00
Oliver Gugger
333fc6eb1d
mod: bump btcwallet to latest version
Fixes #8626.
This commit updates btcwallet to the latest version that correctly
includes the MasterKeyFingerprint for all generated addresses, including
change addresses derived from imported watch-only accounts.
2024-04-12 08:34:54 +02:00
Olaoluwa Osuntokun
1c229e4422
Merge pull request #8611 from bhandras/sql-tx-retry
sqldb+kvdb: unify SQL error mapping and transaction retry for between the `kvdb` and `sqldb` packages
2024-04-11 15:41:56 -07:00
Andras Banki-Horvath
024598266d
docs: update release notes for 0.18 2024-04-11 15:04:04 +02:00
Andras Banki-Horvath
043e4aff01
sqldb+invoices: fix ordering bug in FilterInvoices
Previously if the `reverse` named arg was unset (value of NULL), then
SQL would order by NULL instead of ID causing undifined ordering of the
returned rows. To fix that we check for NULL and also make sure to set
the `reverse` arg in the code explicitly as it in the generated code it
is an `interface{}` instead of `bool`.
2024-04-11 15:04:04 +02:00
Andras Banki-Horvath
478ae1e9b0
sqldb: cleanup scope state reset by adding reset closure to ExecTx
For SQL transactions, we often accumulate results in variables declared
outside the closure's scope. To eliminate the need for manually clearing
these containers, we introduce a reset function to ExecTx, mirroring the
approach already adopted in kvdb.
2024-04-11 15:04:04 +02:00
Andras Banki-Horvath
c6073a14ca
sqldb: ensure that we're using serializable isolation 2024-04-11 15:04:04 +02:00
Olaoluwa Osuntokun
0609431a0c
channeldb: fix payment control unit tests w/ errors.Is 2024-04-11 15:04:04 +02:00
Oliver Gugger
648fb22f63
multi: wrap all errors 2024-04-11 15:04:03 +02:00
Andras Banki-Horvath
9a28a4c105
kvdb: remove the unused SQL error mappers 2024-04-11 15:04:03 +02:00
Olaoluwa Osuntokun
cd0ca43a00
kvdb: don't do a critical log for db serialization errors
In this commit, we fix a bug that would cause the entire db to shutdown
if hit a panic (since db operations in the main buckets exit with a
panic) while executing a txn call back. This might be a postgres error
we need to check, so we don't want to bail out, and instead want to pass
up the error to the caller so we can retry if needed.
2024-04-11 15:04:03 +02:00
Olaoluwa Osuntokun
120d6dd297
channeldb: explicitly catch error in pruneGraphNodes
With the new postgres concurrency control, an error may come from a
bucket function that's actually a postgres error. In this case, we need
to return early so we can retry the txn. Otherwise, we'll be working
with an aborted tx, and never actually return the error so we don't auto
retry.
2024-04-11 15:04:03 +02:00
Olaoluwa Osuntokun
329fcc6498
kvdb+sqldb: update SQL error parsing to account for non wrapped errs
Some sub-systems like btcwallet will return an error from the database,
but they won't properly wrap it. As a result, we were unable to actually
catch the serialization errors in the first place. To work around this,
we'll now attempt to parse the error string directly.
2024-04-11 15:04:03 +02:00
Andras Banki-Horvath
43f4b14c28
kvdb+sqldb: use the same tx retry helper 2024-04-11 15:04:02 +02:00
Oliver Gugger
976f5d2760
Merge pull request #8603 from bhandras/sqldb-go-package
sqldb+invoices: turn sqldb into a go module
2024-04-10 08:51:00 +00:00
Oliver Gugger
971281deae
Merge pull request #8576 from mohamedawnallah/check-outbound-peers-chain-backend
healthcheck: make sure chain backend has enough outbound peers
2024-04-10 07:39:16 +00:00
Andras Banki-Horvath
c804894849
docs: update release notes for 0.18 2024-04-09 20:46:12 +02:00
Andras Banki-Horvath
a7bd9701b1
github: update gRPC pin to v1.59.0 2024-04-09 20:46:11 +02:00
Andras Banki-Horvath
8f729241d9
sqldb: turn sqldb into a go package 2024-04-09 20:46:11 +02:00
Andras Banki-Horvath
7f5c8219ef
sqldb+invoices: move SQL invoice store impl to invoices package 2024-04-09 20:46:11 +02:00
Andras Banki-Horvath
6d316ef56f
sqldb: export sql null type helpers 2024-04-09 20:46:11 +02:00
Mohamed Awnallah
130fdbde73
docs: update the release-notes-0.18.0.md 2024-04-09 19:08:38 +02:00
Mohamed Awnallah
df9f1485a7
chainreg: add checkOutboundPeers function
In this commit we add `checkOutboundPeers` function
to the `cc.HealthCheck` function.
2024-04-09 19:08:36 +02:00
Oliver Gugger
6377f98536
Merge pull request #8615 from ProofOfKeags/bugfix/revert-compulsory-gossip-queries
Revert "feature: make gossip queries compulsory"
2024-04-05 06:57:39 +00:00
Keagan McClelland
939e3cc6c1 docs: update release notes 2024-04-04 12:28:37 -07:00
Oliver Gugger
e509657fac
Merge pull request #8620 from twofaktor/patch-1
[FIX] Small parenthesis error on v0.18 release notes
2024-04-04 10:21:19 +00:00
Olaoluwa Osuntokun
9bafcb2e3e
Merge pull request #8160 from carlaKC/7298-2-forwardblindedroutes
[2/3]: Support Forwarding of Blinded Payments
2024-04-03 16:48:12 -07:00
Keagan McClelland
dd2da29cba peer: re-add AuthGossiper nil check 2024-04-03 15:47:50 -07:00
⚡️2FakTor⚡️
142fdbf1fd
Update release-notes-0.18.0.md 2024-04-03 20:30:00 +02:00
Carla Kirk-Cohen
2188dd9d2b
docs: release notes 18.0 2024-04-03 09:19:44 -04:00
Carla Kirk-Cohen
6e5eead617
lncfg: disable allowing blinded routes in daemon but not itests
This commit turns off route blinding for the daemon while we're waiting
on full handling for blinded errors. The feature remains on for itests
so that tests covering blinding can run as usual.
2024-04-03 09:19:43 -04:00
Carla Kirk-Cohen
0d9a184df8
lntest: dispatch and intercept payment to blinded route
We don't support receiving blinded in this PR - just intercept and
settle instead. The HTLC's arrival on the interceptor indicates that
it was successfully forwarded on a blinded hop.
2024-04-03 09:19:42 -04:00
Carla Kirk-Cohen
69e1162dd1
lntest: add route construction to blinded forwarding test 2024-04-03 09:19:41 -04:00
Carla Kirk-Cohen
58dda83b22
lntest: add helper to create blinded route 2024-04-03 09:19:40 -04:00
Carla Kirk-Cohen
a72aaa3d84
lntest: add setup for blinded route forwarding itest
Note: the itest is broken up into multiple commits to make it
more readable, they can be squashed post-review.
2024-04-03 09:19:39 -04:00
Carla Kirk-Cohen
7e4f3d3b1d
htlcswitch: reject HTLCs that use use as introduction if disabled
Reject any HTLCs that use us as an introduction point in a blinded
route if we have disabled route blinding. We have to do this after
we've processed the payload, because we only know we're an introduction
point once we've processed the payload itself.
2024-04-03 09:19:39 -04:00
Carla Kirk-Cohen
6d41037628
htlcswitch: set forwarding information from encrypted data
If we received a payload with a encrypted data point set, our forwarding
information should be set from the information in our encrypted blob.
This behavior is the same for introduction and relying nodes in a
blinded route.
2024-04-03 08:52:26 -04:00
Carla Kirk-Cohen
2029a06918
multi: return parsed types from payload
To separate blinded route parsing from payload parsing, we need to
return the parsed types map so that we can properly validate blinded
data payloads against what we saw in the onion.
2024-04-03 08:52:25 -04:00
Carla Kirk-Cohen
1e6fae37f7
htlcswitch: add blinding point to sphinx iterator for decoding 2024-04-03 08:52:25 -04:00
Carla Kirk-Cohen
da76d05fa5
htlcswitch: add NextBlinding to ForwardingInfo and set in UpdateAddHtlc
When we have a HTLC that is part of a blinded route, we need to include
the next ephemeral blinding point in UpdateAddHtlc for the next hop. The
way that we handle the addition of this key is the same for introduction
nodes and relaying nodes within the route.
2024-04-03 08:38:24 -04:00
Carla Kirk-Cohen
ca6d414308
multi: validate contents in blinded data against payload 2024-04-03 08:38:23 -04:00
Carla Kirk-Cohen
03f6c5cd0a
htlcswitch: add blinding kit to handle encrypted data in blinded routes
This commit introduces a blinding kits which abstracts over the
operations required to decrypt, deserialize and reconstruct forwarding
data from an encrypted blob of data included for nodes in blinded
routes.
2024-04-03 08:38:22 -04:00
Carla Kirk-Cohen
040fcb0f92
multi: add option to disable route blinding, rejecting at link
Add an option to disable route blinding, failing back any HTLC with
a blinding point set when we haven't got the feature enabled.

Note that this commit only handles the case where we're chosen as the
relaying node (where the blinding point is in update_add_htlc), we'll
add handling for the introduction node case once we get to handling of
blinded payloads).
2024-04-03 08:35:41 -04:00
Keagan McClelland
dad53b3f9a Revert "feature: make gossip queries compulsory"
This reverts commit 717facc202.

It turns out that we can't do this since it would result in
incompatibility with LDK. The spec has been updated to reallow
optional gossip queries so we revert this commit.
2024-04-02 16:43:27 -07:00
Carla Kirk-Cohen
019b8fa8aa
hop: add function for calculating forwarding amount
Co-authored-by: Calvin Zachman <calvin.zachman@protonmail.com>
2024-04-02 15:44:06 -04:00
Carla Kirk-Cohen
7fd9c2a7f8
multi: use some record for payment descriptor blinding point 2024-04-02 15:44:05 -04:00
Oliver Gugger
b1175514f9
Merge pull request #8515 from mohamedawnallah/add-coin-selection-strategy-on-chain-rpc
coin select: add coin selection strategy option to all on-chain RPCs
2024-04-02 11:20:08 +00:00
Oliver Gugger
b331e73b67
Merge pull request #8609 from ziggie1984/master
lnd: fix sweepall argument call.
2024-04-02 11:04:37 +00:00
András Bánki-Horváth
16c8339034
Merge pull request #8595 from bhandras/sqldb-invoices-reset-on-retry
sqldb: reset out of scope containers on potential ExecTx retry
2024-04-02 09:43:59 +02:00
ziggie
b019657d19
docs: add release-notes. 2024-04-01 20:05:28 +01:00
ziggie
eba4911599
lnd: fix sweepall argument call.
maxFeeRate and feePerKw were switched in CraftSweepAllTx.
2024-04-01 20:00:54 +01:00
Mohamed Awnallah
31526a0191
docs: update the release-notes-0.18.0 2024-04-01 19:08:24 +02:00
Mohamed Awnallah
1a2d50d385
multi: add coin selection strategy option to all on-chain rpcs
In this commit, we add the coin selection strategy option to the following
on-chain RPCs `fundpsbt`, `batchopenchannel`, `estimatefee`, `sendcoins`,
`sendmany`, and `sendoutputs`.
2024-04-01 19:08:22 +02:00
Mohamed Awnallah
a0b0e7aa62
lncli: add coin selection strategy option to on-chain rpc commands
In this commit we add coin selection strategy option to the
following on-chain rpc commands `fundpsbt`, `fundtemplatepsbt`,
`batchopenchannel`, `estimatefee`, `sendcoins`, and `sendmany`.
2024-04-01 19:08:19 +02:00
Mohamed Awnallah
7c2c0dcf98
lnrpc+lnd+config: add coin selection strategy to all on-chain rpcs
In this commit, we add the coin selection strategy option
to all on-chain RPCs `FundPsbt`, `BatchOpenChannel`, `EstimateFee`,
`SendMany`, `SendCoins`, `SendOutputs`.
2024-04-01 19:08:01 +02:00
Olaoluwa Osuntokun
5599b3c9e2
Merge pull request #6934 from bottlepay/inbound-fees-send-support
routing: inbound fees send support
2024-03-31 10:54:09 -07:00
Joost Jager
0bae781785 routing: add inbound fee support to pathfinding
Add sender-side support for inbound fees in pathfinding
and route building.
2024-03-31 18:12:28 +02:00
Joost Jager
d97e7d30fb channeldb/test: refactor TestGraphCacheForEachNodeChannel 2024-03-31 18:12:28 +02:00
Joost Jager
9d4251c18d routing/test: test local unified edge 2024-03-31 18:12:28 +02:00
Joost Jager
e0a080454a routing: track unifiedPolicyEdge
Preparation so that we can have the inbound fee available
in addition to the outgoing policy.
2024-03-31 18:12:28 +02:00
Olaoluwa Osuntokun
a6d4bb5c89
Merge pull request #6703 from bottlepay/inbound-fees
htlcswitch: add inbound routing fees receive support
2024-03-31 08:43:09 -07:00
Joost Jager
ba21ca7609 itest: multi-hop payment test with negative inbound fee
Ensure that negative fees are backwards compatible.
2024-03-31 16:49:19 +02:00
Joost Jager
763787e08c routing+lnrpc: add inbound fee policy update 2024-03-31 16:49:19 +02:00
Joost Jager
e8c97deaef htlcswitch: add receiver-side inbound fee support 2024-03-31 16:49:19 +02:00
Joost Jager
3e6adbf1c0 lnwire+channeldb: parse inbound fees
In this commit, the tlv extension of a channel update message is parsed.
If an inbound fee schedule is encountered, it is reported in the
graph rpc calls.
2024-03-31 16:33:26 +02:00
Olaoluwa Osuntokun
1d61de28c0
Merge pull request #8159 from carlaKC/7298-1-forwardblindedroutes
[1/3]: Preparatory work for Forwarding Blinded Routes
2024-03-28 15:13:05 -07:00
Olaoluwa Osuntokun
41cdb0fce5
Merge pull request #8599 from yyforyongyu/update-fn
gomod: bump `fn` version to v1.0.5
2024-03-28 14:28:21 -07:00
yyforyongyu
252b909867
gomod: bump fn version to v1.0.5 2024-03-28 23:52:31 +08:00
Andras Banki-Horvath
a1a7982646
sqldb: reset out of scope containers on potential ExecTx retry
As SQL serializaton errors can lead to transaction retries we need to
ensure that we reset any out of scope containers where we accumulate
results. Otherwise partial data from a previously executed transacton
retry may be returned along with the latest result.
2024-03-27 17:59:54 +01:00
Carla Kirk-Cohen
2130022e20
docs: release notes for blinded routes prep work 2024-03-27 09:39:03 -04:00
Carla Kirk-Cohen
d67f65212b
routing: fix comment on blinded path cltv delta 2024-03-27 09:39:02 -04:00
Carla Kirk-Cohen
421433039b
lnrpc: rename proportional fee rate on lnrpc
This field is incorrectly suffixed as "msat", when it is actually
interpreted as the proportional fee rate. This is the value that we
should be using because the sender will calculate proportional fees
accordingly. This is a breaking change to the RPC, but on an
experimental and unreleased API.
2024-03-27 09:39:01 -04:00
Carla Kirk-Cohen
0aeb7c4ba2
multi/refactor: clarify blinded payment fee rate field name 2024-03-27 09:39:00 -04:00
Carla Kirk-Cohen
4a93f4d8d3
multi: pass blinding point through to reconstruction 2024-03-27 09:38:59 -04:00
Carla Kirk-Cohen
7265e4c9b0
htlcswitch: add incoming amount and to decode hop iterator request
When we have payments inside of a blinded route, we need to know
the incoming amount to be able to back-calculate the amount that
we need to forward using the forwarding parameters provided in the
blinded route encrypted data. This commit adds the payment amount
to our DecodeHopIteratorRequest so that it can be threaded down to
payment forwarding information creation in later commits.
2024-03-27 09:38:58 -04:00
Carla Kirk-Cohen
7bf1daaade
htlcswitch: add blinding point to decode hop iterator request 2024-03-27 09:38:57 -04:00
Carla Kirk-Cohen
f090a64142
multi: add blinding point to payment descriptor and persist
This commit adds an optional blinding point to payment descriptors and
persists them in our HTLC's extra data. A get/set pattern is used to
populate the ExtraData on our disk representation of the HTLC so that
callers do not need to worry about the underlying storage detail.
2024-03-27 09:38:56 -04:00
Carla Kirk-Cohen
7596e764ac
channeldb: include extra data in htlc clone function 2024-03-27 09:38:55 -04:00
Carla Kirk-Cohen
e4f90ec593
lnwire: add blinding point to update_add_htlc TLVs
Add blinding points to update_add_htlc. This TLV will be set for
nodes that are relaying payments in blinded routes that are _not_
the introduction node.
2024-03-27 09:38:50 -04:00
Carla Kirk-Cohen
d8979d3086
multi: add validation of blinded route encrypted data
Co-authored-by: Calvin Zachman <calvin.zachman@protonmail.com>
2024-03-27 09:36:40 -04:00
Carla Kirk-Cohen
c48841a38b
record: add TLV encoding/decoding for blinded route data blobs
This commit adds encoding and decoding for blinded route data blobs.
TLV fields such as path_id (which are only used for the final hop)
are omitted to minimize the change size.
2024-03-27 09:36:39 -04:00
Carla Kirk-Cohen
3cc50ced55
lnwire: create common encoder/decoder for raw feature vectors
We'll need to pack feature vectors for route blinding, so we pull
the encoding/decoding out into separate functions (currently
contained in ChannelType). Though it's more lines of code, we keep
most of the ChannelType assertions so that we strictly enforce
use of the alias.
2024-03-27 09:36:38 -04:00
Carla Kirk-Cohen
42069ef2f8
htlcswitch: remove unused decode hop iterator 2024-03-27 09:36:37 -04:00
ffranr
05db2c35df
lntest: add test node name to tmp directory name
In this commit we add the LND node name to the temporary directory's
name. This change makes it easier to identify a particular test node's
temporary directory.

This commit also replaces the depreciated `ioutil.TempDir` function call
with `os.MkdirTemp`.
2024-03-26 18:28:41 +00:00
Oliver Gugger
b76f733a9e
Merge pull request #8587 from zhiqiangxu/add_nil_check
channeldb: check return value of ReadWriteBucket
2024-03-26 09:30:07 -06:00
zhiqiangxu
5fd46b0dce channeldb: check return value of ReadWriteBucket 2024-03-26 17:28:09 +08:00
Oliver Gugger
d3e5b2f799
Merge pull request #8584 from yyforyongyu/fix-unit-race
chainntnfs: fix race in `TestInterfaces`
2024-03-26 02:37:53 -06:00
yyforyongyu
bf799719b5
chainntnfs: fix race in TestInterfaces 2024-03-26 12:59:02 +08:00
Oliver Gugger
fa2b0ca833
Merge pull request #8577 from undefinedor/bugfix/fix-unreachable-code
kvdb+watchtower: fix unreachable code
2024-03-25 11:44:33 -06:00
undefinedor
028959f5a0
kvdb+watchtower: fix unreachable code 2024-03-25 21:04:48 +08:00
Oliver Gugger
1422df27b2
Merge pull request #8521 from zhiqiangxu/typo
chore: fix typo
2024-03-22 01:34:57 -06:00
zhiqiangxu
74a290b46d lnwallet+input: fix a few typoes 2024-03-21 15:44:45 +08:00
Oliver Gugger
15c7686830
Merge pull request #8554 from yyforyongyu/use-new-errors
lnwallet: use new errors returned from `rpcclient`
2024-03-21 01:42:57 -06:00
Oliver Gugger
9e59fb4563
Merge pull request #8572 from zhiqiangxu/fix_deprecated
lnwire: fix deprecated usage
2024-03-21 01:23:02 -06:00
zhiqiangxu
cbf676e404 lnwire: fix deprecated usage 2024-03-21 10:05:17 +08:00
ProofOfKeags
b575460bca
Merge pull request #8418 from Crypt-iQ/feefilter_0117
chainfee: introduce filterManager and use it for fee floor
2024-03-20 19:15:35 -06:00
Eugene Siegel
fccf6ce3f1
release-notes: update for 0.18.0 2024-03-20 12:14:28 -04:00
Eugene Siegel
d5a13577bf
chainfee: introduce filterManager and use it for fee floor
This commit introduces a filterManager that uses our outbound peers'
feefilter values to determine an acceptable minimum feerate that
ensures successful transaction propagation. Under the hood, a moving
median is used as it is more resistant to shocks than a moving average.
2024-03-20 12:14:25 -04:00
Oliver Gugger
56c04172c0
Merge pull request #8570 from guggero/release-notes-fix
docs: remove merge artifact, polish
2024-03-20 09:56:38 -06:00
Oliver Gugger
23f5f3cde5
Merge pull request #8568 from bhandras/native-sql-ensure-empty-invoicedb
lnd: ensure that LND won't start in native SQL mode if it has any KV invoices
2024-03-20 05:34:08 -06:00
Oliver Gugger
ad9144ffa3
Merge pull request #8273 from guggero/bitcoind-26
GitHub: use bitcoind v26.0 for CI
2024-03-20 01:50:44 -06:00
Andras Banki-Horvath
483f5f3bca
docs: update release notes for 0.18 2024-03-20 08:46:48 +01:00
Andras Banki-Horvath
2fbffab421
itest: ensure that native SQL LND won't start if it has any KV invoices 2024-03-20 08:46:48 +01:00
Andras Banki-Horvath
2d3d11487c
lnd: ensure that native SQL can only be used with a clean KV invoice DB
This commit adds a check to ensure that we don't start LND with native
SQL invoice DB if we already have any invoices in our KV channeldb. This
is needed as native SQL invoices is an experimental feature and we do
not yet support migration.
2024-03-20 08:46:48 +01:00
Andras Banki-Horvath
65c1f5483b
lncfg: make sure to only use native SQL with SQL backends 2024-03-20 08:46:47 +01:00
Oliver Gugger
0c6cc8d0ae
Merge pull request #8550 from kornpow/kornpow/rescan-info-log
routerrpc: Add detailed info logging during a rescan
2024-03-20 01:46:18 -06:00
Oliver Gugger
38be396121
docs: remove merge artifact, polish
This commit removes a merge artifact introduced by a rebase of a
previous PR.
While we're at it, we streamline the grammar, formatting and general
look-and-feel of the release notes.
2024-03-20 08:41:27 +01:00
Oliver Gugger
4100646e59
Merge pull request #8569 from xiaoxianBoy/fix-typos
chore: fix typos [skip ci]
2024-03-20 01:40:48 -06:00
snoppy
089278d817
docs+lntest: fix typos 2024-03-20 15:13:19 +08:00
Oliver Gugger
ad88407b33
Merge pull request #7805 from ziggie1984/updatefee-limiter
Limit FeeRate change for the UpdateFee msg to prevent sharp changes
2024-03-19 14:50:07 -06:00
Oliver Gugger
8ef5933a43
Merge pull request #8566 from ellemouton/windowsTowerFail
itest: mine blocks on tower session assertion failure
2024-03-19 14:49:51 -06:00
yyforyongyu
9dace4377a
docs: update release notes 2024-03-20 04:40:38 +08:00
yyforyongyu
03afb72918
workflows: remove loggings from unit test
These loggings are not helpful.
2024-03-20 04:40:38 +08:00
yyforyongyu
c00b7101d2
lnwallet: update the unit tests to check the new errors 2024-03-20 04:40:38 +08:00
yyforyongyu
837c7f761c
lnwallet+lnd: make use of the new errors from btcd/rpcclient
This commit updates `btcd` and `btcwallet` packages and make use of the
new RPC error mappings.
2024-03-20 04:40:38 +08:00
ziggie
25c38491ee
docs: add release-notes.
Adding the release-notes for release 0.18 and fixing typos in the
release doc.
2024-03-19 16:57:12 +00:00
ziggie
6821309af3
lnwallet: Change MaxFee calculation.
When determining the max fee rate of a channel we used to scale
the fee rate depending on our available local balance on this channel.
This lead to a special case that if a channel would be drained we
could especially decrease the fee rate even down to the fee floor.
Now we make sure that our max fee rate will not be lower than the
old fee rate to make sure in case our channel is locally drained
we do not continue to decrease fees too low.
2024-03-19 16:56:15 +00:00
ziggie
45c6ee69d2
chainfee: special case a zero fee estimation.
Bitcoind will not report any fee estimation in case it has not
enough data available. We used to just set the min mempool fee
in such cases but this might not represent the current fee situation
of the bitcoin network. We return an error now so that we will use
the fallback fee instead.
2024-03-19 16:56:14 +00:00
Oliver Gugger
b1d3b9f678
Merge pull request #8567 from ellemouton/bumpSqliteToFixRace
go.mod+docs: bump sqlite version to fix data race
2024-03-19 09:29:47 -06:00
Elle Mouton
91ed8cf862
go.mod+docs: bump sqlite version to fix data race 2024-03-19 15:40:10 +02:00
Elle Mouton
d87fd6138d
itest: mine blocks on tower session assertion failure
In the tower session itest, we make sure to mine blocks on session count
assertion failure. This required because the session count is expected
to change only when 2 things both happen: 1) a closable session is
queued and 2) a new block notification comes through _after_ the session
has been queued. Only then will it be deleted. So we need to do this to
prevent the case where all the block notifications are consumed _before_
the session is queued for deletion. This flake tended to happen in the
windows itest.
2024-03-19 13:17:20 +02:00
Oliver Gugger
f6656d1daa
Travis+GitHub: replace Travis CI with GitHub MacOS 14 build 2024-03-18 17:08:18 +01:00
Oliver Gugger
17b93db5cc
chainntnfs: fix race unit test issue
Because we pass in the same config into multiple notifiers, we sometimes
get a data race in the unit tests. By creating a copy of the config we
avoid that.
2024-03-18 17:08:17 +01:00
Oliver Gugger
ab422ba184
lntest: give chain backend more time to get ready
This is a commit to attempt to fix Travis which runs on ARM64.
2024-03-18 17:08:17 +01:00
Oliver Gugger
77a82309f5
docs: add release notes 2024-03-18 17:08:17 +01:00
Oliver Gugger
b1b32d9026
make: add nocache and verbose arguments
To make it easy to add "-test.v" and "-test.count=1" to the unit tests,
we add two new make flags.
2024-03-18 17:07:26 +01:00
Oliver Gugger
aa811c784a
lnwallet+routing: use chainntnfs.NewBitcoindBackend
Since we fixed a number of issues in chainntnfs.NewBitcoindBackend that
makes it compatible with bitcoind v26.0, we now want to use that
function in all our unit tests.
2024-03-18 16:13:40 +01:00
Oliver Gugger
d40312c36b
multi: move unit test backend funcs to new package
To avoid circular dependency issues between packages, we move the unit
test backend creation function to a new package in the lntest parent
package.
2024-03-18 16:13:39 +01:00
Oliver Gugger
c170a9830b
multi: use chainntnfs.NewMiner for miners in unit tests
With the chainntnfs.NewMiner now being optimized for not creating
nodes with colliding ports, we use it in all unit tests that spin up
temporary miners.
2024-03-18 16:13:39 +01:00
Oliver Gugger
2884389ce4
chainntnfs: fix issues with NewBitcoindBackend
This commit fixes a number of issues with our temporary bitcoind nodes
that we spin up for unit tests:
 - We didn't remove the node's temporary data dir after tests finished.
 - We used random ports which lead to unwanted port collisions.
 - We used ipc:// unix sockets for ZMQ which currently isn't supported
   in bitcoind v26.0 due to a regression. Since we can reliably create
   new non-colliding ports now, we should use TCP for ZMQ anyway.
2024-03-18 16:13:39 +01:00
Oliver Gugger
2cc28baa84
chainntnfs: re-try miner connection more often
Make sure we wait for the initial connection long enough.
2024-03-18 16:13:39 +01:00
Oliver Gugger
9cd7285439
itest+lntest: use system wide unique ports everywhere
With this commit we create a new function that returns system wide
unique ports by using a single file to keep track of previously used
ports. We'll want to use this everywhere whenever we need to listen on a
new, random port during unit or integration tests.
Because we now have a unique source, we don't need to apply the port
offset that was used for the different tranches of parallel running
integration tests before.
2024-03-18 16:13:39 +01:00
Oliver Gugger
11ba14ab02
chainntnfs: add netParams arg to backend funcs 2024-03-18 16:13:39 +01:00
Oliver Gugger
b4449ab55f
GitHub: use bitcoind v26.0 for CI, remove default value
To make it less confusing what version of bitcoind is actually
installed, we now require the version to be specified as a command line
argument.

Because we tag the version in the docker image tag as bitcoin-core:XX
but the binary internally is located under /opt/bitcoin-XX.Y/, we
manually set Y to 0.
2024-03-18 16:13:38 +01:00
Oliver Gugger
b0552da007
Merge pull request #8558 from mohamedawnallah/fix-manpages-script-breaks-dockerfiles-bug
Fix: Manpages Script breaks Dockerfiles
2024-03-18 08:12:44 -06:00
Mohamed Awnallah
1812b0e56e
scripts+dev.Dockerfile: address dockerfile build issue 2024-03-18 13:47:39 +02:00
Oliver Gugger
0bc3d29413
Merge pull request #8496 from aakselrod/locks-to-leases
multi: replace `LockOutpoint` with `LeaseOutput`
2024-03-18 03:34:56 -06:00
Oliver Gugger
51ebc2052f
Merge pull request #8310 from mohamedawnallah/lnconfig-support-env-vars-for-rpcuser-rpcpassword
lnconfig: Support utilizing Environment Variables in `lnd.conf` for `rpcuser` and `rpcpass` fields.
2024-03-15 12:39:54 -06:00
Alex Akselrod
4193505341
lntest/wait: increase DefaultTimeout for db access
This helps take into account the new limits on GHA runners.
2024-03-15 11:09:52 -07:00
Oliver Gugger
ff31426248
Merge pull request #8300 from mohamedawnallah/fix/clarify-available-commitment-balance-message
fix: clarify available commitment balance log message
2024-03-15 05:56:40 -06:00
Mohamed Awnallah
e16efd6f08
lnwallet: clarify-available-commitment-balance-message [skip ci] 2024-03-15 11:18:57 +02:00
Sam Korn
11d6442d17
routerrpc: Add detailed info/trace logging during a rescan 2024-03-14 11:23:16 -06:00
Mohamed Awnallah
0add4fcec7
docs: update the release-notes-0.18.0.md 2024-03-14 17:55:59 +02:00
Mohamed Awnallah
3e5f03eb0b
config_test.go: add test cases for supplyEnvValue 2024-03-14 17:55:59 +02:00
Mohamed Awnallah
ae1c470cb4
config.go: support utilizing env variables in lnd.conf file
In this commit, we support utilizing the usage of enviroment variables in `lnd.conf` file
for `rpcuser` and `rpcpass` fields by adding `supplyEnvValue` function in `config.go`
that returns the value of the specified environment variable, the fall-back value
if provided, or the original input string if no matching environment variables are found or set.
2024-03-14 17:53:43 +02:00
Oliver Gugger
18371e120d
Merge pull request #8552 from guggero/optimize-build
GitHub: separate build caches
2024-03-14 09:15:29 -06:00
Oliver Gugger
23d5ed826f
Merge pull request #8551 from guggero/dependency-update
mod: update outdated module dependencies
2024-03-14 04:19:23 -06:00
Oliver Gugger
05675fa254
GitHub: separate build caches
To avoid build caches getting larger and larger, causing our builds to
fail, we separate the caches of the different job types.
If we don't separate them, then the caches can end up being a
combination of the different jobs, which isn't useful (for example the
build cache of the cross compilation build isn't useful in an
integration test and vice versa).
2024-03-14 11:14:39 +01:00
Oliver Gugger
73058c7c6a
Merge pull request #8525 from mohamedawnallah/generate-man-pages
Feature: generate man pages
2024-03-14 03:00:06 -06:00
Oliver Gugger
4140d2a9d7
lnrpc: re-generate protos after dependency update 2024-03-14 09:32:29 +01:00
Oliver Gugger
2c19c91741
mod: update outdated module dependencies
To avoid getting spammed by Dependabot, we preemptively bump the
versions of dependencies with known CVEs (even if they might not
directly affect us).
2024-03-14 09:15:16 +01:00
Mohamed Awnallah
fb5b425c40
docs: update release-notes-0.18.0 2024-03-13 21:18:24 +02:00
Mohamed Awnallah
158b802f49
lncli+makefile: generate man pages automatically for lncli and lnd 2024-03-13 21:18:23 +02:00
Mohamed Awnallah
dfd1636f18
scripts: add gen_man_pages.sh script 2024-03-13 21:18:23 +02:00
Alex Akselrod
7af3d4022f
docs: update release notes 2024-03-13 09:50:18 -07:00
Alex Akselrod
b9357fe830
multi: remove unused LockOutpoint and UnlockOutpoint 2024-03-13 09:50:18 -07:00
Alex Akselrod
cefbb77b1e
lnwallet: use ReleaseOutput instead of UnlockOutpoint 2024-03-13 09:50:17 -07:00
Alex Akselrod
a1d4463947
sweep: use {Lease|Release}Output instead of {Lock|Unlock}Outpoint 2024-03-13 09:50:17 -07:00
Alex Akselrod
6ad86a800c
chanfunding: use {Lease|Release}Output not {Lock|Unlock}Outpoint 2024-03-13 09:50:16 -07:00
Alex Akselrod
4d2ab7423f
multi: move 3 vars from walletrpc+lncfg to chanfunding
This commit moves the constants LndInternalLockID and
DefaultLockDuration from the walletrpc package to the chanfunding
package, moves DefaultReservationTimeout from lncfg to chanfunding,
and also updates the lncli package with the new location.
2024-03-13 09:50:16 -07:00
Alex Akselrod
07ba9d6015
itest: add open channel locked balance test 2024-03-13 09:50:15 -07:00
Yong
d9887f3212
Merge pull request #8504 from calvinrzachman/healthcheck
lnd/healthcheck: add checks after initialization + success/failure callbacks
2024-03-13 20:20:39 +08:00
Oliver Gugger
1fd6bc870b
Merge pull request #8544 from ellemouton/undoChainsListDeprecation
lnrpc: undo GetInfo Chains list deprecation
2024-03-12 15:55:13 -06:00
Elle Mouton
041a7859ff
lnrpc: undo GetInfo Chains list deprecation 2024-03-12 20:06:56 +02:00
Calvin Zachman
add2b2957b
docs: release notes for healthcheck package changes 2024-03-12 09:50:17 -05:00
Calvin Zachman
39f94a150f
lnd/healthcheck: add tests for callbacks and dynamic checks 2024-03-12 09:36:42 -05:00
Calvin Zachman
6a3a2ee61d
lnd/healthcheck: add healthcheck onSuccess/onFailure callbacks
Allow package users to provide custom callback which will
execute whenever a healthcheck fails.

Allow package users to provide custom callback which will
execute whenever a healthcheck succeeds.
2024-03-12 09:36:35 -05:00
Calvin Zachman
80c2ac8ed3
lnd/healthcheck: add health checks dynamically
Allow health checks to be added to our monitor after
the initial startup.
2024-03-12 09:12:24 -05:00
Oliver Gugger
5cb4811e86
Merge pull request #8425 from ProofOfKeags/refactor/lnwallet/chan-point-leaks
[EZ Review]: avoid leaking pointers to authoritative ChannelPoint
2024-03-11 00:55:41 -06:00
Oliver Gugger
780ffe913c
Merge pull request #8527 from cuinix/master
chore: remove repetitive words
2024-03-11 00:33:26 -06:00
Keagan McClelland
659ad459bb brontide: placate linter 2024-03-08 15:54:25 -08:00
Keagan McClelland
16be46c1e5 htlcswitch: prevent ChannelLink from leaking ChannelPoint pointer 2024-03-08 15:48:02 -08:00
Keagan McClelland
db39a905cb multi: make NewChanIDFromOutpoint accept value instead of pointer 2024-03-08 15:47:55 -08:00
Keagan McClelland
fd1cd315ce multi: don't leak underlying pointer to LightningChannel.ChannelPoint() 2024-03-08 15:27:19 -08:00
Oliver Gugger
4f06f58791
Merge pull request #8483 from ProofOfKeags/feature/for-loop-destroyer
fn: add slice utilities
2024-03-08 01:48:38 -06:00
Oliver Gugger
d9048d1f3d
Merge pull request #8533 from Roasbeef/code-owners
github/CODEOWNERS: rename code owners file to soft deactivate
2024-03-08 01:35:54 -06:00
Olaoluwa Osuntokun
482b0ad7b4
github/CODEOWNERS: rename code owners file to soft deactivate
In this commit, rather than attempt to reduce the scope of the current
`CODEOWNERS` file, we instead rename it as a way to stop Github from
automatically assigning reviewers based on it. Instead, we put things in
a "hint" mode as a way for PR OPs to figure out who they should manually
assign PRs today.

With the CODEOWNERS file reduced to a code review assignment hint, we
aim to instead promote usage of the `@code-review` team which will use a
load balancing algorithm for automatic code review assignment.
2024-03-07 17:15:22 -08:00
Keagan McClelland
e9b3808c29 lnwallet+contractcourt: remove redundant ChanPoint field 2024-03-07 14:16:16 -08:00
Oliver Gugger
5ccb9db78f
Merge pull request #8526 from guggero/confirm-closeallchannels
cli: add confirmation prompt to closeallchannels
2024-03-07 02:31:46 -06:00
Oliver Gugger
bb5b614af5
docs: add release notes 2024-03-07 09:12:13 +01:00
Oliver Gugger
92ae54d7ae
cmd/lncli: add confirmation promt to closeallchannels
To make sure users don't accidentally close all channels, we ask before
running this potentially very destructive command.
2024-03-07 09:12:12 +01:00
cuinix
60bc30dd08 remove repetitive words
Signed-off-by: cuinix <915115094@qq.com>
2024-03-07 14:05:47 +08:00
Olaoluwa Osuntokun
716c6dddd8
Merge pull request #8052 from bhandras/sql-invoices
sqldb: `InvoiceDB` implementation
2024-03-06 21:15:14 -06:00
Olaoluwa Osuntokun
d5138c1039
Merge pull request #8505 from yyforyongyu/version-check-testmempool
lnwallet: skip `testmempoolaccept` when the backend version is too low
2024-03-06 17:35:55 -06:00
ProofOfKeags
56f17afeeb
Merge pull request #8517 from ProofOfKeags/cleanup/link-weeds
htlcswitch+peer+lnwire: pull weeds
2024-03-06 16:05:44 -07:00
yyforyongyu
c9f857e426
docs: update release notes 2024-03-07 06:45:33 +08:00
yyforyongyu
0d4472c5ea
lnwallet: skip TestMempoolAccept for old backend versions 2024-03-07 06:45:33 +08:00
yyforyongyu
a21e6610f2
gomod: update btcd and btcwallet versions 2024-03-07 06:45:30 +08:00
Keagan McClelland
59700892b7 lnwire: make LinkUpdater a subclass of Message
Conceptually, all messages that are capable of identifying the
channel_id on which they operate are themselves messages. Here we
codify this.
2024-03-06 11:59:19 -08:00
Keagan McClelland
f5f0286e34 peer+lnwire: move LinkUpdater to lnwire
The purpose of this interface is to distinguish messages that are
bound to a particular channel_id from those that are not. There is
no reason this ought to be a property of the peer package as it is
entirely determined by the contents of the message itself. Therefore
we move it to the lnwire package so it can be used without having
import cycles elsewhere in the codebase.
2024-03-06 11:59:19 -08:00
Keagan McClelland
3761912680 htlcswitch: avoid leaking peer interface from link
Here we notice that the only use of the Peer call on the link is
to find out what the peer's pubkey is. To avoid leaking handles to
IO actions outside the interface we reduce the surface area to
just return the peer's public key.
2024-03-06 11:59:09 -08:00
Oliver Gugger
5f89a8b832
Merge pull request #8523 from guggero/linter-use-cache
make: use Golang build and module cache for linter
2024-03-06 07:28:10 -06:00
Oliver Gugger
834371c995
make: use Golang build and module cache for linter
This commit gives the linter container access to the local machine's
build and module cache, drastically decreasing the run time of
subsequent linter runs (no difference on first run with this change).
2024-03-06 13:38:51 +01:00
Keagan McClelland
be69b022d9 htlcswitch: remove Switch reference from channelLink 2024-03-05 16:43:29 -08:00
Oliver Gugger
6cef367336
Merge pull request #8136 from hieblmi/fee-estimation-probe
Probing for more reliable route fee estimation
2024-03-05 11:35:57 -06:00
Slyghtning
fba6fdaf94
docs: update release notes 2024-03-05 09:24:27 +01:00
Slyghtning
814e1a79a6
lncli: add estimateroutefee command 2024-03-05 09:24:27 +01:00
Slyghtning
e79b8b2986
itest: estimate route fee tests 2024-03-05 09:24:27 +01:00
Slyghtning
ef069b658d
itest: preparatory fee estimation changes 2024-03-05 09:24:27 +01:00
Slyghtning
7d9589ecbf
routerrpc+zpay32: EstimateRouteFee overhaul
In this commit the mission control based fee estimation
is supplemented with a payment probe estimation which can
lead to more accurate estimation results. The probing
utilizes a hop-hint heurisic to detect routes through LSPs
in order to manually estimate fees to destinations behind
an LSP that would otherwise block the payment probe.
2024-03-05 09:24:27 +01:00
Slyghtning
24080c51f9
multi: fee estimation timeout parameters
conf: fee estimation timeout in sample config
2024-03-05 09:24:27 +01:00
Slyghtning
721038d1a4
routerrpc: overhaul RouteFeeRequest with probing parameters. 2024-03-05 09:24:25 +01:00
Keagan McClelland
2bd9911804 fn: add slice utilities
In the year of our lord 2024 we should not be writing for loops
for standard operations. Here we introduce named slice operations
not found in the golang slices package. Note all these functions
are pure.
2024-03-02 11:43:07 -08:00
Olaoluwa Osuntokun
f61761277f
Merge pull request #8513 from lightningnetwork/lnd-master-version-17-99
build: bump version to v0.17.99
2024-03-01 13:58:48 -06:00
Oliver Gugger
10a6861bc9
build: bump version to v0.17.99
In this commit, we bump the version of the master branch to v0.17.99.
This reflects the fact that master will be a super set of all the minor
releases until v0.18, and will also include changes towards v0.18.
2024-03-01 10:29:04 +01:00
Andras Banki-Horvath
6c09617568
docs: update release notes for v0.18.0-beta 2024-03-01 10:08:10 +01:00
Andras Banki-Horvath
29ae17ba71
github: add nativesql itests to the matrix 2024-03-01 10:08:10 +01:00
Andras Banki-Horvath
ba8e7550d5
itest: add the -nativesql flag to run SQL itests with native SQL tables 2024-03-01 10:08:10 +01:00
Andras Banki-Horvath
7a45bbbeab
lnd: call into the correct InvoiceStore from RPC calls 2024-03-01 10:08:10 +01:00
Andras Banki-Horvath
42508d44e5
lnd: update sample-lnd.conf 2024-03-01 10:08:10 +01:00
Andras Banki-Horvath
ce1b57da2d
sqldb: exclude sqlite from the JS and unsupported platform builds 2024-03-01 10:08:09 +01:00
Andras Banki-Horvath
88370de1ab
lnd: use native SQL invoice store if configured 2024-03-01 10:08:09 +01:00
Andras Banki-Horvath
e31879ea0a
lncfg: instantiate the native SQL backend if configured
This commit adds an optional separate "native" SQL backend that will
host all tables supporting native SQL. For now since we don't have many
such tables we'll keep it in one file for SQLite, but it may be split up
if desired.
2024-03-01 10:08:09 +01:00
Andras Banki-Horvath
debfaf41b9
lncfg: use the sqldb config types instead of the kvdb counterparts 2024-03-01 10:08:09 +01:00
Andras Banki-Horvath
aba45018a8
sqldb: merge SQLite and Postgres configs with the kvdb counterparts
This commit is part of a refactor that unifies configuration of the
sqldb and kvdb packages for SQL backends.
In order to unify the SQLite and Postgres configuration under sqldb we
first need to ensure that the final config types are compatible with
the alreay deployed versions.
2024-03-01 10:08:09 +01:00
Andras Banki-Horvath
aee1f7f563
invoices: run InvoiceStore and InvoiceRegistry tests on PostgreSQL too 2024-03-01 10:08:09 +01:00
Andras Banki-Horvath
06730824a2
sqldb: fixup PostgreSQL fixture to allow creating separate DBs per test
This change will enable us to use a single PostgreSQL container instead of
spawning new a one for each (parallel) unit test reducing overall test
runtime.
2024-03-01 10:08:08 +01:00
Andras Banki-Horvath
b10ce17cd4
invoices: run InvoiceStore and InvoiceRegistry tests on SQLite too 2024-03-01 10:08:08 +01:00
Andras Banki-Horvath
734d3a9d66
invoices: small test fixes 2024-03-01 10:08:08 +01:00
Andras Banki-Horvath
39211d25ed
invoices: make test HTLC circuit keys unique 2024-03-01 10:08:08 +01:00
Andras Banki-Horvath
3d56d2f1ee
sqldb: add full SQL InvoiceStore implementation 2024-03-01 10:08:08 +01:00
Andras Banki-Horvath
5cf67c4440
sqldb: add utility functions for SQL NULL types 2024-03-01 10:08:07 +01:00
Andras Banki-Horvath
74e7a50f4a
sqldb: convert primary key violation to ErrSQLUniqueConstraintViolation
Besides the usual unique constraint violation that we already support we
also want to return the same error if the primary key constraint is
violated.
2024-03-01 10:08:07 +01:00
Andras Banki-Horvath
6a360fb2e2
sqldb: simplify and fixup the existing invoice store schema and queries
This commit attempts to fix some issues with the invoice store's schema that we
couldn't foresee before the implementation was finished. This is safe as the
schema has not been instantiated yet outside of unit tests. Furthermore the
commit updates invoice store SQL queries according to fixes in the schema as
well as to prepare the higher level implementation in the upcoming commits.
2024-03-01 10:08:07 +01:00
Andras Banki-Horvath
3e0f98a75a
sqldb: introduce replace for the BIGINT type alias 2024-03-01 10:08:07 +01:00
positiveblue
e7d82fa530
tools: update sqlc version to v1.25.0 2024-03-01 10:08:07 +01:00
Olaoluwa Osuntokun
e623263b7f
Merge pull request #8499 from Roasbeef/taproot-nonce-tlv-t
multi: upgrade new taproot TLVs to use tlv.OptionalRecordT
2024-02-29 16:00:09 -06:00
Olaoluwa Osuntokun
cac779b69e
funding: send warning to remote peer if chan nonce missing on reest 2024-02-29 11:32:31 -06:00
Olaoluwa Osuntokun
7feb8b21e1
multi: upgrade new taproot TLVs to use tlv.OptionalRecordT
In this commit, we update new Taproot related TLVs (nonces, partial sig,
sig with nonce, etc). Along the way we were able to get rid of some
boiler plate, but most importantly, we're able to better protect against
API misuse (using a nonce that isn't initialized, etc) with the new
options API. In some areas this introduces a bit of extra boiler plate,
and where applicable I used some new helper functions to help cut down
on the noise.

Note to reviewers: this is done as a single commit, as changing the API
breaks all callers, so if we want things to compile it needs to be in a
wumbo commit.
2024-02-29 11:32:26 -06:00
Olaoluwa Osuntokun
6bd556d38c
build: bump tlv version to v1.2.3 2024-02-29 11:32:20 -06:00
Keagan McClelland
38db17b8cc htlcswitch: remove redundant field from channelLink 2024-02-27 17:06:35 -08:00
Olaoluwa Osuntokun
72764b1473
Merge pull request #8100 from bhandras/updateinvoice-refactor
channeldb: refactor `UpdateInvoice` to make it simpler to create SQL specific implementation
2024-02-27 16:50:02 -08:00
Oliver Gugger
48a3d56335
Merge pull request #8503 from ffranr/fix-err-wrap
Correct `fmt.Errorf` error wrapping instances
2024-02-27 12:20:16 -06:00
ffranr
e0358df39e
doc: update release notes 2024-02-27 17:08:02 +00:00
ffranr
b308895583
lncli: unit test makes use of error wrapping during comparison
This commit modifies a unit test such that it inspects a wrapped error
rather than comparing errors by string.
2024-02-27 17:08:01 +00:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
ffranr
581c16d72f
lint: ensure the linter checks fmt.Errorf error wrapping 2024-02-27 11:12:28 +00:00
Olaoluwa Osuntokun
b234658945
Merge pull request #8501 from Roasbeef/tlv-fn-ergonomics
tlv: add UnwrapOrErrV+UnwrapOrFailV+Zero to OptionalRecord
2024-02-26 17:03:37 -08:00
Olaoluwa Osuntokun
3dd01cdc78
tlv: add Zero() method for OptionalRecordT
Most of the time with wire messages, we'll have the wrapped record, so
this is useful when decoding into a blank instance of the record's
value.
2024-02-26 16:12:55 -08:00
Olaoluwa Osuntokun
afde7162c6
tlv: add UnwrapOrErrV and UnwrapOrFailV
These two methods mirror the recently added `fn.Option` methods but
allow us to unwrap on level deeper into the underlying value of the
Record.
2024-02-26 16:12:49 -08:00
Olaoluwa Osuntokun
d69e1111ba
build: update to fn/v1.0.4 2024-02-26 16:12:47 -08:00
Olaoluwa Osuntokun
6d8f40cb27
Merge pull request #8500 from Roasbeef/fn-option-ergonomics
fn: add UnwrapOrErr and UnwrapOrFail to Option
2024-02-26 16:06:17 -08:00
Olaoluwa Osuntokun
5a960269f2
Merge pull request #8378 from guggero/fundpsbt-coin-select
walletrpc: unify coin selection, allow coin selection for PSBT with pre-defined inputs
2024-02-26 16:05:07 -08:00
Oliver Gugger
c307d1eeda
docs: document fundtemplate sub command, add release notes 2024-02-26 11:06:26 +01:00
Oliver Gugger
6dea39c23a
itest: add new test for FundPsbt with coin selection 2024-02-26 11:06:22 +01:00
Oliver Gugger
f333581d6c
cmd/lncli: add 'wallet psbt fundtemplate' command
This commit adds a new sub command to the wallet that allows using the
new funding option from a template.
Creating a new command is way easier for the user to understand than
adding multiple flags that are only valid in certain combinations.
2024-02-26 11:05:19 +01:00
Oliver Gugger
54fa5805c2
lnwallet+lnrpc: add address index to ListAddresses
For the itest in the next commit we'll need to be able to fetch the
input information for an address over RPC. The only piece missing is the
address' index, which we add in this commit. Everything else should be
derivable from the ListAddresses and ListAccounts calls.
2024-02-26 11:05:19 +01:00
Oliver Gugger
fb20cd598e
lnwallet+lnrpc: add derivation info for P2TR change addrs
In some situations (for example in Taproot Assets), we need to be able
to prove that an address is a bare BIP-0086 address that doesn't commit
to any script. We can do that by providing the BIP-0032 derivation info
and internal key.
2024-02-26 11:05:18 +01:00
Olaoluwa Osuntokun
166b2fdb97 fn: add UnwrapOrErr and UnwrapOrFail to Option
In this commit, we add two new methods that simplify usage of an
handling a value wrapped in an Option. Thes methods allow a caller to
force the nil/None check up front, and either obtain the value, or fail
the current execution or test.

This should replace most usages of `UnsafeFromSome` where ever used
today.
2024-02-24 17:21:37 -08:00
Oliver Gugger
094fdbfa72
walletrpc: implement third PSBT funding option
And now we finally implement the new funding option: Allowing coin
selection with pre-defined inputs and outputs.
2024-02-23 08:58:10 +01:00
Oliver Gugger
0f6c25a773
walletrpc: add PsbtCoinSelect option to FundPsbt 2024-02-23 08:58:10 +01:00
Oliver Gugger
446152e1a5
walletrpc: refactor to prepare for third funding option
In the following commits we'll add a new, third, funding option for
funding PSBTs: It will allow users to specify pre-selected inputs but
still request the wallet to perform coin selection up to the total
output sum amount.
2024-02-23 08:58:10 +01:00
Oliver Gugger
17645cd196
multi: add DecorateInputs to WalletController interface
This commit adds the new DecorateInputs method of the base wallet to the
WalletController interface.
2024-02-23 08:58:10 +01:00
Oliver Gugger
90c2926fdf
input: add AddOutput method to TxWeightEstimator
This commit adds a helper method to estimate the weight of an output by
the given pkScript.
2024-02-23 08:58:10 +01:00
Oliver Gugger
6773d6a6f6
btcwallet: add EstimateInputWeight helper function
This is a helper function that we will need to accurately determine the
weight of inputs specified in a PSBT.
Due to the nature of P2WSH and script-spend P2TR inputs, we can only
accurately estimate their weights if the full witness is already known.
So this helper function rejects inputs that use a script spend path but
don't fully specify the complete witness stack.
2024-02-23 08:58:09 +01:00
Oliver Gugger
7aa3662ea2
chanfunding: export change amount calculation
We want to re-use the logic that determines what change amount is left
over depending on whether we add or don't add a change output to a
transaction, respecting the change output's dust limit.
2024-02-23 08:58:09 +01:00
Oliver Gugger
2619c03d7d
chanfunding: allow using existing change output
We'll want to be able to tell the coin selection algorithm that we
intend to add any change to an existing output instead of assuming that
a change output is always created.
If we add any left over change to an existing output, we can skip the
dust amount check as we assume the selected existing output already has
a non-dust amount requested (responsibility of the caller to assert).
2024-02-23 08:58:09 +01:00
Oliver Gugger
4c82fb6cbb
chanfunding: make coin selection generic
Before this commit the coin selection logic in the chanfunding package
would always assume that there is a P2WSH funding output and potentially
a P2TR change output. But because we want to re-use the coin selection
for things other than just channel funding, we make the logic more
generic by allowing us to specify both the existing weight of the
transaction (the already known, static parts of the TX) as well as the
type of the potential change output we would use.
2024-02-23 08:58:09 +01:00
Oliver Gugger
9bdddbcc56
mod+chanfunding: use coin selection strategy for channel funding
The wallet assembler is now aware of the node config level coin
selection strategy, so we can use it when creating new channels.
2024-02-23 08:58:09 +01:00
Oliver Gugger
f7198c4105
walletrpc+subserver_config: add coin selection strategy
With this commit we also add the config-level coin selection strategy to
the wallet RPC server.
2024-02-23 08:58:09 +01:00
Oliver Gugger
cbc11dac8f
multi: add coin selection strategy to channel funding
With this commit we prepare for the lnwallet channel funding logic to be
aware of the config-level coin selection strategy by adding it to the
wallet config.
2024-02-23 08:58:07 +01:00
Olaoluwa Osuntokun
935e550da6
Merge pull request #8463 from ProofOfKeags/refactor/chainreg/rm-channel-constraints
Remove `DefaultChannelConstraints` from PartialChainControl and lnwallet.Config
2024-02-22 14:39:35 -08:00
Elle
16279765eb
Merge pull request #8464 from ellemouton/resend-shutdown-2
multi: resend shutdown on reestablish
2024-02-21 14:10:05 +02:00
Elle Mouton
2fe8520c44
docs: update release notes 2024-02-21 11:58:18 +02:00
Elle Mouton
785790abed
peer/lnwallet: persist shutdown info on send
In this commit, we start persisting shutdown info when we send the
Shutdown message. When starting up a link, we also first check if we
have previously persisted Shutdown info and if we have, we start the
link in shutdown mode meaning that it will not accept any new outgoing
HTLC additions and it will queue the shutdown message after any pending
CommitSig has been sent.
2024-02-21 11:58:18 +02:00
Elle Mouton
5de7792520
htlcswitch: ability to start link in shutdown mode
In this commit, we add the ability to start a link in shutdown mode.
This means that we immediately disable any new HTLC adds in the outgoing
direction and that we queue up a Shutdown message after the next
CommitSig message is sent (or immediately if no CommitSig message is
owed).
2024-02-21 11:57:47 +02:00
Elle Mouton
dc25b425c0
channeldb+lnwallet: add ShutdownInfo with read and write methods
ShutdownInfo contains any info about a previous Shutdown message that we
have sent. This commit adds this type along with read and write methods
for it in the channel db. The existence of the ShutdownInfo on disk
represents the fact that we have previously sent the Shutdown message
and hence that we should resend it on re-establish.
2024-02-21 11:56:15 +02:00
Elle Mouton
987604effb
itest: demonstrate shutdown on restart bug
This commit adds an itest to demonstrate that the following bug exists:
If channel Shutdown is initiated but then a re-connect is done before
the shutdown is complete, then the initiating node currently does not
properly resend the Shutdown message as required by the spec. This will
be fixed in an upcoming commit.
2024-02-21 11:35:12 +02:00
Elle Mouton
8c064b86f1
peer: call DisableAdds before link.OnCommitOnce
This commit moves calls to link.DisableAdds to outside link.OnCommitOnce
call backs. This is done so that if a user requests shutdown, then we
can immediately block any new outgoing HTLCs. It's only the sending of
the Shutdown message that needs to wait until after any pending
CommitSig message is sent.
2024-02-21 11:35:11 +02:00
Elle Mouton
972f57e9a7
peer+htlcswitch: update Enable/DisableAdds API
In this commit, the `ChannelUpdateHandler`'s `EnableAdds` and
`DisableAdds` methods are adjusted to return booleans instead of errors.
This is done becuase currently, any error returned by these methods is
treated by just logging the error since today all it means is that the
proposed update has already been done. And so all we do today is log the
error. But in future, if these methods are updated to return actual
errors that need to be handled, then we might forget to handle them
correctly at the various call sights. So we instead change the signature
of the function to just return a boolean. In future, if we do need to
return any error, we will have to go inspect every call sight in any
case to fix compliation & then we can be sure we are handling the errors
correctly.
2024-02-21 11:35:11 +02:00
Elle Mouton
71753af8ee
multi: fix various typos 2024-02-21 11:35:10 +02:00
Elle
c398b0cc69
Merge pull request #8239 from ellemouton/loadSessionByActiveTower
wtclient: add DeactivateTower and TerminateSession commands
2024-02-21 11:28:25 +02:00
Oliver Gugger
e53f7c1018
Merge pull request #8494 from yyforyongyu/update-fn
gomod: bump `fn` version to `v1.0.2`
2024-02-21 02:09:57 -06:00
yyforyongyu
d38f949072
gomod: bump fn version to v1.0.2 2024-02-21 08:35:08 +08:00
Elle Mouton
a3ccae9a55
docs: update release notes 2024-02-20 14:44:39 +02:00
Elle Mouton
4ab17525ce
itest+lntest: add wtclient session & tower management test 2024-02-20 14:44:39 +02:00
Elle Mouton
59a4bfbc59
itest+refactor: extract various tower test helpers 2024-02-20 14:44:39 +02:00
Elle Mouton
d4424fbcfa
itest: refactor watchtower related tests 2024-02-20 14:44:39 +02:00
Elle Mouton
1c7a7543c7
lnrpc: add session ID to tower session info
This will be used in the itest added in an upcoming commit so that we can
test the TerminateSession command.
2024-02-20 14:44:39 +02:00
Elle Mouton
a9648cbdd1
wtclient: load all active towers into memory
Load an active tower into memory regardless of whether or not it has any
sessions.
2024-02-20 14:44:38 +02:00
Elle Mouton
5d16491c13
lnrpc+lncli: add TerminateSession command 2024-02-20 14:44:38 +02:00
Elle Mouton
24702ede14
wtclient: add TerminateSession method 2024-02-20 14:44:37 +02:00
Elle Mouton
05c03400a9
wtdb: add TerminateSession method 2024-02-20 14:44:11 +02:00
Elle Mouton
41582c0b8b
wtdb: create and remove tower should no longer change session status 2024-02-20 14:44:11 +02:00
Elle Mouton
cbf08940ca
wtdb: let DeleteCommitedUpdates move session to terminal
In this commit, we adjust the DeleteCommitmentUpdate method so that it
marks a session as Terminal (if there are updates to delete) since once
we have deleted a commitment update from a session - the session is no
longer useable.
2024-02-20 14:44:11 +02:00
Elle Mouton
5cb8c8df7e
wtdb: rename CSessionInactive to CSessionTerminal
Since we will now change this to mean that the session should not ever
be activated again.
2024-02-20 14:44:11 +02:00
Elle Mouton
26432359ad
lnrpc+lncli: add DeactivateTower to rpc 2024-02-20 14:44:11 +02:00
Elle Mouton
beb9b2eeb8
wtclient: add DeactivateTower method
This commit adds the DeactiateTower method to the wtclient.ClientManager
interface along with its implementation. A test is also added for the
new method.
2024-02-20 14:44:09 +02:00
Elle Mouton
4548e72f79
wtdb: add a DeactivateTower method
This new method sets the tower's status to inactive so that it is not
loaded at startup as a candidate tower. We also ensure that a tower's
status is set to active if the CreateTower is called when the tower
already exists.
2024-02-20 09:02:36 +02:00
Elle Mouton
0bb1816fff
watchtower: add filter function to ListTowers
And then only load active towers on client start up.
2024-02-20 08:58:46 +02:00
Elle Mouton
ffd355c6c4
wtdb: add TowerStatus to Tower
This is added as a TLV record meaning that all the towers currently on
disk that don't have this new field will be seen as Active.
2024-02-20 08:58:46 +02:00
Elle Mouton
1ae802812c
watchtower: update DeleteCommittedUpdate to delete all
This commit updates the DeleteCommittedUpdate DB method to delete all of
a given session's committed updates instead of just one at a time. The
reason for this is that in an upcoming commit, we will introduce a
"Terminal" session state - once we have deleted a committed update for a
session it should be considered "Terminal" and there is never a case
where we would only want to delete one committed update and not the
rest. So we want these two actions (deleting committed updates of a
session and setting it's status to terminal) to be atomic.
2024-02-20 08:58:45 +02:00
Keagan McClelland
fb8de14798 lnwallet+funding+lnd: trim unused parameters, from lnwallet.Config
chainreg: remove unused GenDefaultBtcConstraints

lnwallet+funding+lnd: remove DefaultDustLimit from lnwallet.Config
2024-02-19 17:06:21 -08:00
Keagan McClelland
c6ecb10865 chainreg+lnd: remove ChannelConstraints from PartialChainControl 2024-02-19 17:06:21 -08:00
Andras Banki-Horvath
bcc6a3f517
docs: update release notes for 0.18.0 2024-02-19 20:47:25 +01:00
Andras Banki-Horvath
f5abc94bdf
mod: bump kvdb to v1.4.5 2024-02-19 20:47:25 +01:00
Andras Banki-Horvath
7d56d5385d
invoices: parametrize invoice(registry) tests with InvoiceDB constructor
This commit extracts the InvoiceDB construction from all invoice and
registry tests such that we can later on run subtests with multiple
backends without needing to use tags.
2024-02-19 20:47:25 +01:00
Andras Banki-Horvath
0e2b39ed44
invoices: fix linter issues after the move 2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
5e746b4d2c
invoices: move InvoiceDB tests unrelated to kvdb to invoices package 2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
6b0931af82
invoices: move UpdateInvoice implementation to the invoices package
With the introducation of the `InvoiceUpdater` interface we are now
able to move the non-kv parts of `UpdateInvoice` completely under
the invoices package. This is a preprequisite for being able to use
the same code-base for the sql InvoiceDB implementation of
UpdateInvoice.
2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
ecbfc46312
invoices+channeldb: add InvoiceUpdater interface and the KV impl
This commit introduces the InvoiceUpdater interface which is meant
to abstract and assist the in-memory invoice update procedure with
the accompanying database updates. These abstract updater steps will
enable further refactoring later while also ensuring that a full
SQL implementation of the InvoiceDB interface will be possible.
2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
998156930f
invoices: refactor updateInvoiceAmpState to return new state
With this commit updateInvoiceAmpState becomes getUpdatedInvoiceAmpState
which will only return the new AMP state but that needs to be applied at
the call site. This is a part of a larger refactor to gather all
mutations of an invoice update to be later applied by the invoice
updater.
2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
08df7f4175
invoices: change cancelSingleHtlc to be purely used for validation
This change moves the HTLC state change out of the cancelSingleHtlc
function. This is part of the larger refactor of collecting all changes
to be later applied by the invoice updater.
2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
87044b815c
invoices: rename updateInvoiceState to getUpdatedInvoiceState
This commit turns updateInvoiceState "const" by moving preimage update
out of the function while also removing it to getUpdatedInvoiceState.
2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
342eb4eac2
invoices: refactor updateHtlc to return new state
With this refactor updateHtlc is renamed to getUpdatedHtlcState and
changed such that it won't change the HTLC's state and resolve time but
instead returns whether the change is needed. This change is part of a
multi-commit refactor to ensure that all changes to the invoice will be
tracked individually.
2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
ef5a31733e
channeldb: do not change the update descriptor when cancelling htlcs 2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
7298b2d190
channeldb: extract AMP state updates to updateInvoiceAmpState() 2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
4bf6b52158
channeldb: fetch the invoice before calling into updateInvoice 2024-02-19 20:47:22 +01:00
Andras Banki-Horvath
eb4198b970
channeldb: extract store update methods when updaing an invoice
This commit is a small refactor to move all actual DB updates after
an invoice state is update to separate methods. This is a small
preliminary change before we completely decouple DB updates from
in-memory invocie update.
2024-02-19 20:47:22 +01:00
Oliver Gugger
a3bf2c70e5
Merge pull request #8486 from joaothallis/fix/link-typo
docs: fix typo and links
2024-02-19 02:43:11 -06:00
João Thallis
805c1c0d59
docs: fix contribution guide links [skip ci] 2024-02-17 21:48:01 -03:00
joao
1e7f0d42ad
docs: fix makefile typo [skip ci] 2024-02-17 21:47:38 -03:00
Olaoluwa Osuntokun
7a3101710c
Merge pull request #8430 from bhandras/update-pr-stats
github: bump pull-resquest-stats to v2.11.0
2024-02-14 17:52:11 -08:00
Oliver Gugger
f008a97082
Merge pull request #8479 from tdb3/master
lnrpc: Clarify payment_addr and payment_secret
2024-02-14 03:49:47 -06:00
tdb3
3288490df3
lnrpc: Clarify payment_addr and payment_secret
Fix #7438, adding clarification statements in lnrpc proto files.
Originally proposed by daredevil3435 in PR #7873 and PR #7885.
2024-02-13 19:04:18 -05:00
Oliver Gugger
4855faf162
Merge pull request #8471 from morehouse/codeowners
.github: add morehouse to CODEOWNERS
2024-02-12 02:24:22 -06:00
Matt Morehouse
7a0390fe59
.github: add morehouse to CODEOWNERS 2024-02-09 10:27:17 -06:00
Oliver Gugger
17f5798726
Merge pull request #8466 from weiliy/docs-fix-mining-address
docs: preserve MINING_ADDRESS across docker-compose sessions
2024-02-08 02:41:20 -06:00
Weili Y
d740e95c08
docs: preserve MINING_ADDRESS across docker-compose sessions
Export MINING_ADDRESS before docker-compose up to ensure it's retained for
subsequent operations, fixing block generation errors due to missing mining
addresses.
2024-02-07 20:24:24 +08:00
Yong
9651ee6372
Merge pull request #8452 from ProofOfKeags/refactor/contractcourt/naming-consistency
contractcourt: homogenize naming convention
2024-02-07 18:54:55 +08:00
rockstardev
3da3d28064 Adding BtcPayServer related files and resources 2024-02-06 21:29:46 -06:00
Keagan McClelland
0f245bf237 contractcourt: rename breacharbiter*.go to breach_arbitrator
This is just to finish the cleaning things up to make them more
consistent.
2024-02-06 13:32:51 -07:00
Keagan McClelland
bc3feba267 contractcourt+lnrpc+lnd: s/BreachArbiter/BreachArbitrator
Since we have two other examples of XArbitrator, we rename
BreachArbiter to BreachArbitrator to keep things consistent.
The aim is to reduce the amount of lore you need to know to
intuit where things are or what they do.
2024-02-06 13:32:47 -07:00
Olaoluwa Osuntokun
771d1f0a9c
Merge pull request #8338 from lightningnetwork/coop-close-v2-wire-messages
lnwire: add new closing_complete and closing_sig messages
2024-02-05 17:08:36 -08:00
Olaoluwa Osuntokun
8bba79222f
build: bump version to v0.17.4-beta 2024-02-05 16:32:42 -08:00
Olaoluwa Osuntokun
ba3c0c497a
.github: codeowners additions 2024-02-05 16:30:31 -08:00
Olaoluwa Osuntokun
5953eaa9d8
lnwire: add fuzz tests for ClosingComplete+ClosingSigs 2024-02-05 16:30:26 -08:00
Olaoluwa Osuntokun
3d88017b38
lnwire: add new closing_complete and closing_sig messages
These two messages will be used to implement the new and improved co-op
closing protocol. This PR also show cases how to use the new
`tlv.OptionalRecord` type to define and handle TLV level parsing.

I think we can make one additional helper function to clean up some of
the boiler plate for the encode/decode.
2024-02-05 16:30:23 -08:00
Olaoluwa Osuntokun
34fd35bc63
lnwire: add Record() method to lnwire.Sig
We'll use this later on to re-use the normal primitive record to create
a series of new TLV types for the new co-op close protocol.
2024-02-05 16:30:16 -08:00
Olaoluwa Osuntokun
ab8f319750
Merge pull request #8455 from Roasbeef/v0-17-4-branch
release: update v0.17.4 release branch to rc2
2024-02-05 11:57:31 -08:00
Yong
63e698ec49
Merge pull request #8432 from yyforyongyu/fix-timestamp-precision
invoice+payment: fix timestamp precision for queries
2024-02-05 18:28:39 +08:00
Oliver Gugger
4584f7e39c
Merge pull request #8457 from mohamedawnallah/lnddir-option-overwrite-docs
docs: mention that `--lnddir` option overwrites all other directory options [skip ci]
2024-02-05 03:36:05 -06:00
Mohamed Awnallah
043834c698
config.go: mention that --lnddir option overwrites all other directory options [skip ci] 2024-02-05 11:30:09 +02:00
Oliver Gugger
e9bc9ad510
Merge pull request #8456 from Roasbeef/record-zero-fn
tlv: add new Zero method on RecordT
2024-02-05 02:48:38 -06:00
yyforyongyu
4da9582862
docs: add release notes for precision fix 2024-02-05 15:26:54 +08:00
yyforyongyu
605211823d
multi: fix timestamp filters for payment query
This commit fixes the timestamp precision to always compare the dates
using unix seconds for payments.
2024-02-05 15:26:49 +08:00
yyforyongyu
18333e8c7d
multi: fix timestamp filters for invoice query
This commit fixes the timestamp precision to always compare the dates
using unix seconds for invoices.
2024-02-05 15:26:43 +08:00
yyforyongyu
221e7ff898
itest: update testListPayments to precisely test timestamp filters 2024-02-05 15:23:57 +08:00
Yong
d41b86bb7e
Merge pull request #7852 from ziggie1984/pathfind_sizeestimate
Path Finding Size Estimation including Blinded Path Data
2024-02-05 15:21:51 +08:00
ziggie
da5055c210
docs: add release-notes. 2024-02-03 12:16:07 +00:00
ziggie
4732c09a26
multi: Fix final hop payload size for AMP payments. 2024-02-03 12:16:06 +00:00
ziggie
ff30ff40bf
multi: Fix final hop payload size for blinded rt.
The final hop size is calculated differently therefore we extract
the logic in its own function and also account for the case where
the final hop might be a blinded hop.
2024-02-03 12:11:01 +00:00
ziggie
c1b91fff14
multi: use new AdditionalEdge interface.
In the previous commit the AdditionalEdge interface was introduced
with both of its implementations `BlindedEdge` and `PrivateEdge`.
In both cases where we append a route either by a blinded route
section or private route hints we now use these new types. In
addition the `PayloadSizeFunc` type is introduced in the
`unifiedEdge` struct. This is necessary to have the payload size
function at hand when searching for a route hence not overshooting
the max sphinx package size of 1300 bytes.
2024-02-03 12:10:46 +00:00
Yong
54c47a3feb
Merge pull request #8449 from ProofOfKeags/refactor/lnwallet/delete-LightningChannel-status
lnwallet: simplify status row
2024-02-03 13:48:31 +08:00
Olaoluwa Osuntokun
78e0e5ac5d
tlv: add new Zero method on RecordT
In this commit, we add a new `Zero` method for the `RecordT` type. This
method allows a caller to create the zero record for a type without
needing to reference the actual TLV type.

With this we go from this:
```go
sig1 := tlv.ZeroRecordT[tlv.TlvType1, Sig]()
```

To this:
```
sig1 := c.CloserNoClosee.Zero()
```
2024-02-02 17:31:06 -08:00
Olaoluwa Osuntokun
47fced69da
Merge pull request #8440 from saubyk/codeowners
Add CODEOWNERS file
2024-02-02 17:25:30 -08:00
Olaoluwa Osuntokun
504f0d0024
build: bump version to v0.17.4 rc2 2024-02-02 17:08:07 -08:00
Olaoluwa Osuntokun
18d94a22a3 Merge branch 'v0-17-4-branch-7372' into v0-17-4-branch 2024-02-02 17:06:44 -08:00
Andras Banki-Horvath
b119ac87f9 docs: update release notes for 0.17.4 2024-02-02 17:06:27 -08:00
Andras Banki-Horvath
b1506eca95 itests: add itest for ListSweeps's start_height 2024-02-02 17:05:25 -08:00
Andras Banki-Horvath
1ae89d67ad walletkit: add startheight parameter to ListSweeps
By default ListSweeps will list all sweeps known to the wallet. Over
time this may become expensive to call and callers may not be interested
in the full history. This commit adds a `startheight` parameter to the
`ListSweeps` RPC call. This parameter can be used to fetch sweeps only
from a specified start block height or only unconfirmed ones if it is
set to -1.
2024-02-02 17:04:18 -08:00
Keagan McClelland
3a02f2ba65 lnwallet: use ResetState instead of tweaking private rows 2024-02-02 11:46:32 -08:00
Keagan McClelland
606f8e79d1 lnwallet: rewrite channelState to bool for clarity
Over the last few commits we have systematically eliminated all but
two states. This allows us to replace it with a boolean to encode
the two remaining states. We would like to be able to eliminate this
field entirely, but doing so requires being able to prove that the
concurrent request block is necessary. This is more difficult and
will be left to future commits.
2024-02-02 11:46:32 -08:00
Keagan McClelland
17e67348a8 lnwallet: remove unused channelPending channelState
lnwallet: remove unused channelPendingPayment channelState

Since this state is never set nor read, we remove it completely.

lnwallet: remove redundant channelDispute channelState

In this case, even though we do set this value, it is never read.
Further, the times we read the field at all from LightningChannel
we want the situation of force-closure to block any other
concurrent closure attempts, so we change the sites where we set
channelDispute to channelClosed.

lnwallet: remove redundant channelClosing channelStatus

This value is never used to impact control flow so we need not set
it. We also need not have it.
2024-02-02 11:46:20 -08:00
Keagan McClelland
4e6b1cda49 lnwallet: change channelDispute to channelClosed so errors are handled 2024-02-02 11:40:22 -08:00
Oliver Gugger
ca5f23a647
Merge pull request #7372 from bhandras/listsweeps-range
walletrpc: add `startheight` parameter to the `ListSweeps` RPC
2024-02-02 02:03:16 -06:00
saubyk
fd212ed8c2
.github: add CODEOWNERS file 2024-02-01 12:16:40 -08:00
Andras Banki-Horvath
c4472254ef
docs: update release notes for 0.18.0 2024-02-01 21:02:25 +01:00
Andras Banki-Horvath
187e61da23
itests: add itest for ListSweeps's start_height 2024-02-01 21:02:25 +01:00
Andras Banki-Horvath
7725a57055
walletkit: add startheight parameter to ListSweeps
By default ListSweeps will list all sweeps known to the wallet. Over
time this may become expensive to call and callers may not be interested
in the full history. This commit adds a `startheight` parameter to the
`ListSweeps` RPC call. This parameter can be used to fetch sweeps only
from a specified start block height or only unconfirmed ones if it is
set to -1.
2024-02-01 21:02:24 +01:00
ziggie
9d3c0d9e3a
routing: add new interface AdditionalEdge.
A new interface AdditionalEdge is introduced which allows us to
enhance the CachedEdgePolicy with additional information. We
currently only need a PayloadSize function which is then used to
determine the exact payload size when building a route to adhere
to the sphinx package size limit (BOLT04).
2024-02-01 17:37:43 +00:00
Yong
5fe99f06ac
Merge pull request #8446 from yyforyongyu/validate-deprecation
lnd: add warning logs if deprecated config options are used
2024-02-01 23:32:35 +08:00
yyforyongyu
1057eb729d
multi: add unsafedisconnect as a dev config
This commit adds a new dev config `unsafedisconnect` as we sometimes
want to disconnect nodes in our itests.
2024-02-01 21:21:18 +08:00
yyforyongyu
9adec89fa8
lncfg: hide deprecated routing.assumechanvalid and neutrino.feeurl 2024-02-01 21:21:16 +08:00
yyforyongyu
78d552de22
config+rpcserver: hide deprecated option unsafe-disconnect
Also fix a case where this deprecated flag is used. We will always
bypass the active channels check when `DisconnectPeer` because
`!r.cfg.UnsafeDisconnect` is always false.
2024-02-01 21:20:11 +08:00
yyforyongyu
157c84cc4d
multi: log warnings if deprecated config options are used
This commit adds warning logs if the user uses deprecated config
options, paving the way for future removal.
2024-02-01 21:20:11 +08:00
Olaoluwa Osuntokun
7d74165296
Merge pull request #8442 from ProofOfKeags/bugfix/shutdown-msg
peer: fix issue where we echo remote Shutdown
2024-01-31 12:05:30 -08:00
Olaoluwa Osuntokun
ed6f03ea3e
Merge pull request #8416 from Roasbeef/v0-17-4-branch
release: create v0.17.4 rc1 release branch
2024-01-30 15:32:34 -08:00
Olaoluwa Osuntokun
b5cfc2fa05 Merge branch 'v0-17-4-branch-8437' into v0-17-4-branch 2024-01-30 11:24:27 -08:00
Elle Mouton
8f1460464e tls_manager: let REST proxy skip tls cert verification 2024-01-30 11:24:12 -08:00
Olaoluwa Osuntokun
cf4f468ab5
Merge pull request #8437 from ellemouton/v0-17-3-tls-fix
tls_manager: let REST proxy skip tls cert verification
2024-01-30 11:22:31 -08:00
Keagan McClelland
317aaf9940 peer: fix issue where we echo remote Shutdown 2024-01-30 12:15:59 -05:00
Yong
c89005c3a1
Merge pull request #8431 from ziggie1984/unhandled-witness-type-taproot
walletrpc: Add Taproot witness types to rpc.
2024-01-30 11:40:07 +08:00
Olaoluwa Osuntokun
6cbe5172d6 Merge branch 'v0-17-4-branch-8428' into v0-17-4-branch 2024-01-29 17:58:17 -08:00
ziggie
b02bbd5e95 docs: update release-notes. 2024-01-29 17:58:08 -08:00
ziggie
f9a2818d95 mod: update btcwallet version.
Update the btcwallet version to fix a case where fetching of
already pruned blocks from our peers was not garbage collected
when the request failed.
2024-01-29 17:57:14 -08:00
Yong
dd7b186622
Merge pull request #8426 from breez/expose-closing-tx
Expose closing tx in waiting_close_channels
2024-01-30 09:13:17 +08:00
Elle Mouton
404a50ae25
tls_manager: let REST proxy skip tls cert verification 2024-01-29 17:56:50 +02:00
ziggie
13e20e99e4
docs: add release-notes. 2024-01-29 15:10:15 +00:00
ziggie
339c5fe1f0
makefile: add rpc tags to the unit tests. 2024-01-29 15:09:22 +00:00
ziggie
4f77758419
walletrpc: Add Taproot witness types to rpc. 2024-01-29 15:09:22 +00:00
Jesse de Wit
172e8366d4
docs: add release note for 8426 2024-01-29 14:16:51 +01:00
Jesse de Wit
ef3aa84c10
lncli: add include_raw_tx flag to pendingchannels 2024-01-29 14:16:51 +01:00
Jesse de Wit
b6616bc040
itest: assert closing tx is set in waiting_close_channels 2024-01-29 14:16:51 +01:00
Jesse de Wit
e794bd37a4
lnrpc: include raw closing tx in waiting_close_channels 2024-01-29 14:16:50 +01:00
Yong
b76d3e64d3
Merge pull request #8428 from ziggie1984/prune-node-deadlock-blocksync
Fix Pruned Node Loss Sync Issue.
2024-01-29 20:42:02 +08:00
Oliver Gugger
c517d4ccd9
Merge pull request #8427 from yyforyongyu/fix-rpc-docs
trivial: fix docs on `ListPaymentsRequest`
2024-01-29 06:26:17 -06:00
Oliver Gugger
1e5ff5fa27
Merge pull request #8438 from guggero/fix-sendpayment-api-docs
routerrpc: make use of fee limit obvious in SendPaymentV2
2024-01-29 06:16:51 -06:00
Oliver Gugger
eb08a6f004
routerrpc: make use of fee limit obvious in SendPaymentV2 2024-01-29 13:45:14 +02:00
ziggie
141a30dc37
docs: update release-notes. 2024-01-29 10:23:03 +00:00
ziggie
d2c82c49ca
mod: update btcwallet version.
Update the btcwallet version to fix a case where fetching of
already pruned blocks from our peers was not garbage collected
when the request failed.
2024-01-29 10:23:03 +00:00
Yong
59feec44ca
Merge pull request #7976 from w3irdrobot/serialize-deserialize-amp
Serialize/deserialize AMP struct in hop
2024-01-29 09:48:05 +08:00
Olaoluwa Osuntokun
d44c72b979
Merge pull request #8345 from yyforyongyu/use-testmempoolaccept
lnwallet: perform mempool acceptance check before publishing
2024-01-26 18:54:43 -08:00
Alex Sears
0767a2cbc0
routerrpc: unmarshal AMP record in route hop marshalling 2024-01-26 15:21:43 -05:00
Olaoluwa Osuntokun
0d37621bcb
Merge pull request #8420 from ProofOfKeags/cleanup/contractcourt/naming
contractcourt: rename files for package consistency
2024-01-25 15:23:02 -08:00
yyforyongyu
a614888797
lnwallet/test: fix testPublishTransaction for neutrino 2024-01-26 03:01:20 +08:00
yyforyongyu
d2ab35629a
lnwallet/test: fix ZMQ format 2024-01-26 03:01:20 +08:00
Yong
2f1468000d
Merge pull request #8421 from ProofOfKeags/refactor/lnwallet/redundant-fields
lnwallet: remove redundant unused fields
2024-01-26 02:59:08 +08:00
Andras Banki-Horvath
59ce7d9845
github: bump pull-resquest-stats to v2.11.0 2024-01-25 18:08:34 +01:00
Yong
b9a8e2f6d0
Merge pull request #8419 from bhandras/kvdb-embedded-postgres-upgrade
kvdb: embedded postgres upgrade to allow setting a custom `max_connections` config value
2024-01-25 23:18:46 +08:00
yyforyongyu
cb2c2e89dd
lnrpc: fix docs on ListPaymentsRequest 2024-01-25 19:49:29 +08:00
Keagan McClelland
9c2270a5ea lnwallet: remove redundant unused fields 2024-01-24 17:22:35 -08:00
Keagan McClelland
9b92b55b9b contractcourt: rename files for package consistency 2024-01-24 17:15:01 -08:00
Olaoluwa Osuntokun
08cb77c415
build: bump version to v0.17.4-beta.rc1 2024-01-24 16:52:01 -08:00
Olaoluwa Osuntokun
2859a5a16d Merge branch 'v0-17-4-branch-8401' into v0-17-4-branch 2024-01-24 16:51:00 -08:00
yyforyongyu
a6fc5a901a chainreg: satisfy chain.Interface in NoChainSource 2024-01-24 16:50:52 -08:00
yyforyongyu
6d566068df docs: update release notes for mem leak fix 2024-01-24 16:50:51 -08:00
yyforyongyu
033292f2c2 blockcache: fix heap escape in GetBlock
This commit fixes a heap escape found in `GetBlock`. This happens
because the `msgBlock` is a pointer returned from `getBlockImpl`, and
the whole `getBlockImpl` escapes to the heap because it's referenced in
two places,
- in the `Cache`, it's used as a reference type to create the new block.
- this pointer is also returned and now needs to stay on the heap.

The fix is simple, we now make a copy of the block and use the copy
instead, freeing `getBlockImpl` from the heap.
2024-01-24 16:48:32 -08:00
yyforyongyu
68c24831df gomod: update btcd version to fix mem leak 2024-01-24 16:48:30 -08:00
Olaoluwa Osuntokun
599ff50fd4 Merge branch 'v0-17-4-branch-8406' into v0-17-4-branch 2024-01-24 16:46:48 -08:00
ziggie
a258ff74e9 docs: add release-notes. 2024-01-24 16:46:40 -08:00
ziggie
8a825a4687 multi: Add itest for a failed funding flow.
This adds an itest for a failed funding flow by our peer.
2024-01-24 16:46:38 -08:00
ziggie
192c35b2c7 peer: add unit test.
Add a unit test for the removal of a pending channel.
2024-01-24 16:46:02 -08:00
ziggie
39206a96fb funding: initialize remove channel. 2024-01-24 16:46:02 -08:00
Olaoluwa Osuntokun
0d5deef407 Merge branch 'v0-17-4-branch-8413' into v0-17-4-branch 2024-01-24 16:45:41 -08:00
Elle Mouton
c2a597747d docs: add template for 0.17.4 2024-01-24 16:45:41 -08:00
yyforyongyu
783e914027
lnwallet/test: stop creating burning tx in tests
bitcoind v25.0 updated the `sendrawtransaction` RPC to have an optional
argument `maxburnamount` with a default value of 0. This means our
existing test that uses burning output cannot be published, hence, we
remove the usage of it in our tests and replace it with a normal tx.
2024-01-25 08:45:22 +08:00
Olaoluwa Osuntokun
11bafe84ff
lnwallet/test: add new tx publish sub-test for policy weight limits 2024-01-25 08:45:22 +08:00
Olaoluwa Osuntokun
a616fa3fb7
lnwallet/test: convert the tx publish tests to sub-tests 2024-01-25 08:21:11 +08:00
yyforyongyu
a6a8415a26
contractcourt: make sure ChainArbitrator is started properly
We should not fail to start the node if a republish attempt failed for a
channel's closing tx. Instead, we log an error to continue the startup
and let other channels continue their operations.
2024-01-25 07:54:39 +08:00
yyforyongyu
fb1c6ea6a7
btcwallet: proceed to call PublishTransaction on mempool errors
Previously, `PublishTransaction` in `btcwallet` will first mark the tx
label in db first before broadcasting it to the network. Even though the
broadcast may fail with the error already in mempool or already
confirmed, this tx label updating is still performed. To maintain the
old behavior, we now catch the errors from `TestMempoolAccept`, and make
sure to call the `PublishTransaction` to mark the tx label even there
are errors from mempool acceptance check.
2024-01-25 07:54:39 +08:00
yyforyongyu
1435ba5636
docs: add release note for testmempoolaccept 2024-01-25 07:54:39 +08:00
yyforyongyu
2686ca324a
lnwallet: check mempool acceptance before publishing
This commit adds a mempool acceptance check before broadcasting a given
transaction. To maintain the current behavior from
`BtcWallet.PublishTransaction`, the two errors, `ErrInMempool` and
`ErrAlreadyConfirmed` returned from `TestMempoolAccept` are ignored.
2024-01-25 07:54:39 +08:00
yyforyongyu
e4482421c9
gomod+chainreg: update btcwallet to use TestMempoolAccept 2024-01-25 07:54:35 +08:00
Andras Banki-Horvath
560ea95a59
docs: update release notes for 0.18 2024-01-24 21:38:54 +01:00
Andras Banki-Horvath
25af657ad5
kvdb: set postgres max_connections on the started instance 2024-01-24 21:38:54 +01:00
Andras Banki-Horvath
524fa66abf
kvdb: bump embedded postgres to v1.25.0 2024-01-24 21:38:53 +01:00
Olaoluwa Osuntokun
758ae6fbec
Merge pull request #8336 from lightningnetwork/fn-module-goodies
fn: add some new goodies to sub-module to be used in future PRs
2024-01-23 19:18:34 -08:00
Olaoluwa Osuntokun
1d1c1382d0
fn: add utility funcs/method for option type 2024-01-23 19:09:59 -08:00
Olaoluwa Osuntokun
1fc3f14467
fn: add new generic set container 2024-01-23 19:09:53 -08:00
Olaoluwa Osuntokun
eb72bb9712
fn: add SendOrQuit 2024-01-23 19:09:50 -08:00
Olaoluwa Osuntokun
a2694009cd
fn: add basic generic chan recv utility funcs 2024-01-23 19:09:47 -08:00
Olaoluwa Osuntokun
f7e2e6ddd6
fn: add basic generic queue 2024-01-23 19:09:45 -08:00
Olaoluwa Osuntokun
f166829fe4
fn: add reduce func 2024-01-23 19:09:42 -08:00
Olaoluwa Osuntokun
d702158d9b
fn: add new EventPublisher event pub/sub system
This builds on the concurrent queue to create a generic way to allow
goroutines to pub/sub information. An example includes being notified
each time a state machine is able to carry out a new state transition.
2024-01-23 19:09:39 -08:00
Olaoluwa Osuntokun
1cbfda525a
fn: add new Either[L, R] type
This implements a union of two values. Uses the existing option under
the hood, and adds a simple helper function.
2024-01-23 19:09:36 -08:00
Olaoluwa Osuntokun
0715e84f04
fn: add new ConcurrentQueue[T] data structure
This is a version of the queue we have elsewhere, but we can get rid of
all the casting and interface usage in favor of a type param.
2024-01-23 19:09:29 -08:00
Olaoluwa Osuntokun
1caca81ba1
Merge pull request #8167 from ProofOfKeags/bugfix/htlc-flush-shutdown
Bugfix/htlc flush shutdown
2024-01-23 18:49:47 -08:00
Keagan McClelland
69ef1b2b3b docs: update release notes 2024-01-23 14:31:57 -08:00
Keagan McClelland
07277172f8 itest+lntest: remove temporary hacks around broken coop close in itests 2024-01-23 14:31:51 -08:00
Keagan McClelland
9e58ebd0fb itest: test that we can close with in-flight htlcs 2024-01-23 12:25:06 -08:00
Keagan McClelland
94373bd96f htlcswitch: placate confused linter 2024-01-23 12:25:06 -08:00
Keagan McClelland
804dabb4ea lnd: make closechannel send an instant empty update when no_wait set
We do things this way to keep behavior consistent across REST, gRPC
and CLI consistent. This was done to not alter the way we handle
Recv calls from the streams.
2024-01-23 12:25:01 -08:00
Oliver Gugger
e31d159893
Merge pull request #8401 from yyforyongyu/update-btcd-ver
gomod: fix `btcd` mempool leak fix and `GetBlock` heap escape
2024-01-23 11:42:09 -06:00
Oliver Gugger
d7796b464e
Merge pull request #8377 from ellemouton/towerTestFlakeFix
wtclient: ensure correct disk mode for overflow queue
2024-01-23 09:47:27 -06:00
yyforyongyu
e6f5d17548
chainreg: satisfy chain.Interface in NoChainSource 2024-01-23 17:46:06 +08:00
Oliver Gugger
7d03b43ddf
Merge pull request #8314 from mohamedawnallah/add-auto-protolinter
[CI]: Install protolint to enforce the protobuf style guide rules in the CI
2024-01-23 03:25:55 -06:00
yyforyongyu
ff1f33eee9
docs: update release notes for mem leak fix 2024-01-23 17:09:44 +08:00
yyforyongyu
4ee862e3be
blockcache: fix heap escape in GetBlock
This commit fixes a heap escape found in `GetBlock`. This happens
because the `msgBlock` is a pointer returned from `getBlockImpl`, and
the whole `getBlockImpl` escapes to the heap because it's referenced in
two places,
- in the `Cache`, it's used as a reference type to create the new block.
- this pointer is also returned and now needs to stay on the heap.

The fix is simple, we now make a copy of the block and use the copy
instead, freeing `getBlockImpl` from the heap.
2024-01-23 17:08:57 +08:00
yyforyongyu
77e5deae9d
gomod: update btcd version to fix mem leak 2024-01-23 17:08:54 +08:00
Elle
51de320d69
Merge pull request #8385 from Roasbeef/ping-async-dc
peer: make PingManager disconnect call async
2024-01-23 09:24:11 +02:00
Keagan McClelland
359f271541
docs: update release notes 2024-01-22 18:20:36 -08:00
Olaoluwa Osuntokun
185119f5c3
peer: refactor main event loop for ping handler
The error was never used as the init couldn't return an error, so we do
away with that. We also modify the main event loop dispatch to more
closely match other areas of the codebase.
2024-01-22 18:20:30 -08:00
Olaoluwa Osuntokun
b5cbeb4ad7
peer: make PingManager disconnect call async
In this commit, we make all calls to disconnect after a ping/pong
violation is detected in the `PingManager` async. We do this to avoid
circular waiting that may occur if the disconnect call back ends up
waiting on the peer goroutine to be torn down. If this happens, then the
peer goroutine will be blocked on the ping manager fully tearing down,
which is blocked on the peer disconnect succeeding.

This is a similar class of issue we've delt with recently as pertains to
the peer and the server: sync all back execution must not lead to
a circular waiting loop.

Fixes #8379
2024-01-22 18:20:23 -08:00
Keagan McClelland
ec55831229 htlcswitch+peer: remove ShutdownIfChannelClean 2024-01-22 16:08:59 -08:00
Keagan McClelland
64fda6ca65 htlcswitch: implement flush and commit lifecycle hooks for channelLink 2024-01-22 16:08:55 -08:00
Olaoluwa Osuntokun
41c167d37c
Merge pull request #8400 from ellemouton/deadlockFix
channeldb: acquire mutexes in the same order throughout
2024-01-22 12:57:48 -08:00
Keagan McClelland
601afaf1b2 htlcswitch: implement flush api for channelLink 2024-01-22 12:19:58 -08:00
Keagan McClelland
891b00d473 htlcswitch: drop the connection when receiving an invalid add
When the link is flushing in the incoming direction, it means
adds are invalid. The best chance we have at dealing with this
is to drop the connection. This should roll back the channel
state to the last CommitSig. If the remote has already sent a
CommitSig we haven't received yet, channel state will be
re-synchronized with a ChannelReestablish message upon
reconnection and the protocol state that caused us to flush
the link will be rolled back. In the event that there was some
non-deterministic behavior in the remote that caused them to
violate the protocol, we have a decent shot at correcting it
this way, since reconnecting will put us in the cleanest
possible state to try again.
2024-01-22 12:19:58 -08:00
Keagan McClelland
a9d5235c62 htlcswitch: bounce downstream adds when flushing 2024-01-22 12:19:58 -08:00
Keagan McClelland
5ab69aedc7 peer: remove tryLinkShutdown due to redundance
We don't need to try a link shutdown when the chan closer is fetched
since, by this commit, the only callsite manages the shutdown semantics.
After removing the call to tryLinkShutdown, we no longer need the
function at all.
2024-01-22 12:19:58 -08:00
Keagan McClelland
025e569f07 peer: fix local close requests to shutdown via link lifecycle hooks
In order to handle shutdown requests when there are still HTLCs on
the link, we have to manage the shutdown process via the link's
lifecycle hooks. This means we can't use the simple `tryLinkShutdown`
anymore and instead queue a `Shutdown` message at the next opportunity
to do so -- when we send our next `CommitSig`
2024-01-22 12:19:58 -08:00
Keagan McClelland
442f1dd677 peer: handle close messages using link lifecycle hooks 2024-01-22 12:19:58 -08:00
Keagan McClelland
70292253d1 htlcswitch: make link forward eligibility flush aware 2024-01-22 12:19:58 -08:00
Keagan McClelland
6955dc9f12 chancloser: remove ProcessCloseMsg 2024-01-22 12:19:58 -08:00
Keagan McClelland
704eb84bcb chancloser: rewrite tests in terms of new ChanCloser methods 2024-01-22 12:19:58 -08:00
Keagan McClelland
f81e7ada4c peer: rewrite handleCloseMsg in terms of new ChanCloser methods 2024-01-22 12:19:58 -08:00
Keagan McClelland
7b08899cdb chancloser: cache remote ClosingSigned to deal with race 2024-01-22 12:19:58 -08:00
Keagan McClelland
3aceeea4f3 chancloser: move nil MarkCoopBroadcasted to BeginNegotiation 2024-01-22 12:19:58 -08:00
Keagan McClelland
1b0f97a483 chancloser: move initFeeBaseline to BeginNegotiation 2024-01-22 12:19:58 -08:00
Keagan McClelland
45d30af273 chancloser: add BeginNegotiation method to bridge phases 2024-01-22 12:19:58 -08:00
Keagan McClelland
e77d3adef2 chancloser: extract ProcessCloseMsg ClosingSigned handling logic into dedicated method 2024-01-22 12:19:58 -08:00
Keagan McClelland
6fef9ea2d7 chancloser: extract ProcessCloseMsg Shutdown handling logic into dedicated method 2024-01-22 12:19:58 -08:00
Keagan McClelland
30ad49a29d chancloser: add new closeAwaitingFlushState 2024-01-22 12:19:58 -08:00
Keagan McClelland
9b2d1018f2 htlcswitch+peer: add flush api and lifecycle hooks to ChannelUpdateHandler
We also add dummy implementations to channelLink and various mocks.
2024-01-22 12:19:58 -08:00
Mohamed Awnallah
1402ffd17b
protolint: configure protolint and fix the protolinting issues
This PR addresses the following:
- Install and Configure protolint to enforce the protobuf style guide rules in the CI.
- Fix the protolinting issues (package and import ordering) while maintaining the comaptibility.
2024-01-22 22:00:00 +02:00
Elle Mouton
63a3882272
docs: add release note 2024-01-22 21:08:37 +02:00
Elle Mouton
6c427a6ba9
multi: update FetchChanInfos to take in an optional tx
In this commit, the FetchChanInfos ChannelGraph method is updated to
take in an optional read transaction for the case where it is called
from within another transaction.
2024-01-22 21:07:55 +02:00
Elle Mouton
8cf4044215
channeldb: rename delChannelEdge to delChannelEdgeUnsafe
In order to emphasise the fact that the ChannelGraph's cacheMu should be
acquired before calling the `delChannelEdge` method, we add the `Unsafe`
postfix and add a comment to alert readers.
2024-01-22 21:07:55 +02:00
Elle Mouton
ab06665fde
channeldb: acquire mutexes in the same order throughout
In this commit, we ensure that the channeldb cacheMu mutex is only ever
aquired _before_ acquiring the main DB lock in the cases where the two
locks need to be held simultaneously.

With this commit, the deadlock demonstrated in the previous commit is
now fixed.
2024-01-22 21:07:55 +02:00
Elle Mouton
76748bdbf7
channeldb: add ChannelGraph stress test
This commit adds a test that calls many of the ChannelGraph methods
concurrently and in a random order. This test demonstrates that a
deadlock currently exists in the ChannelGraph since the test does not
complete. This is fixed in the next commit.
2024-01-22 21:07:54 +02:00
Yong
ec5b824879
Merge pull request #8406 from ziggie1984/fix-channel-opening-issue
Fix case where Opening Channels get stuck forever.
2024-01-23 02:12:44 +08:00
ziggie
13e557d9b0
docs: add release-notes. 2024-01-22 16:45:39 +00:00
ziggie
ccac5c349c
multi: Add itest for a failed funding flow.
This adds an itest for a failed funding flow by our peer.
2024-01-22 16:45:38 +00:00
ziggie
3530254ff4
peer: add unit test.
Add a unit test for the removal of a pending channel.
2024-01-22 13:01:42 +00:00
ziggie
a5d2541292
funding: initialize remove channel. 2024-01-22 12:58:52 +00:00
Oliver Gugger
e1259cd3c7
Merge pull request #8411 from guggero/make-help
Makefile: add `make help` command that describes goals
2024-01-22 03:59:41 -06:00
Oliver Gugger
35fa053144
Merge pull request #8413 from ellemouton/add-0-17-4-release-notes
docs: add template for 0.17.4
2024-01-22 03:58:16 -06:00
Elle Mouton
2a237209d2
docs: add template for 0.17.4 2024-01-22 11:08:25 +02:00
Oliver Gugger
f35a3718ec
Makefile: add make help command that describes goals
This commit adds a description to each make goal that is printed when
`make help` is run.
Idea borrowed from btcsuite/btcd#2107.
2024-01-22 10:31:48 +02:00
Oliver Gugger
2b83ea309a
Merge pull request #8407 from mohamedawnallah/fix-typo-channel.go
fix: fix typo "(cltv_expiry" to "(cltv_expiry)" in `channeldb/channel.go` [skip ci]
2024-01-22 00:46:06 -06:00
Oliver Gugger
cc18ec4f55
Merge pull request #8354 from mohamedawnallah/add-bitcoind-docker-image-compose-setup
docker: setup `bitcoind` docker image in the `docker-compose.yml` file
2024-01-22 00:43:26 -06:00
Mohamed Awnallah
8407e6989e
fix: fix typo "(cltv_expiry" to "(cltv_expiry)" [skip ci] 2024-01-20 17:31:19 +02:00
Elle
0a29b37be6
Merge pull request #7733 from ellemouton/taprootTowers
watchtower: support taproot channel commitments
2024-01-19 22:55:20 +02:00
Oliver Gugger
24a79c78ed
Merge pull request #8403 from ellemouton/towerInterfaceGotcha
config: pass tower manager pointer in to PopulateDependencies
2024-01-19 07:59:30 -06:00
Mohamed Awnallah
a7914af264
docker: setup bitcoind docker image in the docker compose yaml file 2024-01-19 15:33:47 +02:00
Elle Mouton
2a61c914fb
docs: add release note entry for 7733 2024-01-19 15:33:07 +02:00
Elle Mouton
55ee01a6ca
itest: add taproot tower itest 2024-01-19 15:33:07 +02:00
Elle Mouton
f12cc12da5
server: register a taproot tower client 2024-01-19 15:33:07 +02:00
Elle Mouton
3cb194c45e
lnrpc+lncli: update wtclientrpc for taproot towers 2024-01-19 15:33:06 +02:00
Elle Mouton
660f1f361e
watchtower/wtclient: prep client for taproot towers 2024-01-19 15:33:06 +02:00
Oliver Gugger
c0e3ae6adc
Merge pull request #8399 from yyforyongyu/add-signing-key
scripts: add gpg key for yyforyongyu [skip ci]
2024-01-19 07:15:25 -06:00
Elle Mouton
589cebcec2
config: pass tower manager pointer in to PopulateDependencies
In this commit, we let the explicit wtclient.Manager struct be passed in
to PopulateDependencies instead of the tower client interface. We need
to do this since we do allow the tower client interface to be nil if the
client is not active. So to avoid the golang gotcha where the interface
value will be seen as not nil even though the underlying value is nil,
we pass in the explicit pointer instead.
2024-01-19 13:55:53 +02:00
yyforyongyu
6abfa0b1ee
scripts: add gpg key for yyforyongyu [skip ci] 2024-01-19 01:23:30 +08:00
Elle Mouton
c50aa10194
watchtower/lookout: make justice desciptor taproot ready 2024-01-18 18:06:00 +02:00
Elle Mouton
5960253357
watchtower/blob: add taproot Commitment type 2024-01-18 18:05:58 +02:00
Elle Mouton
d84a98e3db
watchtower/blob: add taprootJusticeKit implementation 2024-01-18 17:59:14 +02:00
Elle Mouton
0ec3f31780
watchtower/blob: add justiceKitPacketV1 encoding
In preparation for the new Taproot commitment type being supported by
watchtowers, we add a new justice packet type.
2024-01-18 17:58:13 +02:00
Elle Mouton
20a107600f
watchtower: add new TaprootCommit Type and flag
This commit adds a new FlagTaprootChannel Flag which is then used to
construct a new blob Type: TypeAltruistTaprootCommit. New watchtower
feature bits are also added (4/5).
2024-01-18 17:56:49 +02:00
Elle Mouton
fde982ad78
input: extract to_local script builders
Factor out the building of the delay and revoke scripts from
NewLocalCommitScriptTree so that they can be re-used later on.
2024-01-18 17:56:48 +02:00
Oliver Gugger
ba4021cad9
Merge pull request #8388 from morehouse/fix_fuzz_payload
htlcswitch: update fuzzPayload for route blinding
2024-01-18 09:31:22 -06:00
Elle
08c18a338b
Merge pull request #8275 from ProofOfKeags/chore/enforce-feature-bits
multi: make legacy feature bits compulsory
2024-01-18 17:26:09 +02:00
Oliver Gugger
4315e80e07
Merge pull request #8394 from cristiantroy/master
fix: typos [skip ci]
2024-01-18 08:52:10 -06:00
cristiantroy
afa21953b5
internal/musig2: fix typos [skip ci] 2024-01-18 20:24:52 +08:00
cristiantroy
f778f8b24e
docs: fix typo in release-notes [skip ci] 2024-01-18 20:24:19 +08:00
Yong
54329a338e
Merge pull request #8387 from ziggie1984/buildroute-use-lnd-default
buildroute use lnd default
2024-01-18 18:53:46 +08:00
Oliver Gugger
dda5c4515e
Merge pull request #8279 from Crypt-iQ/p2tr_weight
sweep: use p2tr output as change weight
2024-01-18 02:11:35 -06:00
Matt Morehouse
0f5ee7cc1e
htlcswitch: update fuzzPayload for route blinding
Route blinding added some new fields to hop.Payload and route.Hop, which
we need to copy over to the fuzzPayload tests.
2024-01-16 11:12:11 -06:00
Yong
1bc1295fc0
Merge pull request #8350 from ziggie1984/rename-bumpclosefee
Minor improvements in the lncli api regarding channel closures.
2024-01-17 00:41:29 +08:00
ziggie
2db5752f99
docs: add release-notes. 2024-01-16 14:10:22 +01:00
ziggie
4db5b2266f
lncli: remove default cltv delta for buildroute.
Now the default of the lnd backend is used instead of providing
the default value via the caller of the buildroute rpc cmd.
2024-01-16 14:10:22 +01:00
ziggie
79fb45074b
routerrpc: use cltv delta default for buildroute.
This commit uses the default timelock delta (cltv delta) when
no value is provided for the buildroute rpc cmd.
Moreover it enhances the docs.
2024-01-16 14:08:51 +01:00
Elle Mouton
65de80be7d
wtclient: remove temporary bug demonstration logic and test
This commit removes the temporary members added to the DiskOverflowQueue
that made it possible to more easily demonstrate a previous bug that
existed.
2024-01-15 17:28:43 +02:00
Elle Mouton
3d201dde50
wtclient: ensure correct disk mode for overflow queue
Before this commit, in the watchtower client's DiskOverflowQueue, there
could be a situation _if no consumer was reading from the queue_ that
could lead to an in-memory build up of backup tasks instead of the
expected disk overflow. This commit fixes this by ensuring that if a
task is read from disk, then the mode is set to disk mode to ensure that
any new items are persisted to disk in this scenario.
The unit tests added in the previous commit is updated here in order to
show that the fix does in-fact fix the test.
2024-01-15 17:28:17 +02:00
Elle Mouton
d4fefda10a
wtclient: demonstrate overflow queue flake
In this commit, some temporary variables and logic is added to the
DiskOverflowQueue for easy stop/go control from unit tests. This is then
used to write a temporary unit tests that demonstrates a race condition
that can cause the queue to be in disk mode when it should be in memory
mode. This new code & test will be removed after the issue has been
fixed.
2024-01-15 17:26:34 +02:00
Oliver Gugger
76ae3e457b
Merge pull request #8382 from ellemouton/bumpTlv
go.mod: update TLV package tag
2024-01-15 16:24:50 +01:00
Elle Mouton
9208083db3
go.mod: update TLV package tag
To v1.2.1
2024-01-15 14:29:57 +02:00
Yong
26c466aa80
Merge pull request #8372 from mohamedawnallah/deep-copy-transactions-GetBlock
routing: deep copy any transaction we obtain from `GetBlock` call.
2024-01-15 20:13:00 +08:00
Mohamed Awnallah
99908ed2dc
routing: deep copy any transaciton we obtain from GetBlock call. 2024-01-15 11:35:55 +02:00
Oliver Gugger
a2986f96da
Merge pull request #8373 from hieblmi/fix-funding-logs
funding: fix funding flow log
2024-01-15 09:24:50 +01:00
Oliver Gugger
cc5fcb8135
Merge pull request #8375 from ProofOfKeags/chore/typo-fix
lnrpc: fix typo in rpc docs
2024-01-12 18:56:46 +01:00
Elle
2824fe27d1
Merge pull request #8233 from ellemouton/unackedUpdatesBug
wtclient: handle un-acked updates for exhausted sessions
2024-01-12 09:49:20 +02:00
Elle Mouton
b14b30ff52
docs: update release notes 2024-01-12 08:25:28 +02:00
Elle Mouton
1daec3e890
wtclient: use the new filter options to fix the demo'd bug
In this commit, we use the newly added session listing options to ensure
that we only see a session as exhausted if it does not have any un-acked
updates on disk. This fixes the bug previously demonstrated.
2024-01-12 08:25:28 +02:00
Elle Mouton
776f2a026c
wtdb: supply commited update count to PostEvaluateFilterFn
In this commit, we adjust the PostEvaluateFilterFn to also take in a
count representing the number of committed updates (ie, persisted
un-acked updates) that the session has. This will be made use of in an
upcoming commit.
2024-01-12 08:23:02 +02:00
Olaoluwa Osuntokun
ba1725f161
Merge pull request #8376 from ProofOfKeags/feature/unsafe-from-some
fn: add UnsafeFromSome to Option API
2024-01-11 17:22:33 -08:00
Keagan McClelland
2499813414 fn: add UnsafeFromSome to Option API 2024-01-11 16:40:48 -08:00
Keagan McClelland
ec854e4dae lnrpc: fix typo in rpc docs 2024-01-11 14:08:31 -08:00
Keagan McClelland
721463c7c7 docs: update release notes 2024-01-11 13:58:01 -08:00
Keagan McClelland
109265c77a multi: make static remote key compulsory 2024-01-11 13:58:01 -08:00
Keagan McClelland
d47338cd45 feature: fixup making data loss protection compulsory 2024-01-11 13:58:01 -08:00
Keagan McClelland
717facc202 feature: make gossip queries compulsory 2024-01-11 13:57:56 -08:00
Slyghtning
a6b4135781
funding: fix logs 2024-01-11 19:39:11 +01:00
Keagan McClelland
239103c2b3 multi: make tlv onion compulsory 2024-01-11 09:43:31 -08:00
Oliver Gugger
2ae6b586e3
Merge pull request #8361 from calvinrzachman/remote-signer-itest
lntest: standby test nodes in remote signing configuration
2024-01-11 16:57:08 +01:00
Elle Mouton
bdf9ec1423
wtclient: demonstrate "tower has un-acked updates" bug
This commit adds a test to demonstrate an edge case that can result in
the "tower has un-acked updates" error being thrown when a user is
attempting to remove a tower. This will be fixed in an upcoming commit.
2024-01-11 15:13:02 +02:00
Calvin Zachman
2209badfe8
lntest: standby test nodes in remote signing configuration
Add the ability to create a test harness with nodes in a
remote signing configuration.
2024-01-10 09:18:30 -06:00
Oliver Gugger
9afe1b72dc
Merge pull request #8188 from guggero/debug-rpcs
rpcserver+lncli: add ability to create encrypted debug information package
2024-01-09 16:28:03 +01:00
Alex Sears
4521894ed2
channeldb: Serialize/deserialize AMP struct in hop
The AMP struct in a hop was never being set when deserizlied. Also,
the AMP TLV record was not being added when the hop was serialized.
This sets the TLV record when serializing and correctly sets the
AMP struct on the hop when that record is present.

Co-authored-by: BitcoinCoderBob <90647227+BitcoinCoderBob@users.noreply.github.com>
Co-authored-by: Tee8z <tee8z@protonmail.com>
2024-01-09 10:02:16 -05:00
Oliver Gugger
ad34f80c85
docs: add release notes 2024-01-09 12:43:44 +01:00
Oliver Gugger
0da35edc48
cmd/lncli: add flags for more info to encryptdebugpackage
This commit adds three optional command line flags to the
encryptdebugpackage: --peers, --onchain and --channels.
Each of them adds the output of extra commands to the encrypted debug
package.
2024-01-09 12:43:42 +01:00
Oliver Gugger
d4f49cb04b
cmd/lncli: add {encrypt,decrypt}debugpackage commands 2024-01-09 12:40:39 +01:00
Oliver Gugger
b6abede4a3
lnencrypt: add ECDHEncryptor
With this commit we add a new way to encrypt and decrypt a sensitive
payload: By using Diffie-Hellman over a local and remote key to derive
at a shared secret key.
2024-01-09 12:32:38 +01:00
Oliver Gugger
375bc6950c
cmd/lncli: add new getdebuginfo command 2024-01-09 12:32:37 +01:00
Oliver Gugger
8a2c3a3d85
lnrpc+rpcserver: add new GetDebugInfo RPC method 2024-01-09 12:32:37 +01:00
Oliver Gugger
becbe7085d
config: create helper for dumping config
With this commit we add a new helper function that recursively turns the
runtime configuration into a flat key/value map that is human-readable,
using the dot notation for nested values that is also used in the config
file or command line flags.
2024-01-09 12:32:01 +01:00
Oliver Gugger
2b54774721
Merge pull request #8339 from mani2310/mani2310-Wrong-documentation-on-lncli
Wrong documentation on lncli
2024-01-09 08:29:06 +01:00
ziggie
90f5dc3efe
docs: update release-docs. 2024-01-09 01:23:58 +01:00
ziggie
1bdc7ce165
lncli: add max_fee_rate to closechannel cmd. 2024-01-09 01:19:10 +01:00
ziggie
7481ed0a43
walletrpc-lncli: add new bumpforceclosefee cmd.
Replace (hide) the old bumpclosefee cmd with the new
bumpforceclosefee cmd to avoid confusion which closing
transactions can be bumped.
2024-01-09 01:15:43 +01:00
ziggie
81dd631935
walletrpc: add status to BumpFeeResponse type.
BumpFee now returns a status signaling the success of the operation.
2024-01-09 01:15:42 +01:00
Yong
34af399a5b
Merge pull request #8096 from ziggie1984/fix-dip-below-reserve
lnwallet: Introduce a fee buffer.
2024-01-09 01:52:04 +08:00
Oliver Gugger
7cb53020ee
Merge pull request #8346 from yyforyongyu/remove-error-return
routing+routerrpc: remove redudant error check
2024-01-08 17:41:32 +01:00
ziggie
320108a424
docs: add release-notes. 2024-01-08 16:47:48 +01:00
ziggie
1aa1e18b9f
routing: add log message. 2024-01-08 16:47:48 +01:00
ziggie
a1678fa9b7
itest: multi part payments test fix.
Because we need to account for an addtional fee buffer we need to
increase channel capacities for the multi payment tests.
2024-01-08 16:47:47 +01:00
Oliver Gugger
8d0abc01c1
Merge pull request #8353 from mohamedawnallah/fix-typo-code-formatting-rules
docs: fix typo "paren" to "parenthesis" in `code_formatting_rules.md` [skip ci]
2024-01-08 15:51:32 +01:00
Mohamed Awnallah
39d9252c96
docs: fix typo "paren" to "parenthesis" [skip ci] 2024-01-07 14:49:26 +02:00
ziggie
51c56d2825
lnwallet: add underflow check when computing balance. 2024-01-06 20:52:46 +01:00
ziggie
0b63989f3a
lnwallet+htlcswitch: Introduce a fee buffer.
We take into account a fee buffer of twice the current fee rate
of the commitment transaction plus an additional htlc output
when we are the opener of the channel hence pay when publishing the
commitment transaction. This buffer is not consensus critical
because we only consider it when we are in control of adding a
new htlc to the state. The goal is to prevent situations
where we push our local balance below our channel reserve due to
parallel adding of htlcs to the state. Its not a panacea for these
situations but until we have __option_simplified_update__ deployed
widely on the network its a good precaution to protect against
fee spikes and parallel adding of htlcs to the update log.

Moreover the way the available balance for a channel changed.
We now need to account for a fee buffer when we are the channel
opener. Therefore all the tests had to be adopted.
2024-01-06 20:52:46 +01:00
Olaoluwa Osuntokun
2f04ce7c6e
Merge pull request #8334 from lightningnetwork/tlv-record-enchancements
tlv: various enhancements to the new RecordT type
2024-01-05 13:57:55 -08:00
yyforyongyu
6de21b2a02
routerrpc: add verbose log and ignore context canceled error 2024-01-05 22:18:25 +08:00
yyforyongyu
58677569b5
routing+routerrpc: remove redudant error check
Since `SendPaymentAsync` now never returns an error, there's no need to
catch it and check it in `SendPaymentV2`.
2024-01-05 18:11:04 +08:00
Elle
695bfc8414
Merge pull request #7736 from ellemouton/towerInterfaces
watchtower+refactor: CommitmentType and JusticeKit interface
2024-01-04 16:04:11 +02:00
Elle Mouton
4daa0f309c
docs: add release note for 7736 2024-01-04 14:37:42 +02:00
Elle Mouton
154e9fafec
watchtower: convert JusticeKit to interface
In this commit, we convert the `JusticeKit` struct to an interface.
Then, we add two implementations of that interface:
1) The `legacyJusticeKit` which implements all the methods of
   `JusticeKit`
2) The `anchorJusticKit` which wraps the `legacyJusticeKit` and just
   re-implements the `ToRemoteOutputSpendInfo` method since.
2024-01-04 14:37:42 +02:00
Elle Mouton
048dc54110
watchtower/blob: move code to justice_kit_packet.go
In preparation for the next commit which will introduce the `JusticeKit`
interface, here we just move the code related to building the actual
justice kit packet into a separate file.
2024-01-04 14:37:42 +02:00
Elle Mouton
204ca6cb0f
watchtower: introduce CommitmentType
In this commit a new enum, CommitmentType, is introduced and initially
there are 3 CommitmentTypes: Legacy, LegacyTweakless and Anchor.

Then, various methods are added to `CommitmentType`. This allows us to
remove a bunch of "if-else" chains from the `wtclient` and `lookout`
code. This will also make things easier to extend when a new commitment
type (like Taproot) is added.
2024-01-04 14:37:42 +02:00
Oliver Gugger
708bd05df3
Merge pull request #8342 from guggero/js-doc-fix
docs: update Node.JS example
2024-01-04 10:57:39 +01:00
Oliver Gugger
0bf857d8e1
Merge pull request #8341 from threewebcode/patch-3
fix: remove duplicate words [skip ci]
2024-01-04 10:37:47 +01:00
Oliver Gugger
3a7e564582
docs: update Node.JS example
Fixes #8333 by not using the outdated `bytebuffer` library anymore.
2024-01-04 09:13:59 +01:00
Oliver Gugger
319a5dab5c
Merge pull request #8325 from Thabokani/master
chore: fix typos [skip ci]
2024-01-04 09:01:58 +01:00
Afanti
452b2d5a80
fix: remove duplicate words [skip ci]
There are some unnecessary duplicate words in the source file. Use this change to remove them. The CI can be skipped.
2024-01-04 04:47:03 +08:00
Olaoluwa Osuntokun
cedbdd8999
Merge pull request #8142 from carlaKC/8137-validateblindedpayload
routing: Add Validation for Decoding Blinded Paths
2024-01-03 12:33:11 -08:00
Olaoluwa Osuntokun
ffd330ac43
Merge pull request #8095 from carlaKC/7882-mcblinding
missioncontrol: add invalid onion blinding handling for blinded paths
2024-01-03 12:29:43 -08:00
Manisha
034bb5b51e Wrong documentation on lncli
Signed-off-by: Manisha <manisha2133@gmail.com>
2024-01-03 21:57:25 +05:30
Oliver Gugger
82e2b4010b
Merge pull request #8320 from threewebcode/patch-2
fix: correct the typo [skip ci]
2024-01-03 14:07:41 +01:00
Thabokani
b8d2fc3816
kvdb+cmd: fix typos 2024-01-03 12:06:32 +08:00
Olaoluwa Osuntokun
85046997c9
tlv: add utility funcs/methods to make tlv.OptionalRecord easier to use
We add a WhenSome that'll pass in the actual underlying value, and not
just the record.

We also add `SomeRecord` to make it easier to create TLV records w/
`Some` set.
2024-01-02 18:51:41 -08:00
Olaoluwa Osuntokun
aec2f9bf08
tlv: add TlvType method to RecordT
This will be useful when decoding optional TLV records, as we can use
this to look up in the `typeMap` for a given field to see if we decoded
it or not.
2024-01-02 18:51:35 -08:00
Olaoluwa Osuntokun
09afc92215
tlv: make TlvType method for TlvType interface public
With this change, callers can now examine a struct instance of the
`TlvType` instance to figure out programmatically which integer type is
maps to. This'll be useful when decoding optional TLV types into a wire
struct (knowing when to set it to Some vs None).
2024-01-02 18:51:33 -08:00
Olaoluwa Osuntokun
66cf4396a2
tlv: modify RecordT type to ensure type param takes precedence
In this commit, we modify the RecordT type to allow callers to re-use
the Record definition of a different type, but use the new type param to
override the integer type used on the wire.

This will let use do things like encode a signature using the same
RecordProducer instance, but with a diff type in another context.

The upcoming use for this is allowing our `lnwire.Sig` type to be
encoded in the same message using distinct TLV integer types (new co-op
close protocol).
2024-01-02 18:51:30 -08:00
Olaoluwa Osuntokun
7f8b185f40
Merge pull request #8307 from ziggie1984/channel-reestablishment-logging
lnwallet: fix logging.
2024-01-02 12:28:01 -08:00
Thabokani
55072bfd5e
sweep+lntest: fix typos 2024-01-02 19:23:30 +08:00
Yong
ab8fb2c9c3
Merge pull request #8308 from ziggie1984/new_min_cltv_default
zpay32: Change min_final_cltv_expiry_delta.
2024-01-02 17:19:52 +08:00
ziggie
160713eade
docs: add release-notes. 2023-12-29 22:35:12 +01:00
Afanti
fff785c909
fix: correct the typo 2023-12-29 21:27:13 +08:00
rockstardev
ba80ce46e4 Adding BtcPayServer related files and resources 2023-12-24 23:39:40 -06:00
ziggie
ec02ffa383
zpay32: Change min_final_cltv_expiry_delta.
We adhere to BOLT 02 and use 18 instead of 9.
2023-12-22 18:16:07 +01:00
ziggie
45a3bf333b
lnwallet: fix logging. 2023-12-22 17:36:41 +01:00
Oliver Gugger
4d8fa349ca
Merge pull request #8303 from AtomicInnovation321/master
docs: fix typos
2023-12-21 17:31:59 +01:00
bitcoin-lightning
b72fc9529e docs: fix typos 2023-12-21 15:21:35 +00:00
Oliver Gugger
30348baedc
Merge pull request #8296 from threewebcode/patch-1
fix: rectify the typos in the docs
2023-12-20 09:47:14 +01:00
Afanti
c0ef879b8c
fix: rectify the typos in the docs 2023-12-20 08:21:57 +08:00
Carla Kirk-Cohen
b31bab3529
docs: add release notes 2023-12-18 12:08:05 -05:00
Carla Kirk-Cohen
4071db77b5
routing: add handling for blinded errors from final node
We do not expect blinding errors from the final node:
1. If the introduction is the recipient, they should use regular errors.
2. Otherwise, nodes have no business sending this error when they are
   not part of a blinded route.
2023-12-18 12:07:56 -05:00
Carla Kirk-Cohen
7ce3a152a1
routing/refactor: add failNode helper to final outcome processing
Note: this refactor updates the inequality used from >= 2 to > 1 to
align with the rest of this file so that we express this concept
consistently throughout the code.
2023-12-18 12:07:47 -05:00
Carla Kirk-Cohen
b82478a7e7
routing: add result interpretation for intermediate invalid blinding
This commit adds handling for route blinding errors that are reported
by the introduction node in a multi-hop blinded route. As the
introduction node is always responsible for handling blinded errors,
it is not penalized - only the final hop is penalized to discourage the
blinded route without filling up mission control with ephemeral
results.

If this error code is reported by a node that is not an introduction
node, we penalize the node because it is returning an error code that
it should not be using.
2023-12-18 12:07:46 -05:00
Carla Kirk-Cohen
f91589bef9
routing: handle introduction node failure to convert error
This commit adds handling for errors that originate after the
introduction node when making payment to a blinded route. This
indicates that the introduction node is not obeying the spec, so
it is punished for the violation.
2023-12-18 12:07:36 -05:00
Carla Kirk-Cohen
31d4242b6d
docs: add release notes for 0.18 2023-12-18 11:27:57 -05:00
Carla Kirk-Cohen
af4fdcc1fd
htlcswitch/test: allow missing field errors in payload decode 2023-12-18 11:27:56 -05:00
Carla Kirk-Cohen
69d5496e7c
multi: update payload validation to account for blinded routes 2023-12-18 11:27:55 -05:00
Carla Kirk-Cohen
343a6ed831
hltcswitch/hop: add next hop to intermediate hop with custom records
Fix our existing test to have a valid intermediate hop that will pass
stricter validation. Previously, we did not specify a next channel for
an intermediate hop (which violates bolt4).
2023-12-18 11:27:53 -05:00
Carla Kirk-Cohen
7db072e020
routing: add additional validation to hop payload creation 2023-12-18 11:27:52 -05:00
Carla Kirk-Cohen
585f28c5f5
multi: explicitly signal final hop in pack hop payload
Previously, we'd use the value of nextChanID to infer whether a payload
was for the final hop in a route. This commit updates our packing logic
to explicitly signal to account for blinded routes, which allow zero
value nextChanID in intermediate hops. This is a preparatory commit
that allows us to more thoroughly validate payloads.
2023-12-18 11:27:52 -05:00
Carla Kirk-Cohen
b5afd905d1
htlcswitch/hop: explicitly signal final hop from sphinx packet
Previously, we were using nextChanID to determine whether a hop
payload is for the final recipient. This is no longer suitable in a
route-blinding world where intermediate hops are allowed to have zero
nextChanID TLVs (as this information is provided to forwarding nodes
in their encrypted data). This commit updates payload reading to use
the signal provided by sphinx that we are on the last packet, rather
than implying it from the contents of a hop.
2023-12-18 11:27:51 -05:00
Carla Kirk-Cohen
2f8587341a
htlcswitch/test: do not set amount and cltv for blinded test cases 2023-12-18 11:27:50 -05:00
Carla Kirk-Cohen
a75bc13230
routing/test: set outgoing timelock on non-legacy test cases
Provide valid hop payloads for tests cases that use TLV onion format.
2023-12-18 11:27:49 -05:00
Carla Kirk-Cohen
fa78d21975
htlcswitch/test: add sphinx action to decoding test
Update test to include the sphinx action to more closely represent
reality. This will be required when we add more validation to the
presence of a nextChanID field. A MoreHops action is chose because
we're testing the case with a payload that contains forwarding info.
2023-12-18 11:27:48 -05:00
Oliver Gugger
0df507eca0
Merge pull request #8261 from markettes/lncli-multiple-outgoing-channels
Enable multiple outgoing channel ids in payments
2023-12-18 11:38:46 +01:00
Marcos
ea9a780203
docs: release notes update for 0.18.0 2023-12-18 10:27:19 +01:00
Marcos
72a56f56b4
lncli: enable multiple outgoing channel ids in payments 2023-12-18 10:27:03 +01:00
Eugene Siegel
b47c1da07d
sweep: use p2tr output as change weight 2023-12-14 12:15:34 -05:00
Olaoluwa Osuntokun
ac9ca024a4
Merge pull request #8121 from Roasbeef/tlv-record-type-param
tlv: add new RecordT[T] utility type
2023-12-12 17:47:59 -08:00
Olaoluwa Osuntokun
63e86b72c5
tlv: add new RecordT[T, V] utility type
In this commit, we add a new type, `RecordT[T, V]` to reduce some of the
common boiler plate for TLV types. This type lets you take either a
primitive type, or an existing Record, and gain common methods used to
create tlv streams.

It also serves as extra type annotation as well, since wire structs can
use this to wrap any existing type and gain the relevant record methods.

This implementation ensures that the very definition of the field also
binds the TLV type value. It does this by using the generated code to
map a struct like TlvType1 to an actually Type like Type(1).
2023-12-12 17:47:10 -08:00
Olaoluwa Osuntokun
c304c2a8bb
tlv: run go generate for new set of TLV types
This shouldn't need to be run again, as this implementation restricts
things to just values 0-99, due to a hard upper limit with the way Go
unions work under the hood.
2023-12-12 17:47:04 -08:00
Olaoluwa Osuntokun
78d5806555
tlv/internal: add new internal package for generating TLV type structs
In this commit, we add some new code generation to the codebase. As
we'll see in a future commit, this'll allow us to create a new Record[T,
V] type, where T is actually a concrete _struct_ that implements a
special interface that deems it as a valid TLV type.
2023-12-12 17:47:01 -08:00
Oliver Gugger
f2d48c328b
Merge pull request #7800 from ziggie1984/neutrino-remove-sweeptx
neutrino remove sweeptx
2023-12-12 17:48:12 +01:00
Carla Kirk-Cohen
b0870ea2ed
htlcswitch/test: add encrypted data to blinded intermediate hop
Blinding points will always be accompanied by encrypted data, so
update the test to more accurately represent reality.
2023-12-12 10:01:26 -05:00
Carla Kirk-Cohen
1bb48178d7
routing/test: add channel id for final hop in clear route
Add the missing channel field to the final hop in our clear text
route test case. Note that this is the channel of the hop. With the
addition of stricter validation, we'll need this so that the
penultimate hop has a non-zero next channel ID.
2023-12-12 10:01:25 -05:00
Carla Kirk-Cohen
d017fe01e3
lnrpc: surface invalid onion blinding on rpc 2023-12-12 09:44:42 -05:00
Carla Kirk-Cohen
fd8381bf2a
lnwire: add invalid onion blinding error code 2023-12-12 09:44:05 -05:00
ziggie
043153fe09
docs: add release-notes 2023-12-12 14:18:17 +01:00
ziggie
58a5dcd502
docs: add formatting rule for function calls. 2023-12-12 14:18:17 +01:00
ziggie
7c09cc3326
lncli: add new removetx cmd.
This new command calls the new rpc endpoint RemoveTransaction.
2023-12-12 14:18:17 +01:00
ziggie
1ca3732f25
itest: add an itest for the removal of a tx. 2023-12-12 14:18:16 +01:00
ziggie
227ac770af
walletrpc: add new RemoveTransaction endpoint.
The RemoveTransaction endpoint removes the transaction with the
provided txid including all its descendants from the internal wallet.

We still keep watching for the address of the transation in case
the transcation is confirmed nonetheless. This command is particular
useful for neutrino backends because new bitcoind versions do not
reply with an invalid transaction error code when the tx published
fails to be included into the mempool (fullnodes do).
2023-12-12 14:18:16 +01:00
ziggie
2bc6b22a43
sweeper+lntest: remove conflicting tx
For anchor channels and neutrino backends we need to make sure
that sweeps of the same exclusive group are removed when one of
them is confirmed. Otherwise for neutrino backends those sweep
transaction are always rebroadcasted and are blocking funds in
the worst case scenario.
2023-12-12 13:11:48 +01:00
Olaoluwa Osuntokun
2fee3f6efa
Merge pull request #8030 from ellemouton/queryChanUpdateTimestamps
multi: query chan update timestamps
2023-12-11 11:18:08 -08:00
Oliver Gugger
0ec9ac7070
Merge pull request #7654 from ErikEk/listchaintxns-add-txhash
rpc: add gettx command to walletrpc
2023-12-11 10:08:42 +01:00
Elle Mouton
645eb44f66
docs: update release notes 2023-12-11 09:12:05 +02:00
Elle Mouton
a242ad5acb
channeldb+discovery: use timestamps to maybe revive zombie 2023-12-11 09:12:05 +02:00
Elle Mouton
ebe0755a97
channeldb: make MarkEdgeLive logic reusable
This commit is a set-up commit. It extracts the logic from
`MarkEdgeLive` to a helper `markEdgeLive` method so that the logic can
be called from within other kvdb.Update blocks. This will be used in the
next commit.
2023-12-11 09:12:05 +02:00
Elle Mouton
e12321cfd6
multi: extract and pass through IsZombieChannel method 2023-12-11 09:12:05 +02:00
Elle Mouton
67df687f08
discovery: start sending timestamps if requested 2023-12-11 09:12:05 +02:00
Elle Mouton
0ad4ef373a
channeldb+discovery: fetch timestamps from DB if required 2023-12-11 09:12:05 +02:00
Elle Mouton
50e17dab59
channeldb: reformat TestFilterChannelRange 2023-12-11 09:12:04 +02:00
Elle Mouton
a439cc970f
multi: start asking for update timestamps in QueryChannelRange
This commit also adds a new `protocol.no-timestamp-query-option` option
to disable the new behaviour.
2023-12-11 09:12:04 +02:00
Elle Mouton
893147d83e
channeldb: don't initialise edge index bkt as top level
The `edgeIndexBucket` key name is used to key a sub-bucket within the
`edgeBucket` bucket. And so the `edgeIndexBucket` is not a top level
bucket.
2023-12-11 09:12:04 +02:00
Elle Mouton
49a0370dcd
lnwire: add timestamps to ReplyChannelRange msg 2023-12-11 09:12:04 +02:00
Elle Mouton
4872010779
lnwire: sort scids before encoding
This is for later when the timestamps also need to be sorted according
to the SCIDs.
2023-12-11 09:12:04 +02:00
Elle Mouton
c882223ead
lnwire+discovery: rename ShortChannelIDEncoding to QueryEncoding
Since the the encoding can be used for multiple different fields, we
rename it here to be more generic.
2023-12-11 09:12:04 +02:00
Elle Mouton
341bae098c
lnwire: add QueryOptions to QueryChannelRange 2023-12-11 09:12:04 +02:00
Elle Mouton
8efd141347
lnwire: add QueryOptions type
This commit adds a new QueryOptions type which will later be used in the
QueryReplyRange message.
2023-12-11 09:12:03 +02:00
ErikEk
c8a7a3d546 doc: update release notes 2023-12-10 22:14:18 +01:00
erik
16f05105c1 itest: add gettransactiondetails 2023-12-10 22:14:18 +01:00
ErikEk
f0bc6d804c rpc: add gettransaction endpoint to walletrpc sub-server 2023-12-10 22:14:12 +01:00
Olaoluwa Osuntokun
c32edbd732
Merge pull request #8266 from Roasbeef/fn-v1
build: bump to fn/v1.0.0
2023-12-08 14:28:40 -08:00
Olaoluwa Osuntokun
d50dd8e2d7
build: bump to fn/v1.0.0 2023-12-08 14:08:17 -08:00
Olaoluwa Osuntokun
445bd27e59
Merge pull request #8259 from Roasbeef/fn-module
fn: create new sub-module
2023-12-08 13:52:26 -08:00
Olaoluwa Osuntokun
b0114efad3
fn: create new sub-module
In this commit, we make a new sub-module from the `fn` package. This
lets other projects use it w/o pulling in all of lnd, and also other
sub-packages within lnd.

We also add a temp replace directive for new module.  We'll remove this
once we tag the final version.
2023-12-06 17:00:10 -08:00
Olaoluwa Osuntokun
13aa7f9924
build: bump version to v0.17.3-beta 2023-12-05 16:37:53 -08:00
Elle
4fa483f1bc
Merge pull request #7702 from ellemouton/towerClientMux
wtclient: Tower Client Multiplexer
2023-12-05 12:27:05 +02:00
Oliver Gugger
ad88396a34
Merge pull request #8097 from markettes/fix-amount-field
Fix amount field
2023-12-04 12:19:07 +01:00
Marcos
7445782db6
lncli: show balance for sweepall 2023-12-04 10:46:54 +01:00
Marcos
80a85d36eb
docs: release notes update for 0.18.0 2023-12-02 02:08:26 +01:00
Olaoluwa Osuntokun
d5b05d6930
Merge pull request #8241 from Roasbeef/v0-17-3-branch
release: create v0.17.3-beta.rc1 release branch
2023-12-01 14:17:21 -08:00
Marcos
90b5037d73
lnrpc: add MinConfs to WalletBalanceRequest 2023-12-01 18:22:35 +01:00
Olaoluwa Osuntokun
937fe6fda6
build: bump version to v0.17.3-beta.rc1 2023-11-30 15:08:20 -08:00
Olaoluwa Osuntokun
f550d04c7d Merge branch 'v0-17-3-branch-8232' into v0-17-3-branch 2023-11-30 15:06:14 -08:00
yyforyongyu
01eb7e539a gomod: update btcwallet version 2023-11-30 15:06:14 -08:00
Olaoluwa Osuntokun
b4425f6eea Merge branch 'v0-17-3-branch-8151' into v0-17-3-branch 2023-11-30 15:05:52 -08:00
Eugene Siegel
41e251b0d7 release-notes: update for 0.17.3 2023-11-30 15:05:52 -08:00
Eugene Siegel
dd2ead1022 routing: launch fetchFundingTx in goroutine so router can exit
This commit introduces a wrapper function fetchFundingTxWrapper
which calls fetchFundingTx in a goroutine. This is to avoid an issue
with pruned nodes where the router is attempting to stop, but the
prunedBlockDispatcher is waiting to connect to peers that can serve
the block. This can cause the shutdown process to hang until we
connect to a peer that can send us the block.
2023-11-30 15:05:52 -08:00
Olaoluwa Osuntokun
5565dffbd1 Merge branch 'v0-17-3-branch-8220' into v0-17-3-branch 2023-11-30 15:01:15 -08:00
yyforyongyu
87b4749d60 docs: add release notes for v0.17.3 2023-11-30 15:01:15 -08:00
yyforyongyu
bb27135477 lnwallet: make sure loop var is properly referenced 2023-11-30 15:01:15 -08:00
yyforyongyu
c6d52147e8 lnwallet: add unit test for extractPayDescs 2023-11-30 15:01:15 -08:00
yyforyongyu
8ac3480942 multi: enhance logging around channel reestablishment 2023-11-30 15:01:15 -08:00
Olaoluwa Osuntokun
97975098b9 Merge branch 'v0-17-3-branch-8224' into v0-17-3-branch 2023-11-30 14:58:52 -08:00
yyforyongyu
c6836d777e docs: add release notes for v0.17.3 2023-11-30 14:58:52 -08:00
yyforyongyu
dd8be9fc87 lntest: add verbose logging when node fails to shutdown 2023-11-30 14:58:52 -08:00
yyforyongyu
23e177514f input: use lnutils.SyncMap to store musig2 sessions 2023-11-30 14:58:52 -08:00
Olaoluwa Osuntokun
f87e370efd
Merge pull request #8232 from yyforyongyu/optimize-mempool
gomod: update `btcwallet` version
2023-11-30 14:47:14 -08:00
Eugene
a397642f73
Merge pull request #8151 from Crypt-iQ/issue_7928
routing: launch fetchFundingTx in goroutine so router can exit
2023-11-30 12:19:01 -05:00
Eugene Siegel
8fa774681b
release-notes: update for 0.17.3 2023-11-30 10:45:11 -05:00
Eugene Siegel
faf76fbf0e
routing: launch fetchFundingTx in goroutine so router can exit
This commit introduces a wrapper function fetchFundingTxWrapper
which calls fetchFundingTx in a goroutine. This is to avoid an issue
with pruned nodes where the router is attempting to stop, but the
prunedBlockDispatcher is waiting to connect to peers that can serve
the block. This can cause the shutdown process to hang until we
connect to a peer that can send us the block.
2023-11-30 10:45:02 -05:00
Yong
9f42459036
Merge pull request #8177 from yyforyongyu/payment-status
routerrpc: optionally return the new payment status
2023-11-30 17:15:23 +08:00
yyforyongyu
827d728cd5
gomod: update btcwallet version 2023-11-30 17:12:32 +08:00
Oliver Gugger
27319315bb
Merge pull request #8220 from yyforyongyu/enhance-logging-switch
multi: fix loopvar and enhance logging around channel reestablishment
2023-11-28 17:48:02 +01:00
Elle Mouton
59ebe02fa4
docs: update release notes 2023-11-28 11:01:52 +02:00
Elle Mouton
e800aacff4
wtclient+server: unexport and rename TowerClient
Rename and unexport the `TowerClient` struct to `client` and rename the
`TowerClientManager` interface to `ClientManager`.
2023-11-28 11:01:51 +02:00
Elle Mouton
fcfdf699e3
multi: move BackupState and RegisterChannel to Manager
This commit moves over the last two methods, `RegisterChannel` and
`BackupState` from the `Client` to the `Manager` interface. With this
change, we no longer need to pass around the individual clients around
and now only need to pass the manager around.

To do this change, all the goroutines that handle channel closes,
closable sessions needed to be moved to the Manager and so a large part
of this commit is just moving this code from the TowerClient to the
Manager.
2023-11-28 10:59:40 +02:00
Elle Mouton
ab2f781b4a
wtclient+lnrpc: move Policy to Manager 2023-11-28 09:54:03 +02:00
Elle Mouton
4e51bf3a3f
wtclient+lnrpc: move LookupTower to Manager 2023-11-28 09:54:02 +02:00
Elle Mouton
0b3d751e33
wtclient+lnrpc: move RegisteredTowers to Manager
Move the `RegisteredTowers` method from the `Client` to the `Manager`
interface.
2023-11-28 09:54:02 +02:00
Elle Mouton
4348f2062a
wtclient+lnrpc: move Stats to Manager
Move the `Stats` method from the `Client` to the `Manager` interface.
2023-11-28 09:54:02 +02:00
Elle Mouton
f38b5cf258
lnrpc+wtclient: refactor ClientStats
This commit removes the mutex from ClientStats and instead puts that in
clientStats which wraps ClientStats with a mutex. This is so that the
tower client interface can return a ClientStats struct without worrying
about copying a mutex.
2023-11-28 09:54:02 +02:00
Elle Mouton
a5e7d35af2
wtclient+lnrpc: move RemoveTower to Manager
Simiarly to the previous commit, this commit moves the RemoveTower
method from the Client to the TowerClientManager interface. The manager
handles any DB related handling. The manager will first attempt to
remove the tower from the in-memory state of each client and then will
attempt to remove the tower from the DB. If the removal from the DB
fails, the manager will re-add the tower to the in-memory state of each
client.
2023-11-28 09:54:02 +02:00
Elle Mouton
a44bf381c4
multi: move AddTower to Tower Client Manager
In this commit we move the AddTower method from the Client interface to
the TowerClientManager interface. The wtclientrpc is updated to call the
`AddTower` method of the Manager instead of calling the `AddTower`
method of each individual client. The TowerClient now is also only
concerned with adding a new tower (or new tower address) to its
in-memory state; the tower Manager will handle adding the tower to the
DB.
2023-11-28 09:54:02 +02:00
Elle Mouton
2abc422aac
watchtower+server: let manager Start & Stop the clients
In this commit, the `Stop` and `Start` methods are removed from the
`Client` interface and instead added to the new `Manager`. Callers now
only need to call the Manager to start or stop the clients instead of
needing to call stop/start on each individual client.
2023-11-28 09:54:01 +02:00
Elle Mouton
ab0375e0c1
wtclient+server: introduce tower client Manager
Introduce a wtclient `Manager` which handles tower clients. It indexes
clients by the policy used. The policy field is thus removed from the
`Config` struct which configures the Manager and is instead added to a
new `towerClientCfg` which configures a specific client managed by the
manager. For now, only the `NewClient` method is added to the Manager.
It can be used to construct a new `TowerClient`. The Manager currently
does notthing with the clients added to it.
2023-11-28 09:51:15 +02:00
Yong
80684eccbd
Merge pull request #8222 from ellemouton/wtclientStartupPerf
wtclient+migration: start storing chan max height in channel details bucket
2023-11-28 15:38:27 +08:00
yyforyongyu
4845b7ade3
docs: add release notes for v0.17.3 2023-11-28 14:07:15 +08:00
yyforyongyu
1ee665d14c
lnwallet: make sure loop var is properly referenced 2023-11-28 14:06:53 +08:00
yyforyongyu
81841b7dab
lnwallet: add unit test for extractPayDescs 2023-11-28 14:06:53 +08:00
yyforyongyu
85f4b13632
multi: enhance logging around channel reestablishment 2023-11-28 14:06:53 +08:00
Oliver Gugger
9ce543fb05
Merge pull request #8209 from vuittont60/master
docs: fix typos [skip ci]
2023-11-27 23:54:17 +01:00
Oliver Gugger
db0b612734
Merge pull request #8224 from yyforyongyu/fix-musig2-session
input: fix `fatal error: concurrent map writes`
2023-11-27 23:40:53 +01:00
yyforyongyu
3934844cc6
docs: add release notes for v0.17.3 2023-11-28 03:19:37 +08:00
Elle Mouton
3642cb6d40
docs: update release notes 2023-11-27 20:01:17 +02:00
Elle Mouton
4131ced707
wtdb/migration8: migrate channel max heights 2023-11-27 20:01:17 +02:00
Elle Mouton
fee94ae5af
watchtower: start using the new channel max heights
This commit also adds tests for the DB changes made in the previous
commit since we can now read the new field with the FetchChanInfos
method.

The commit following this one does the backfill migration.
2023-11-27 20:01:17 +02:00
Elle Mouton
01ba2661db
watchtower/wtdb: start populating channel max commitment
In this commit, a new key, cChanMaxCommitmentHeight, is added to the
channel details bucket. This key will hold the highest commitment number
that the tower has been handed for this channel. In this commit, we
start writing to it in the two places where a backup is first persisted
in the tower client db: 1) CommitUpdate and 2) in the Queue's `addItem`
method. The logic for both 1 & 2 is tested in the next commit which adds
a DB helper that allows us to read the new field.

A follow up commit will do a migration to back-fill the new field.
2023-11-27 20:01:17 +02:00
yyforyongyu
9cc57fa371
lntest: add verbose logging when node fails to shutdown 2023-11-25 07:25:18 +08:00
yyforyongyu
ae09ab2a21
input: use lnutils.SyncMap to store musig2 sessions 2023-11-25 07:25:18 +08:00
Yong
f005b248ce
Merge pull request #8181 from ProofOfKeags/docs/comprehensive-lncli
docs/comprehensive lncli
2023-11-22 06:58:48 +08:00
Keagan McClelland
9fd18a7fd2 docs: update release notes 2023-11-20 14:51:59 -07:00
Keagan McClelland
a2cb3da145 meta: update PR template to remind contributors about lncli docs 2023-11-20 14:48:26 -07:00
Keagan McClelland
545b8913c7 lnrpc: fix watchtowerrpc doc tags to enable lncli api doc generation 2023-11-20 14:45:37 -07:00
Keagan McClelland
dae80f5db7 lnrpc: add top level command doc tags to enable lncli api doc generation 2023-11-20 14:44:30 -07:00
Keagan McClelland
ba4438b923 lnrpc: add devrpc doc tags to enable lncli api doc generation 2023-11-20 14:44:25 -07:00
Keagan McClelland
4eca04e6a0 lnrpc: add wtclientrpc doc tags to enable lncli api doc generation 2023-11-20 14:43:59 -07:00
Keagan McClelland
179295e441 lnrpc: add routerrpc doc tags to enable lncli api doc generation 2023-11-20 14:43:24 -07:00
Keagan McClelland
305e27d7a1 lnrpc: add neutrinorpc doc tags to enable lncli api doc generation 2023-11-20 14:42:17 -07:00
Keagan McClelland
bba09e320c lnrpc: add invoicesrpc doc tags to enable lncli api doc generation 2023-11-20 14:41:54 -07:00
Keagan McClelland
b855566e6b lnrpc: add autopilotrpc doc tags to enable lncli api doc generation 2023-11-20 14:41:14 -07:00
Keagan McClelland
c0da9ca1b0 lnrpc: add walletrpc doc tags to enable lncli api doc generation 2023-11-20 14:40:37 -07:00
rockstardev
b8c6baa94a Adding BtcPayServer related files and resources 2023-11-20 14:43:29 -06:00
Olaoluwa Osuntokun
6744c64e62
build: bump version to v0.17.2-beta 2023-11-20 14:31:32 -06:00
vuittont60
e3e2515b83
docs: fix typos [skip ci] 2023-11-20 15:35:56 +08:00
Olaoluwa Osuntokun
ceb8e8a109
Merge pull request #8187 from Roasbeef/v0-17-2-branch
release: create v0.17.2-beta release branch
2023-11-17 16:10:27 -08:00
Olaoluwa Osuntokun
0aaf144b76
build: bump version to v0.17.2-beta.rc2 2023-11-17 18:09:34 -06:00
Olaoluwa Osuntokun
01761ab99b
docs/release-notes: update release notes for v0.17.2 2023-11-17 18:09:17 -06:00
Olaoluwa Osuntokun
04e0c9bc39 Merge branch 'v0-17-2-branch-8198' into v0-17-2-branch 2023-11-17 18:05:43 -06:00
Matt Morehouse
a331308a02 peer: add test for startup race on writeMessage
The test reliably detects
https://github.com/lightningnetwork/lnd/issues/8184.
2023-11-17 18:05:43 -06:00
Matt Morehouse
a283fc62fa peer: enable mockMessageConn to detect data races
We use unsynchronized counters to trigger a report under the race
detector if multiple reads or writes happen concurrently.
2023-11-17 18:05:43 -06:00
Matt Morehouse
0f5e4077ba peer: add missing Close() method to mockMessageConn 2023-11-17 18:05:43 -06:00
Olaoluwa Osuntokun
d9b88fba67
Merge pull request #8198 from morehouse/brontide_startup_race_test
peer: test for startup writeHander data race
2023-11-17 16:01:16 -08:00
Yong
e8bdf01fef
Merge pull request #8201 from yyforyongyu/flake-fix
itest: fix flake in `multi_hop_htlc_remote_chain_claim`
2023-11-18 00:44:02 +08:00
Yong
3ee33ba561
Merge pull request #8173 from morehouse/simplify_tlv
tlv: simplify encoding functions
2023-11-17 20:37:15 +08:00
yyforyongyu
ded9fe6a84
itest: fix flake in multi_hop_htlc_remote_chain_claim 2023-11-17 17:29:53 +08:00
Matt Morehouse
f0ae5b2456
peer: add test for startup race on writeMessage
The test reliably detects
https://github.com/lightningnetwork/lnd/issues/8184.
2023-11-16 17:33:44 -06:00
Matt Morehouse
08fff28504
peer: enable mockMessageConn to detect data races
We use unsynchronized counters to trigger a report under the race
detector if multiple reads or writes happen concurrently.
2023-11-16 17:32:19 -06:00
Matt Morehouse
c4e0daa274
peer: add missing Close() method to mockMessageConn 2023-11-16 17:31:18 -06:00
Olaoluwa Osuntokun
2988c85479
docs/release-notes: add release notes for v0.17.2 2023-11-16 13:08:15 -08:00
Eugene Siegel
a41833c466 peer: send reestablish, shutdown messages before starting writeHandler
This is to avoid a potential race on WriteMessage and Flush internals.
Because there is no locking on WriteMessage and Flush, if we allow
writeMessage calls in Start after the writeHandler has started,
the writeMessage calls may call WriteMessage/Flush at the same time
that writeMessage calls from the writeHandler does. Since there is
no locking, internals like b.nextHeaderSend can race and cause
panics.
2023-11-16 13:05:16 -08:00
Olaoluwa Osuntokun
64753b01d1
Merge pull request #8186 from Crypt-iQ/issue_8184_2
peer: send reestablish, shutdown messages before starting writeHandler
2023-11-16 12:58:12 -08:00
Eugene Siegel
7556402ea4
peer: send reestablish, shutdown messages before starting writeHandler
This is to avoid a potential race on WriteMessage and Flush internals.
Because there is no locking on WriteMessage and Flush, if we allow
writeMessage calls in Start after the writeHandler has started,
the writeMessage calls may call WriteMessage/Flush at the same time
that writeMessage calls from the writeHandler does. Since there is
no locking, internals like b.nextHeaderSend can race and cause
panics.
2023-11-16 12:07:10 -05:00
Elle
ed179e3e7d
Merge pull request #8180 from carlaKC/8128-brontideflake
peer/test: fix race in TestHandleNewPendingChannel
2023-11-16 10:10:24 +02:00
yyforyongyu
99354313d5
routerrpc+itest: make sure TrackPayments is compatible
This commit adds an itest case to make sure when the flag
`routerrpc.usestatusinitiated` is not set, the new status is not sent.
2023-11-15 20:18:21 +08:00
yyforyongyu
9acbbf0ec7
routing: make sure StatusInitiated is notified when creating payments
This commit fixes `InitPayment` method to make sure the subscribers get
notified when new payments are created.
2023-11-15 20:18:21 +08:00
yyforyongyu
9e00799188
docs: update release notes 2023-11-15 20:18:21 +08:00
yyforyongyu
816a70e08c
multi: add new config usestatusinitiated for the new payment status
This commit adds a new config value to signal that the user understands
the new payment status `StatusInitiated`.
2023-11-15 20:18:17 +08:00
rockstardev
c8bd66e881 Adding BtcPayServer related files and resources 2023-11-14 20:45:27 -06:00
Keagan McClelland
0759b2657c meta: add build tags to workspace settings for lsp support 2023-11-14 17:10:31 -08:00
Carla Kirk-Cohen
a8a86b290c
peer/test: setup clean peer for each TestHandleNewPendingChannel case
Running test cases in parallel with shared state means that they
can intermingle if they're run at the same time and set up incorrect
values when we assert on the number of channels we have. Moving the
peer setup into the parallel test run fixes this because no single
test case can interfere with the other.
2023-11-14 15:45:19 -05:00
yyforyongyu
c58454effe
routerrpc: modify field orders based on their assigned number
This commit is a pure refactoring which sorts the fields in
`SendPaymentRequest` so it's easier to see what number to use when
adding a new field.
2023-11-14 20:26:13 +08:00
yyforyongyu
922130c80e
routerrpc: skip initiated payment in trackPaymentStream 2023-11-14 17:46:20 +08:00
Elle
5e369a02bb
Merge pull request #8171 from ellemouton/zombieChansUseCorrectChanID
channeldb+discovery: pass correct SCID to `MarkEdgeLive`
2023-11-14 11:05:57 +02:00
Olaoluwa Osuntokun
744feb04e2
build: bump version to v0.17.1-beta 2023-11-13 11:13:18 -08:00
Elle Mouton
ac58100558
docs: update release notes 2023-11-13 20:58:27 +02:00
Elle Mouton
7ff4a8b157
discovery: use correct channel ID for MarkEdgeLive
In processZombieUpdate, the SCID passed to MarkEdgeLive should _not_ be
derived from the ChannelEdgeInfo ChannelID field since this field will
not be populated when GetChannelByID returns a ChannelEdgeInfo along
with an ErrZombieEdge error. So this commit ensures that a usable
SCID is provided to processZombieUpdate.
2023-11-13 20:58:06 +02:00
Elle Mouton
0193274c10
multi: return error from MarkEdgeLive if not found
Let MarkEdgLive return a new ErrNotZombieEdge error if an entry with the
given channel ID cannot be found. In processZombieUpdate, we then
check for this error and log accordingly.
2023-11-13 20:58:06 +02:00
Elle Mouton
034283db10
channeldb: update TestGraphZombieIndex to use require 2023-11-13 20:58:05 +02:00
Olaoluwa Osuntokun
e02fd39ce6
Merge pull request #8170 from yyforyongyu/0-18-staging-missed
Add missing commits from `0-18-staging`
2023-11-13 10:38:23 -08:00
Matt Morehouse
e796922a82
tlv: simplify encoding functions
The typeless functions can directly call the typed functions after the
type check.
2023-11-13 11:30:17 -06:00
yyforyongyu
5168af55a9
itest: fix flake in max_htlc_pathfind
```
lnd_max_htlcs_test.go:149:
        	Error Trace:	/home/runner/work/lnd/lnd/itest/lnd_max_htlcs_test.go:149
        	            				/home/runner/work/lnd/lnd/itest/lnd_max_htlcs_test.go:40
        	            				/home/runner/work/lnd/lnd/lntest/harness.go:286
        	            				/home/runner/work/lnd/lnd/itest/lnd_test.go:136
        	Error:      	Not equal:
        	            	expected: 3
        	            	actual  : 0
        	Test:       	TestLightningNetworkDaemon/tranche01/60-of-134/btcd/max_htlc_pathfind
        	Messages:   	expected accepted
```
2023-11-13 16:11:07 +08:00
yyforyongyu
678f416008
routing+docs: make sure non-MPP cannot use skipTempErr 2023-11-13 16:11:06 +08:00
yyforyongyu
168cfd7cd5
docs: emphasize the new payment status StatusInitiated 2023-11-13 16:10:51 +08:00
yyforyongyu
98378d9408
routing: unify all dummy errors to be errDummy 2023-11-13 16:10:28 +08:00
yyforyongyu
7ccb77269d
routing: log preimage when it's failed to be saved to db 2023-11-13 16:10:28 +08:00
yyforyongyu
8f5c6e8367
trivial: fix typos 2023-11-13 16:10:28 +08:00
yyforyongyu
e3dadd528b
routing: mark payment as failed when no route can be found 2023-11-13 16:10:28 +08:00
yyforyongyu
27ee917a20
docs: update release note for payment lifecycle 2023-11-13 16:10:26 +08:00
yyforyongyu
6e93764bc1
routing: make sure payment hash is random in unit tests
This commit makes sure a testing payment is created via
`createDummyLightningPayment` to ensure the payment hash is unique to
avoid collision of the same payment hash being used in uint tests. Since
the tests are running in parallel and accessing db, if two difference
tests are using the same payment hash, no clean test state can be
guaranteed.
2023-11-13 16:09:12 +08:00
yyforyongyu
10052ff4f5
routing: patch unit tests for payment lifecycle
This commit adds unit tests for `resumePayment`. In addition, the
`resumePayment` has been split into two parts so it's easier to be
tested, 1) sending the htlc, and 2) collecting results. As seen in the
new tests, this split largely reduces the complexity involved and makes
the unit test flow sequential.

This commit also makes full use of `mock.Mock` in the unit tests to
provide a more clear testing flow.
2023-11-13 16:09:12 +08:00
yyforyongyu
e46c689bf1
routing: refactor attempt makers to return pointers
Thus adding following unit tests can be a bit easier.
2023-11-13 16:09:12 +08:00
yyforyongyu
ddad6ad4c4
routing: update mockers in unit test
This commit adds more mockers to be used in coming unit tests and
simplified the mockers to be more straightforward.
2023-11-13 16:09:12 +08:00
yyforyongyu
01e3bd87ab
routing: delete old payment lifecycle related unit tests
The old payment lifecycle is removed due to it's not "unit" -
maintaining these tests probably takes as much work as the actual
methods being tested, if not more so. Moreover, the usage of the old
mockers in current payment lifecycle test is removed as it re-implements
other interfaces and sometimes implements it uniquely just for the
tests. This is bad as, not only we need to work on the actual interface
implementations and test them , but also re-implement them again in the
test without testing them!
2023-11-13 16:09:11 +08:00
yyforyongyu
09a5d235ec
routing: fail attempt when no shard is found or circuit generation fails 2023-11-13 16:09:11 +08:00
yyforyongyu
eda24ec871
routing: catch lifecycle quit signal in collectResult 2023-11-13 16:09:11 +08:00
yyforyongyu
da8f1c084a
channeldb+routing: add new interface method TerminalInfo
This commit adds a new interface method `TerminalInfo` and changes its
implementation to return an `*HTLCAttempt` so it includes the route for
a successful payment. Method `GetFailureReason` is now removed as its
returned value can be found in the above method.
2023-11-13 16:09:11 +08:00
yyforyongyu
3c5c37b693
routing: introduce stateStep to manage payment lifecycle
This commit adds a new struct, `stateStep`, to decide the workflow
inside `resumePayment`.

It also refactors `collectResultAsync` introducing a new channel
`resultCollected`. This channel is used to signal the payment
lifecycle that an HTLC attempt result is ready to be processed.
2023-11-13 16:09:11 +08:00
yyforyongyu
e8c0226e1c
routing: add AllowMoreAttempts to decide whether more attempts are allowed 2023-11-13 16:09:11 +08:00
bitromortac
9a0db291b5
routing: fix tests after main refactor
Delete TestSendMPPaymentFailedWithShardsInFlight as it seems to be the
same test as TestSendMPPaymentFailed.
2023-11-13 16:09:11 +08:00
yyforyongyu
173900c8dc
routing: only fail attempt inside handleSwitchErr
This commit makes sure we only fail attempt inside `handleSwitchErr` to
ensure the orders in failing payment and attempts. It refactors
`collectResult` to return `attemptResult`, and expands `handleSwitchErr`
to also handle the case where the attemptID is not found.
2023-11-13 16:09:10 +08:00
yyforyongyu
703ea08316
routing: add methods checkTimeout and requestRoute
This commit refactors the `resumePayment` method by adding the methods
`checkTimeout` and `requestRoute` so it's easier to understand the flow
and reason about the error handling.
2023-11-13 16:09:10 +08:00
yyforyongyu
7209c65ccf
routing: split launchShard into registerAttempt and sendAttempt
This commit removes the method `launchShard` and splits its original
functionality into two steps - first create the attempt, second send the
attempt. This enables us to have finer control over "which error is
returned from which system and how to handle it".
2023-11-13 16:09:10 +08:00
yyforyongyu
49bafc0207
routing: handle switch error when sendAttempt fails
This commit starts handling switch error inside `sendAttempt` when an
error is returned from sending the HTLC. To make sure the updated
`HTLCAttempt` is always returned to the callsite, `handleSwitchErr` now
also returns a `attemptResult`.
2023-11-13 16:09:10 +08:00
yyforyongyu
568b977a1f
routing: add new method registerAttempt
This commit adds a new method `registerAttempt` to take care of creating
and saving an htlc attempt to disk.
2023-11-13 16:09:10 +08:00
yyforyongyu
071d05e0e3
routing: unify shardResult and launchOutcome to be attemptResult
This commit removes the `launchOutcome` and `shardResult` and uses
`attemptResult` instead. This struct is also used in `failAttempt` so we
can future distinguish critical vs non-critical errors when handling
HTLC attempts.
2023-11-13 16:09:10 +08:00
yyforyongyu
4bb8db46df
routing: fail payment before attempt inside handleSwitchErr
`handleSwitchErr` is now responsible for failing the given HTLC attempt
after deciding to fail the payment or not. This is crucial as
previously, we might enter into a state where the payment's HTLC has
already been marked as failed, and while we are marking the payment as
failed, another HTLC attempt can be made at the same time, leading to
potential stuck payments.
2023-11-13 16:09:09 +08:00
yyforyongyu
8458966f02
routing: remove the abstraction shardHandler
This commit removes the unclear abstraction `shardHandler` that's used
in our payment lifecycle. As we'll see in the following commits,
`shardHandler` is an unnecessary layer and everything can be cleanly
managed inside `paymentLifecycle`.
2023-11-13 16:09:09 +08:00
Olaoluwa Osuntokun
9937b1d6de Merge branch 'dyncomms' 2023-11-10 13:30:28 -08:00
Keagan McClelland
9793fbb94b lnwire: add musig2 taproot execution messages for dynamic commitments 2023-11-10 13:29:52 -08:00
Keagan McClelland
9b1c04c210 docs: update release notes 2023-11-10 13:29:51 -08:00
Keagan McClelland
564bf852bb lnwire: add fuzz tests for new dynamic commitment message types 2023-11-10 13:29:30 -08:00
Keagan McClelland
3e84d22eeb lnwire: add TLV extension to channel_reestablish for dynamic commitments 2023-11-10 13:29:30 -08:00
Keagan McClelland
e5f7ed8ba1 lnwire: introduce message types for dynamic commitment negotiation
lnwire: add tests for dynamic commitment wire serialization
2023-11-10 13:29:30 -08:00
Keagan McClelland
b298c84d21 fn: introduce option type
this commit introduces many of the most common functions you will
want to use with the Option type. Not all of them are used
immediately in this PR.
2023-11-10 13:29:30 -08:00
Elle
a3f8011ed6
Merge pull request #8156 from hieblmi/improve-fc-logging
contractcourt: log amount if incoming htlc times out
2023-11-09 17:32:18 +02:00
Elle
6122452509
Merge pull request #8117 from ellemouton/removeDBFromChannelDBSchemas
channeldb+refactor: remove `kvdb.Backend` from channel DB schemas
2023-11-09 07:47:11 +02:00
Olaoluwa Osuntokun
eea15f0952
Merge pull request #8162 from Roasbeef/v0-17-1-branch-rc3
build: create v0.17.1 rc3 release branch
2023-11-08 17:10:55 -08:00
Olaoluwa Osuntokun
18a5dda6a9
build: bump version to v0.17.1-beta.rc3 2023-11-08 15:00:20 -08:00
Olaoluwa Osuntokun
31791aadc8 Merge branch 'v0-17-1-branch-rc3-8158' into v0-17-1-branch-rc3 2023-11-08 14:58:41 -08:00
Eugene Siegel
8e8923c251 release-notes: update for 0.17.1 2023-11-08 14:58:41 -08:00
Eugene Siegel
f7e2db9687 peer: send messages in Start via writeMessage to bypass writeHandler
Without this the following could happen:

* InboundPeerConnected is called while we already have an inbound
connection with the peer. This calls removePeer which calls Disconnect.
* If the peer is starting up in Start, it may be sending messages
synchronously via SendMessage(true, ...). This eventually calls the
writeMessage function which will exit if disconnect is set to 1.
* Since Disconnect was called, disconnect will be 1 and writeMessage
will exit, causing writeHandler to exit.
* If there is more than 1 message being sent, later messages will
queue in queueHandler but be unable to get into sendQueue as the
writeHandler goroutine has exited.
* The synchronous sends will be waiting on the errChan indefinitely
and startReady will never get closed meaning Disconnect will never
proceed.

The end result is that the server's mutex will be held until shutdown.

Avoid this by using writeMessage to bypass the writeHandler goroutine.
2023-11-08 14:58:41 -08:00
Olaoluwa Osuntokun
6de3fea8e6
Merge pull request #8158 from Crypt-iQ/writeMessage_fix
peer: send messages in Start via writeMessage to bypass writeHandler
2023-11-08 14:54:54 -08:00
Eugene Siegel
38fb12fb4f
release-notes: update for 0.17.1 2023-11-08 16:36:04 -05:00
Eugene Siegel
955a345153
peer: send messages in Start via writeMessage to bypass writeHandler
Without this the following could happen:

* InboundPeerConnected is called while we already have an inbound
connection with the peer. This calls removePeer which calls Disconnect.
* If the peer is starting up in Start, it may be sending messages
synchronously via SendMessage(true, ...). This eventually calls the
writeMessage function which will exit if disconnect is set to 1.
* Since Disconnect was called, disconnect will be 1 and writeMessage
will exit, causing writeHandler to exit.
* If there is more than 1 message being sent, later messages will
queue in queueHandler but be unable to get into sendQueue as the
writeHandler goroutine has exited.
* The synchronous sends will be waiting on the errChan indefinitely
and startReady will never get closed meaning Disconnect will never
proceed.

The end result is that the server's mutex will be held until shutdown.

Avoid this by using writeMessage to bypass the writeHandler goroutine.
2023-11-08 16:36:02 -05:00
Elle Mouton
0e82293e45
multi: address linter issues 2023-11-08 14:50:35 +02:00
Elle Mouton
84cdcd6847
multi: move DB schemas to channeldb/models
This commit moves the ChannelEdgePolicy, ChannelEdgeInfo,
ChanelAuthProof and CachedEdgePolicy structs to the `channeldb/models`
package.
2023-11-08 14:50:35 +02:00
Elle Mouton
be23986eda
docs: update release notes 2023-11-08 14:50:35 +02:00
Elle Mouton
78ff28fea1
channeldb: remove unused func arguments 2023-11-08 14:50:35 +02:00
Elle Mouton
3a17479ff4
multi: remove LightningNode from ChannelEdgePolicy
Finally, The LightningNode object is removed from ChannelEdgePolicy.
This is a step towards letting ChannelEdgePolicy reflect exactly the
schema that is on disk.

This is also nice because the `Node` object is not necessarily always
required when the ChannelEdgePolicy is loaded from the DB, so now it
only get's loaded when needed.
2023-11-08 14:50:34 +02:00
Elle Mouton
6c76d31e89
multi: let FetchLightningNode take an optional tx
In preparation for the next commit which will remove the
`*LightningNode` from the `ChannelEdgePolicy` struct,
`FetchLightningNode` is modified to take in an optional transaction so
that it can be utilised in places where a transaction exists.
2023-11-08 14:50:34 +02:00
Elle Mouton
9a62a46aa3
channeldb: remove kvdb.Backend from ChannelEdgePolicy 2023-11-08 14:50:34 +02:00
Elle Mouton
f06f08f596
channeldb: remove kvdb.Backend from ChannelEdgeInfo 2023-11-08 14:50:34 +02:00
Elle Mouton
9dc1a1dfec
channeldb: convert FetchOtherNode to ChannelGraph method
To prepare for the `kvdb.Backend` member of `ChannelEdgeInfo` being
removed, the `FetchOtherNode` method is moved from the `ChannelEdgeInfo`
to the `ChannelGraph` struct.
2023-11-08 14:50:34 +02:00
Elle Mouton
6d878c65fc
channeldb: remove kvdb.Backend from LightningNode
Now that the kvdb.Backend is no longer required, it is removed from the
LightningNode struct.
2023-11-08 14:50:34 +02:00
Elle Mouton
d37f5d7e1a
autopilot: use pointer receivers for dbNode methods 2023-11-08 14:50:21 +02:00
Slyghtning
dd49c0175a
docs: update release notes 2023-11-08 10:15:52 +01:00
Slyghtning
8c04c1e7ce
contractcourt: log amount if incoming htlc times out 2023-11-08 09:56:03 +01:00
Elle Mouton
fa7c1e250b
multi: let ForEachChannel be a method on ChannelGraph
Having a `ForEachChannel` method on the `LightningNode` struct itself
results in a `kvdb.Backend` object needing to be stored within the
LightningNode struct. In this commit, this method is replaced with a
`ForEachNodeChannel` method on the `ChannelGraph` struct will perform
the same function without needing the db pointer to be stored within the
LightningNode. This change, the LightningNode struct more closely
represents the schema on disk.

The existing `ForEachNodeChannel` method on `ChannelGraph` is renamed to
`ForEachNodeDirectedChannel`. It performs a slightly different function
since it's call-back operates on Cached policies.
2023-11-08 10:51:50 +02:00
Olaoluwa Osuntokun
0116d9bd0b
Merge pull request #8155 from Roasbeef/v0-17-1-branch-rc2
release: create v0.17.1 rc2 release branch
2023-11-07 16:25:20 -08:00
Olaoluwa Osuntokun
dacb86fdbc
Merge pull request #8106 from orbitalturtle/sign-tagged-hash-rpc
lnrpc: add tagged hash option to signer.SignMessage/VerifyMessage rpcs
2023-11-06 17:05:35 -08:00
Olaoluwa Osuntokun
8ffd64b554
build: bump version to v0.17.1-beta.rc2 2023-11-06 16:10:55 -08:00
Olaoluwa Osuntokun
7dffad8e13 Merge branch 'v0-17-1-branch-rc2-8116' into v0-17-1-branch-rc2 2023-11-06 16:09:38 -08:00
Oliver Gugger
30fc8e96be GitHub: bump pinned versions in CI check 2023-11-06 16:09:38 -08:00
dependabot[bot]
cbccf61c7f build(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.3
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.53.0 to 1.56.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.53.0...v1.56.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-06 16:09:38 -08:00
Olaoluwa Osuntokun
710545b829
Merge pull request #8138 from Roasbeef/v0-17-1-branch-rc1
build: create v0.17.1-rc1 branch
2023-11-01 15:27:51 -07:00
Olaoluwa Osuntokun
155f66b16f Merge branch 'v0-17-1-branch-rc1-8063' into v0-17-1-branch-rc1 2023-11-01 11:17:04 -07:00
Oliver Gugger
464ddb4206 cmd/lncli: fix linter complaint by running make fmt 2023-11-01 11:17:04 -07:00
Olaoluwa Osuntokun
e6fbaafda4
Merge pull request #8139 from yyforyongyu/upgrade-bitcoind
CI: upgrade bitcoind version to 0.25
2023-11-01 11:15:12 -07:00
yyforyongyu
994a1426d6
CI: upgrade bitcoind version to 0.25 2023-11-01 16:34:07 +08:00
Olaoluwa Osuntokun
c8409575bb
build: bump version to v0.17.1-beta.rc1 2023-10-31 16:49:13 -07:00
Olaoluwa Osuntokun
2c2ba34537 Merge branch 'v0-17-1-branch-rc1-8132' into v0-17-1-branch-rc1 2023-10-31 16:44:35 -07:00
Olaoluwa Osuntokun
76862ed10b macaroons: reject unknown macaroon versions
We've only ever made macaroons with the v2 versions, so we should
explicitly reject those that aren't actually v2. We add a basic test
along the way, and also add a similar check for the version encoded in
the macaroon ID.
2023-10-31 16:44:35 -07:00
Olaoluwa Osuntokun
948f8732d6 Merge branch 'v0-17-1-branch-rc1-8104' into v0-17-1-branch-rc1 2023-10-31 16:44:17 -07:00
Olaoluwa Osuntokun
6c7bca2a17 docs/release-notes: add entry for nonce init fix 2023-10-31 16:44:17 -07:00
Slyghtning
9fa2057cd4 itest: simple taproot channel status 2023-10-31 16:44:17 -07:00
Slyghtning
b2a5368846 itest: assertions to check channel status 2023-10-31 16:44:17 -07:00
Eugene Siegel
280a97cbaa multi: skip InitRemoteMusigNonces if we've already called it
Prior to this commit, taproot channels had a bug:

- If a disconnect happened before peer.AddNewChannel was called,
  then the subsequent reconnect would call peer.AddNewChannel and
  attempt the ChannelReestablish dance.

- peer.AddNewChannel would call NewLightningChannel with
  populated nonce ChannelOpts. This in turn would call
  InitRemoteMusigNonces which would create a new musig pair session
  and set the channel's pendingVerificationNonce to nil.

- During the reestablish dance, ProcessChanSyncMsg would be called.
  This would also call InitRemoteMusigNonces, except it would fail
  since pendingVerificationNonce was set to nil in the previous
  invocation.

To fix this, we add a new functional option to signal to the init logic
that it doesn't need to call InitRemoteMusigNonces in   in
ProcessChanSyncMsg.
2023-10-31 16:44:17 -07:00
Olaoluwa Osuntokun
db6acec141 Merge branch 'v0-17-1-branch-rc1-8111' into v0-17-1-branch-rc1 2023-10-31 16:43:15 -07:00
Jonathan Harvey-Buschel
452af8ffa1 doc: add release notes for 8111 2023-10-31 16:43:15 -07:00
Jonathan Harvey-Buschel
6ea7d92c2e itest: add GetBlockHeader to ChainKit tests 2023-10-31 16:43:15 -07:00
Jonathan Harvey-Buschel
6a4dabc684 chainrpc+lncli: expose GetBlockHeader + add to CLI 2023-10-31 16:43:15 -07:00
Jonathan Harvey-Buschel
b04927f688 multi: add GetBlockHeader to BlockChainIO 2023-10-31 16:43:15 -07:00
Jonathan Harvey-Buschel
35bfd27467 chainrpc: update proto to expose GetBlockHeader 2023-10-31 16:43:15 -07:00
Olaoluwa Osuntokun
c0b14c7c39 Merge branch 'v0-17-0-branch-rc1-8094' into v0-17-0-branch-rc1 2023-10-31 16:24:16 -07:00
yyforyongyu
52fdf7086c gomod: update btcwallet re rescan race fix 2023-10-31 16:24:16 -07:00
Olaoluwa Osuntokun
6806a13f68 Merge branch 'v0-17-0-branch-rc1-8090' into v0-17-0-branch-rc1 2023-10-31 16:23:00 -07:00
ziggie
42dd0fa912 multi: clarify co-op closure failures. 2023-10-31 16:23:00 -07:00
Olaoluwa Osuntokun
58193ef18c Merge branch 'v0-17-0-branch-rc1-8019' into v0-17-0-branch-rc1 2023-10-31 16:22:29 -07:00
yyforyongyu
a0448eb14a gomod: update btcwallet version 2023-10-31 16:22:29 -07:00
Olaoluwa Osuntokun
5c4f2c129f Merge branch 'v0-17-0-branch-rc1-7965' into v0-17-0-branch-rc1 2023-10-31 16:21:57 -07:00
yyforyongyu
7be54096b6 itest: update related tests to reflect anchor sweeping
This commit updates all related tests to reflect the latest anchor
sweeping behavior. Previously, anchor sweeping is always attempted as
CPFP when a force close is broadcast, while now it only happens when the
deadline is less than 144. For non-CPFP purpose sweeping, it will happen
after one block is mined after the force close transaction is confirmed
as the anchor will be resent to the sweeper with a floor fee rate, hence
making it economical to sweep.
2023-10-31 16:21:57 -07:00
yyforyongyu
b8464ddd7e itest: fix testMultiHopRemoteForceCloseOnChainHtlcTimeout 2023-10-31 16:21:57 -07:00
yyforyongyu
0cb9ccd066 itest: update test testMultiHopHtlcLocalChainClaim to skip CPFP
Since we now only perform CPFP when both the fee rate is higher and the
deadline is less than 144, we need to update the test to reflect that
Bob will not CPFP the force close tx for the channle Alice->Bob.
2023-10-31 16:21:57 -07:00
yyforyongyu
2cb208e97c docs: update release notes 2023-10-31 16:21:57 -07:00
yyforyongyu
91719b0f49 contractcourt+itest: relax anchor sweeping for CPFP purpose
This commit changes from always sweeping anchor for a local force close
to only do so when there is an actual time pressure. After this change,
a forced anchor sweeping will only be attempted when the deadline is
less than 144 blocks.
2023-10-31 16:21:57 -07:00
yyforyongyu
c2148ad757 sweep: prioritize smaller inputs when adding wallet UTXOs
This commit sorts wallet UTXOs by their values when using them for
sweeping inputs. This way we'd avoid locking large UTXOs when sweeping
inputs and also provide an opportunity to aggregate wallet UTXOs.
2023-10-31 16:21:57 -07:00
yyforyongyu
dde605d375 sweeper: add more docs and debug logs 2023-10-31 16:21:57 -07:00
yyforyongyu
7ebc538c10 sweep: use longer variable name for clarity in addToState 2023-10-31 16:21:57 -07:00
Olaoluwa Osuntokun
738e0c64ec Merge branch 'v0-17-0-branch-rc1-7937' into v0-17-0-branch-rc1 2023-10-31 16:21:19 -07:00
eugene
28c260e4ea release-notes: update for 0.17.1 2023-10-31 16:21:19 -07:00
eugene
75406d177b htlcswitch/hop: use InvalidOnionVersion for replayed packets
The link will send an update_fail_malformed_htlc, so we need to set
the BADONION bit. Since there isn't a replay-specific error, we
set the failure code to InvalidOnionVersion which has the BADONION bit.
2023-10-31 16:21:19 -07:00
Olaoluwa Osuntokun
3c605dbff5 Merge branch 'v0-17-0-branch-rc1-8053' into v0-17-0-branch-rc1 2023-10-31 16:20:50 -07:00
Kilian
6521576f42 lncli: fix description of connect/disconnect peer 2023-10-31 16:20:50 -07:00
Olaoluwa Osuntokun
eb5fc0c349
Merge pull request #7811 from yyforyongyu/fix-panix
contractcourt: stop lnd when received witness is empty
2023-10-31 15:17:30 -07:00
Olaoluwa Osuntokun
b0261f7793
Merge pull request #8132 from Roasbeef/strict-macaroon-version
macaroons: reject unknown macaroon versions
2023-10-31 15:16:55 -07:00
Olaoluwa Osuntokun
9287b755d8
macaroons: reject unknown macaroon versions
We've only ever made macaroons with the v2 versions, so we should
explicitly reject those that aren't actually v2. We add a basic test
along the way, and also add a similar check for the version encoded in
the macaroon ID.
2023-10-31 13:23:50 -07:00
Olaoluwa Osuntokun
c382268201
Merge pull request #8104 from Roasbeef/taproot-chans-nonce-double-init
multi: skip InitRemoteMusigNonces if we've already called it
2023-10-31 13:02:54 -07:00
Olaoluwa Osuntokun
7f652ee729
Merge pull request #8135 from yyforyongyu/fix-flakes
multi: fix test flakes in unit tests and itests
2023-10-31 12:58:25 -07:00
Olaoluwa Osuntokun
8c121ee5e0
docs/release-notes: add entry for nonce init fix 2023-10-31 10:10:49 -07:00
Slyghtning
12f23d2352
itest: simple taproot channel status 2023-10-31 10:10:43 -07:00
Slyghtning
20e731b636
itest: assertions to check channel status 2023-10-31 10:10:41 -07:00
Eugene Siegel
dc42b160a0
multi: skip InitRemoteMusigNonces if we've already called it
Prior to this commit, taproot channels had a bug:

- If a disconnect happened before peer.AddNewChannel was called,
  then the subsequent reconnect would call peer.AddNewChannel and
  attempt the ChannelReestablish dance.

- peer.AddNewChannel would call NewLightningChannel with
  populated nonce ChannelOpts. This in turn would call
  InitRemoteMusigNonces which would create a new musig pair session
  and set the channel's pendingVerificationNonce to nil.

- During the reestablish dance, ProcessChanSyncMsg would be called.
  This would also call InitRemoteMusigNonces, except it would fail
  since pendingVerificationNonce was set to nil in the previous
  invocation.

To fix this, we add a new functional option to signal to the init logic
that it doesn't need to call InitRemoteMusigNonces in   in
ProcessChanSyncMsg.
2023-10-31 10:10:35 -07:00
yyforyongyu
fc52a01055
itest: fix test flake in testHtlcTimeoutResolverExtractPreimageRemote
From the build,
```
harness_miner.go:218:
        	Error Trace:	/home/runner/work/lnd/lnd/lntest/harness_miner.go:218
        	            				/home/runner/work/lnd/lnd/lntest/harness.go:1641
        	            				/home/runner/work/lnd/lnd/itest/lnd_multi-hop_test.go:2207
        	            				/home/runner/work/lnd/lnd/itest/lnd_multi-hop_test.go:152
        	Error:      	Received unexpected error:
        	            	want 2, got 3 in mempool: [a7cbb5724e39579cfc75d0469270f691988cb67fcc51a332256cafb193cf40bd b12a03a0622a3cf7d53867f060a6de8166e564a1a3109bc2be1ec0b720f305da 073d66885ccded1a770dc9aa5f1d44c8e10ac4e916e5ab50ef5149a5649ec8ba]
        	Test:       	TestLightningNetworkDaemon/tranche03/130-of-135/neutrino/htlc_timeout_resolver_extract_preimage_remote/zeroconf=false/committype=SIMPLE_TAPROOT
        	Messages:   	assert tx in mempool timeout
    harness.go:339: finished test: htlc_timeout_resolver_extract_preimage_remote, start height=1312, end height=1347, mined blocks=35
```
2023-10-31 23:49:31 +08:00
yyforyongyu
cc6b20bf2f
lntest: mine empty blocks when cleaning up force close
Fix this test flake,
```
harness_miner.go:218:
        	Error Trace:	/home/runner/work/lnd/lnd/lntest/harness_miner.go:218
        	            				/home/runner/work/lnd/lnd/lntest/harness.go:1641
        	            				/home/runner/work/lnd/lnd/lntest/harness.go:1515
        	            				/home/runner/work/lnd/lnd/itest/lnd_wipe_fwdpkgs_test.go:121
        	            				/home/runner/work/lnd/lnd/lntest/harness.go:286
        	            				/home/runner/work/lnd/lnd/itest/lnd_test.go:136
        	Error:      	Received unexpected error:
        	            	want 1, got 0 in mempool: []
        	Test:       	TestLightningNetworkDaemon/tranche02/91-of-135/neutrino/wipe_forwarding_packages
        	Messages:   	assert tx in mempool timeout
    harness.go:339: finished test: wipe_forwarding_packages, start height=1636, end height=1653, mined blocks=17
    harness.go:345: test failed, skipped cleanup
```
2023-10-31 16:51:24 +08:00
yyforyongyu
2caa7d2b2b
invoices: add verbose errors to catch flakes in
`TestInvoiceExpiryWithRegistry`
2023-10-31 16:31:44 +08:00
Orbital
7ca96a6ab9
docs: update release notes 2023-10-30 21:40:18 -05:00
Orbital
aa6f13e524
itest: test SignMessage/VerifyMessage tag option 2023-10-30 21:39:39 -05:00
Orbital
ed373baed0
multi: add tag option to SignMessageSchnorr 2023-10-30 21:39:39 -05:00
Orbital
dd81edd817
signrpc: add tag option to SignMessage/VerifyMessage rpcs 2023-10-30 21:39:38 -05:00
Olaoluwa Osuntokun
32c8b82c36
Merge pull request #7669 from morehouse/fuzz_lnwire_onion_errors
lnwire: fuzz onion failure messages
2023-10-30 12:44:55 -07:00
Olaoluwa Osuntokun
78ff68ad05
Merge pull request #8119 from lightningnetwork/udpate-docs
docs: Add requirement for bitcoind.
2023-10-30 12:34:57 -07:00
Olaoluwa Osuntokun
99617f7afe
Merge pull request #8123 from R3DRUN3/master
add release build and go report status badges
2023-10-30 10:51:10 -07:00
Olaoluwa Osuntokun
19880ffe2c
Merge pull request #8101 from yyforyongyu/fix-web-fee-unit-test
chainfee: Fix test flake in `TestWebAPIFeeEstimator`
2023-10-30 10:50:16 -07:00
yyforyongyu
28497e940f
docs: update release notes re empty witness data 2023-10-31 01:45:07 +08:00
yyforyongyu
ee883c332f
chainntnfs: stop lnd when received witness stack is empty
This commit uses `Criticalf` to gracefully stop `lnd` when the received
witness data is empty.
2023-10-31 01:44:43 +08:00
yyforyongyu
28c3c835bf
chainntnfs: return an error when witness stack is empty
This commit adds a check when receiving transactions from
`BitcoindClient` so an error is returned when empty witness is found.
2023-10-31 01:44:43 +08:00
yyforyongyu
971d3d8d9c
contractcourt: make sure isPreimageSpend won't panic
This commit adds a length check in `isPreimageSpend` to make sure it
won't ever panic and adds a unit test to verify it.
2023-10-31 01:44:43 +08:00
Olaoluwa Osuntokun
99481e3e84
Merge pull request #8127 from lightningnetwork/dependabot/go_modules/github.com/docker/docker-24.0.7incompatible
build(deps): bump github.com/docker/docker from 20.10.24+incompatible to 24.0.7+incompatible
2023-10-30 10:41:27 -07:00
dependabot[bot]
2a8cf329b9
build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.24+incompatible to 24.0.7+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v20.10.24...v24.0.7)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-30 15:39:29 +00:00
r3drun3
071214006f
docs(readme): add release build and go report status badges
Signed-off-by: r3drun3 <simone.ragonesi@sighup.io>
2023-10-30 08:44:06 +01:00
yyforyongyu
3c62ba57d3
chainfee: make timeout values constant 2023-10-29 13:24:28 +08:00
yyforyongyu
090892c613
chainfee: use proper mock for WebAPIFeeSource in tests 2023-10-29 13:24:27 +08:00
yyforyongyu
efcba4a836
chainfee: simplify WebAPIFeeSource interface
This commit removes the interface methods `GenQueryURL` and
`ParseResponse` so the `WebAPIEstimator` can care less about the
implementation details of this interface.
2023-10-29 13:24:27 +08:00
yyforyongyu
8ca48311ee
chainfee: add a new interface method GetFeeMap
This commit adds a new method `GetFeeMap` to handle querying the web API
and parse the response into a map that's used by the fee estimator. In
doing so we can provide a deeper abstraction over the `WebAPIFeeSource`
interface.
2023-10-29 13:24:27 +08:00
Matt Morehouse
66d6a8455d
docs: update release notes 2023-10-27 14:54:29 -05:00
Matt Morehouse
ed1b54ac3a
lnwire: use require package for onion failure fuzz tests 2023-10-27 14:52:00 -05:00
Matt Morehouse
a7ee45bea0
lnwire: add FuzzFailIncorrectDetails test
The test is identical to other onion failure fuzz tests, except that it
uses a custom equality function to get around the nil != []byte{} issue
with reflect.DeepEqual.
2023-10-27 14:52:00 -05:00
Matt Morehouse
2181fd432c
lnwire: fuzz onion failure messages
Fuzz tests for decoding and encoding of onion failure messages, based on
the fuzz harness for other lnwire messages. The onion failure messages
were uncovered by existing fuzz tests.
2023-10-27 14:12:41 -05:00
Oliver Gugger
3b7cda9e8d
Merge pull request #8111 from jharveyb/chainkit_add_getblockheader
chainkit: expose getblockheader
2023-10-27 18:35:05 +02:00
Jonathan Harvey-Buschel
459a60e4e6
doc: add release notes for 8111 2023-10-27 11:05:28 -04:00
Jonathan Harvey-Buschel
c5d041f2f4
itest: add GetBlockHeader to ChainKit tests 2023-10-27 11:05:28 -04:00
Jonathan Harvey-Buschel
c20e4871cd
chainrpc+lncli: expose GetBlockHeader + add to CLI 2023-10-27 11:05:27 -04:00
Jonathan Harvey-Buschel
6edd1e1220
multi: add GetBlockHeader to BlockChainIO 2023-10-27 11:05:27 -04:00
ziggie
8bbab59745
docs: fix double hypen to single hyphen.
bitcoind uses single hyphens so changed where necessary.
2023-10-27 13:30:44 +02:00
ziggie
14c4addcdc
docs: Add requirement for bitcoind [skip ci]
Add a comment to disallow the bitcoind config parameter
`rpcserialversion`.
2023-10-27 13:28:09 +02:00
Jonathan Harvey-Buschel
7a8803e3cf
chainrpc: update proto to expose GetBlockHeader 2023-10-26 16:16:35 -04:00
Oliver Gugger
7d2e0ae3e4
Merge pull request #8116 from lightningnetwork/dependabot/go_modules/google.golang.org/grpc-1.56.3
build(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.3
2023-10-26 14:06:09 +02:00
Oliver Gugger
e6fde8bd0c
GitHub: bump pinned versions in CI check 2023-10-26 10:25:35 +02:00
dependabot[bot]
c5e42a752a
build(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.3
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.53.0 to 1.56.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.53.0...v1.56.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-26 07:20:20 +00:00
Oliver Gugger
06020578c9
Merge pull request #8115 from lightningnetwork/dependabot/go_modules/kvdb/google.golang.org/grpc-1.56.3
build(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.3 in /kvdb
2023-10-26 09:19:02 +02:00
dependabot[bot]
effa5cf066
build(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.3 in /kvdb
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.53.0 to 1.56.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.53.0...v1.56.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-25 22:28:42 +00:00
Olaoluwa Osuntokun
a1fa195493
Merge pull request #8091 from yyforyongyu/remove-rbf-sweeper
sweep: remove possible RBF when sweeping new inputs
2023-10-25 15:14:32 -07:00
rockstardev
c54373522e Updating README 2023-10-25 13:59:06 -05:00
rockstardev
11bae66d31 Merge branch 'lnd/v0.17.0-beta' 2023-10-25 13:52:18 -05:00
rockstardev
9115aa385f Updating loop to v0.26.4-beta 2023-10-25 13:49:30 -05:00
rockstardev
e234af10a2 Updating README file 2023-10-25 13:46:50 -05:00
rockstardev
dd83fa5286 Merge branch 'lnd/v0.17.0-beta'
# Conflicts:
#	.github/workflows/main.yml
#	.github/workflows/release.yaml
#	.travis.yml
#	Dockerfile
#	cmd/lncli/cmd_open_channel.go
#	contractcourt/htlc_timeout_resolver.go
#	dev.Dockerfile
#	docs/release-notes/release-notes-0.16.0.md
#	docs/release-notes/release-notes-0.16.1.md
#	docs/release-notes/release-notes-0.16.3.md
#	funding/manager.go
#	funding/manager_test.go
#	go.mod
#	go.sum
#	itest/list_on_test.go
#	itest/lnd_channel_funding_fund_max_test.go
#	itest/lnd_funding_test.go
#	itest/lnd_multi-hop_test.go
#	itest/lnd_open_channel_test.go
#	lnrpc/lightning.pb.go
#	lnrpc/lightning.proto
#	lnrpc/lightning.swagger.json
#	lnrpc/walletrpc/walletkit_server.go
#	lntest/harness.go
#	lntest/harness_assertion.go
#	lnutils/sync_map.go
#	lnwallet/chanfunding/assembler.go
#	lnwallet/chanfunding/coin_select_test.go
#	lnwallet/chanfunding/wallet_assembler.go
#	lnwallet/wallet.go
#	make/builder.Dockerfile
#	peer/brontide.go
#	rpcserver.go
2023-10-25 13:42:10 -05:00
rockstardev
bc951d7c24 Merge branch 'lnd/v0.16.4-beta'
# Conflicts:
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
2023-10-25 13:41:40 -05:00
rockstardev
39ecf64086 Merge branch 'lnd/v0.16.3-beta'
# Conflicts:
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
2023-10-25 13:41:20 -05:00
rockstardev
5dd6d0a588 Merge branch 'lnd/v0.16.2-beta'
# Conflicts:
#	docker-entrypoint.sh
#	docker-initunlocklnd.sh
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
2023-10-25 13:40:51 -05:00
rockstardev
38726b19ad Merge branch 'lnd/v0.16.1-beta'
# Conflicts:
#	Makefile
#	build/version.go
2023-10-25 13:39:14 -05:00
rockstardev
97629cbae2 Merge branch 'lnd/v0.16.0-beta'
# Conflicts:
#	.github/ISSUE_TEMPLATE/bug_report.md
#	aliasmgr/aliasmgr.go
#	aliasmgr/aliasmgr_test.go
#	channeldb/channel.go
#	channeldb/db.go
#	channeldb/meta.go
#	channeldb/meta_test.go
#	channeldb/migration30/iterator.go
#	channeldb/migration30/iterator_test.go
#	channeldb/migration30/lnwallet.go
#	channeldb/migration30/migration.go
#	channeldb/migration30/migration_test.go
#	channeldb/migration30/revocation_log.go
#	channeldb/migration30/test_utils.go
#	channeldb/migtest/migtest.go
#	channeldb/options.go
#	channeldb/payment_control_test.go
#	channeldb/revocation_log_test.go
#	cmd/lncli/cmd_open_channel.go
#	cmd/lncli/walletrpc_active.go
#	config.go
#	config_builder.go
#	discovery/gossiper.go
#	discovery/gossiper_test.go
#	docker-entrypoint.sh
#	docker-initunlocklnd.sh
#	docs/INSTALL.md
#	docs/release-notes/release-notes-0.15.1.md
#	docs/release-notes/release-notes-0.15.3.md
#	funding/manager.go
#	funding/manager_test.go
#	go.mod
#	go.sum
#	htlcswitch/link_test.go
#	htlcswitch/mock.go
#	htlcswitch/switch.go
#	htlcswitch/switch_test.go
#	itest/lnd_nonstd_sweep_test.go
#	itest/lnd_psbt_test.go
#	itest/lnd_remote_signer_test.go
#	itest/lnd_rpc_middleware_interceptor_test.go
#	itest/lnd_signer_test.go
#	itest/lnd_zero_conf_test.go
#	keychain/btcwallet.go
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
#	lncfg/db.go
#	lnd.go
#	lnrpc/invoicesrpc/addinvoice.go
#	lnrpc/invoicesrpc/addinvoice_test.go
#	lnrpc/invoicesrpc/invoices.swagger.json
#	lnrpc/lightning.pb.go
#	lnrpc/lightning.pb.gw.go
#	lnrpc/lightning.pb.json.go
#	lnrpc/lightning.proto
#	lnrpc/lightning.swagger.json
#	lnrpc/lightning.yaml
#	lnrpc/lightning_grpc.pb.go
#	lnrpc/neutrinorpc/neutrino_grpc.pb.go
#	lnrpc/routerrpc/router.pb.go
#	lnrpc/signrpc/signer.pb.go
#	lnrpc/signrpc/signer_grpc.pb.go
#	lnrpc/walletrpc/walletkit.pb.go
#	lnrpc/walletrpc/walletkit.pb.gw.go
#	lnrpc/walletrpc/walletkit.pb.json.go
#	lnrpc/walletrpc/walletkit.proto
#	lnrpc/walletrpc/walletkit.yaml
#	lnrpc/walletrpc/walletkit_grpc.pb.go
#	lnrpc/walletrpc/walletkit_server.go
#	lntest/harness_net.go
#	lntest/harness_node.go
#	lntest/itest/lnd_channel_backup_test.go
#	lntest/itest/lnd_multi-hop_htlc_aggregation_test.go
#	lntest/itest/lnd_multi-hop_htlc_local_chain_claim_test.go
#	lntest/itest/lnd_multi-hop_htlc_local_timeout_test.go
#	lntest/itest/lnd_multi-hop_htlc_receiver_chain_claim_test.go
#	lntest/itest/lnd_multi-hop_htlc_remote_chain_claim_test.go
#	lntest/itest/lnd_multi-hop_local_force_close_on_chain_htlc_timeout_test.go
#	lntest/itest/lnd_multi-hop_remote_force_close_on_chain_htlc_timeout_test.go
#	lntest/itest/lnd_multi-hop_test.go
#	lntest/itest/lnd_onchain_test.go
#	lntest/itest/lnd_recovery_test.go
#	lntest/itest/lnd_switch_test.go
#	lntest/itest/lnd_taproot_test.go
#	lntest/itest/lnd_test_list_on_test.go
#	lntest/itest/utils.go
#	lntest/mock/secretkeyring.go
#	lntest/mock/walletcontroller.go
#	lnwallet/btcwallet/btcwallet.go
#	lnwallet/chancloser/chancloser_test.go
#	lnwallet/interface.go
#	peer/brontide.go
#	peer/test_utils.go
#	routing/control_tower_test.go
#	routing/payment_lifecycle.go
#	routing/router.go
#	routing/router_test.go
#	rpcperms/interceptor.go
#	rpcserver.go
#	sample-lnd.conf
#	server.go
2023-10-25 13:37:25 -05:00
rockstardev
9786a1fa2c Adding BtcPayServer related files and resources 2023-10-25 13:22:30 -05:00
Oliver Gugger
ebbf078d6d
Merge pull request #8014 from Roasbeef/go-loop-exp
build: prep for Go 1.22 by using GOEXPERIMENT=loopvar for tests
2023-10-25 15:36:52 +02:00
Olaoluwa Osuntokun
63a94ad987
build: build+install using GOEXPERIMENT=loopvar
We also update the release script to do the same as well.
2023-10-24 18:40:58 -07:00
Olaoluwa Osuntokun
206ad69b75
discovery: fix incorrect test, masked by loop scoping bug
When we first go to boot up the syncer, when we're in the active phase,
after we do the historical sync, we'll send a timestamp message that we
want everything, then transition to the passive mode. The test didn't
account for this extra message before, as the last test was being
re-used here (ran in parallel).

We fix this by asserting that the first expected message is sent, then
also the follow up messages as well.
2023-10-24 18:40:53 -07:00
Olaoluwa Osuntokun
b1eaeb6ac6
build: prep for Go 1.22 by using GOEXPERIMENT=loopvar for tests
In this commit, [we prep for some upcoming changes in
Go](https://go.dev/blog/loopvar-preview) by running our tests with
`GOEXPERIMENT=loopvar`. This changes the loop semantics to fix a common
bug where a scoping issue causes a variable to be re-used, which can
cause unintended bugs down the line.

If everything passes with this flag on, then we can keep it on, and also
rest a bit easier knowing that the compiler will fix a class of bugs
that would previously pop up for us.
2023-10-24 18:40:49 -07:00
yyforyongyu
dba4c8e5ad
trivial: fix typo and nits 2023-10-23 13:01:52 +08:00
yyforyongyu
05fbe8b116
docs: update release note re RBF fix 2023-10-23 13:01:52 +08:00
yyforyongyu
0816f9124c
itest: update itest to reflect new sweeper behavior 2023-10-23 13:01:50 +08:00
yyforyongyu
92837621ec
sweep: remove possible RBF when creating sweeping tx for new inputs
This commit changes how we create the input sets which are used to
construct the sweeping transactions. Assume the sweeper has two inputs,
one is new and one is retried, we'd end up having two transactions,
- tx1: which spends both the new and old inputs.
- tx2: which spends the new inputs only.
When publishing these txes, depending on which one gets into the mempool
first, the other one will be viewed as an RBF for the first one since
they both spending the same input(the new input).

This is now fixed by only attempt to publish the second tx when there
isn't a first tx - when there is a tx1, it means the new inputs are
already used in this tx along with retried inputs, hence there's no need
to publish tx2 which spends the new inputs only.
2023-10-23 10:48:51 +08:00
yyforyongyu
acc15d8113
sweep: add new method rescheduleInputs and refactor sweep 2023-10-23 10:44:46 +08:00
yyforyongyu
7de4186766
sweep: simplify polling logic in sweeper
This commit attempts to make the polling logic in sweeper more linear.
Previously, the sweep's timer is reset/restarted in multiple places,
such as when a new input comes in, or a new block comes in, or a
previous input being spent, making it difficult to follow. We now remove
the old timer and replaces it with a simple polling logic - we will
schedule sweeps every 5s(default), and if there's no input to be swept,
we'd skip, just like the previous `scheduleSweep` does.
It's also worthy noting that, although `scheduleSweep` triggers the
timer to tick, by the time we do the actual sweep in `sweepCluster`,
conditions may have changed. This is now also fixed because we only have
one place to create the clusters and sweeps.
2023-10-23 10:24:58 +08:00
yyforyongyu
4ba09098d1
sweep+lnd: move ticker creation into sweeper 2023-10-23 10:24:58 +08:00
yyforyongyu
62b5869f87
sweep: add new method handleSweep 2023-10-23 10:24:58 +08:00
yyforyongyu
f1d0f9f74e
sweep: add new method handleInputSpent 2023-10-23 10:24:58 +08:00
yyforyongyu
39a7cc6434
sweep: rename waitForSpend to monitorSpend to avoid confusion
The method `waitForSpend` makes it sounding like it's blocking while
it's not, thus it's renamed to avoid confusion.
2023-10-23 10:24:58 +08:00
yyforyongyu
39973687aa
sweep: add new method handleNewInput 2023-10-23 10:24:58 +08:00
Oliver Gugger
15f4213793
Merge pull request #7828 from ProofOfKeags/pong-enforcement
multi: pong enforcement
2023-10-19 21:50:08 +02:00
Keagan McClelland
012cc6af8c peer: eliminate unnecessary log spam from received pong msgs 2023-10-19 09:26:50 -07:00
Keagan McClelland
5762061487 docs: Update release notes to include pong enforcement 2023-10-19 09:26:50 -07:00
Keagan McClelland
99226e37ef peer: Add machinery to track the state and validity of remote pongs
This commit refactors some of the bookkeeping around the ping logic
inside of the Brontide. If the pong response is noncompliant with
the spec or if it times out, we disconnect from the peer.
2023-10-19 09:26:45 -07:00
Keagan McClelland
1eab7826d2 peer: abstract out ping payload generation from the pingHandler
This change makes the generation of the ping payload a no-arg
closure parameter, relieving the pingHandler of having to
directly monitor the chain state. This makes use of the
BestBlockView that was introduced in earlier commits.
2023-10-19 09:22:07 -07:00
Keagan McClelland
ac265812fc peer+lnd: make BestBlockView available to Brontide 2023-10-19 09:22:07 -07:00
Keagan McClelland
74b30a71cb lnd: start the BestBlockTracker during server startup 2023-10-19 09:22:07 -07:00
Keagan McClelland
7c403b439c chainreg: Add BestBlockTracker to ChainControl
This commit takes the best block tracker and adds it to the
ChainControl objects and appropriately initializes it on
ChainControl creation
2023-10-19 09:22:07 -07:00
Keagan McClelland
405d4e5f73 chainntnfs: introduce system for chain state tracking and querying
This change adds a new subsystem that is responsible for providing
an up to date view of some global chainstate parameters.
2023-10-19 09:22:07 -07:00
Oliver Gugger
e1fb1e484a
Merge pull request #7967 from morehouse/fuzz_onion
htlcswitch: fuzz onion encoding/decoding
2023-10-19 15:30:03 +00:00
Oliver Gugger
812f4d9242
Merge pull request #8081 from bhandras/invoicedb-refactor
invoices: refactor `InvoiceDB` to eliminate `ScanInvoices`
2023-10-19 09:27:54 +00:00
Olaoluwa Osuntokun
9bdbd79bd2
Merge pull request #8094 from yyforyongyu/fix-rescan-race
gomod: update btcwallet re rescan race fix
2023-10-18 12:25:41 -07:00
Andras Banki-Horvath
bedafca49d
docs: update release notes for 0.18.0 2023-10-18 16:15:59 +02:00
Andras Banki-Horvath
8bf7503aa4
invoices: remove the now unused ScanInvoices method 2023-10-18 16:15:58 +02:00
Andras Banki-Horvath
d7d385f78f
invoices: refactor initial invoice scan when the registry starts
In this commit we change how we select invoices to follow or delete when
starting the InvoiceRegistry to instead of using the deperecated scan
func from channeldb, use specific functions to gather pending and delete
canceled invoices.
2023-10-18 16:15:58 +02:00
Andras Banki-Horvath
8ab267ad90
channeldb: add k/v implementation for InvoiceDB.DeleteCanceledInvoices method 2023-10-18 16:15:58 +02:00
Andras Banki-Horvath
1f8065de35
channeldb: add k/v implementation for InvoiceDB.FetchPendingInvoices 2023-10-18 16:15:57 +02:00
Oliver Gugger
91d910872d
Merge pull request #7715 from bshramin/http-client-timeout
lntest: set ReadHeaderTimeout for http client
2023-10-17 19:33:39 +00:00
yyforyongyu
59a20fe1d1
gomod: update btcwallet re rescan race fix 2023-10-18 01:31:27 +08:00
Amin Bashiri
0c64a183cf
lntest: add http header timeout to config 2023-10-17 11:25:06 -06:00
Oliver Gugger
82838e4a62
Merge pull request #8090 from ziggie1984/add-additional-log-chan-closure
Add more information when a co-op close is failing.
2023-10-17 10:27:21 +00:00
Oliver Gugger
b0bb853f77
Merge pull request #8092 from yyforyongyu/fix-peer-unit-test
multi: fix peer unit test and disable `paralleltest`
2023-10-17 10:18:27 +00:00
Oliver Gugger
e8d865aba5
Merge pull request #7824 from yyforyongyu/sweeper-unit-test
input+sweep: make sure input with no fee rate is not added to cluster
2023-10-17 06:36:21 +00:00
Oliver Gugger
a6f044b748
Merge pull request #8057 from Chinwendu20/tlv-bool
tlv: Added bool to primitive
2023-10-16 15:23:48 +00:00
Ononiwu Maureen
844a792251 docs: Added release note
Signed-off-by: Ononiwu Maureen <amaka013@gmail.com>
2023-10-16 14:21:36 +01:00
Ononiwu Maureen
206f773a9b tlv: Added bool to primitive
Signed-off-by: Ononiwu Maureen <amaka013@gmail.com>
2023-10-16 14:21:25 +01:00
Oliver Gugger
d6c7200bb4
Merge pull request #8086 from lightningnetwork/dependabot/go_modules/tor/golang.org/x/net-0.17.0
build(deps): bump golang.org/x/net from 0.10.0 to 0.17.0 in /tor
2023-10-16 11:00:19 +00:00
Oliver Gugger
55c5a33f6f
Merge pull request #8087 from lightningnetwork/dependabot/go_modules/kvdb/golang.org/x/net-0.17.0
build(deps): bump golang.org/x/net from 0.10.0 to 0.17.0 in /kvdb
2023-10-16 10:59:59 +00:00
dependabot[bot]
be9fb28ac1
build(deps): bump golang.org/x/net from 0.10.0 to 0.17.0 in /kvdb
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.10.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 10:45:31 +00:00
dependabot[bot]
aa95469b1f
build(deps): bump golang.org/x/net from 0.10.0 to 0.17.0 in /tor
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.10.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 10:45:20 +00:00
dependabot[bot]
cbb6e681a5
build(deps): bump github.com/btcsuite/btcd in /healthcheck (#8051)
Bumps [github.com/btcsuite/btcd](https://github.com/btcsuite/btcd) from 0.22.0-beta.0.20220207191057-4dc4ff7963b4 to 0.23.2.
- [Release notes](https://github.com/btcsuite/btcd/releases)
- [Changelog](https://github.com/btcsuite/btcd/blob/master/CHANGES)
- [Commits](https://github.com/btcsuite/btcd/commits/v0.23.2)

---
updated-dependencies:
- dependency-name: github.com/btcsuite/btcd
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-16 12:44:27 +02:00
Yong
6a80530fff
gomod: update btcwallet version (#8019) 2023-10-16 09:14:56 +02:00
guangwu
fad7d3fe81
chore: pkg import only once (#8093)
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-10-16 09:02:05 +02:00
ziggie
e4dd911778
multi: clarify co-op closure failures. 2023-10-13 20:35:08 +02:00
yyforyongyu
d0edb47166
docs: update release notes 2023-10-13 17:00:53 +08:00
yyforyongyu
551102a0f3
sweep: fix make lint 2023-10-13 17:00:53 +08:00
yyforyongyu
34e0c7b5e0
input+sweep: make sure input with no fee rate is not added to cluster
This commit makes sure an input is only added to the cluster when it has
successfully estimated its fee rate. Previously, when an error is
returned from `feeRateForPreference`, we'd still add this input to the
cluster, resulting a **lower** fee rates being used because when
averaging the fee rates, we'd think this input has zero fee rate
specified.

An unit test is patched to make the method `clusterByLockTime` more
robust.
2023-10-13 17:00:53 +08:00
yyforyongyu
0532b82dd5
multi: add new method FeePerVByte to avoid manual conversion 2023-10-13 17:00:53 +08:00
yyforyongyu
a46168e669
sweep: remove redundant map inputFeeRates when creating cluster
This commit removes the map `inputFeeRates` inside `clusterByLockTime`
as the fee rate can already be access via `input.lastFeeRate`.
2023-10-13 17:00:53 +08:00
yyforyongyu
497f421009
sweep: patch unit test for feeRateForPreference 2023-10-13 17:00:53 +08:00
yyforyongyu
82053970ef
lnd+sweep: move DetermineFeePerKw into config
This commit makes `DetermineFeePerKw` configurable on sweeper so it's
easier to write unit tests for it.
2023-10-13 14:44:20 +08:00
yyforyongyu
22600b47f1
multi: disable linter paralleltest 2023-10-13 13:50:09 +08:00
yyforyongyu
839b6271e5
peer: fix unit test flake 2023-10-13 13:50:07 +08:00
Yong
939375f1a5
sweeper: relax anchor sweeping when there's no deadline pressure (#7965)
* sweep: use longer variable name for clarity in `addToState`

* sweeper: add more docs and debug logs

* sweep: prioritize smaller inputs when adding wallet UTXOs

This commit sorts wallet UTXOs by their values when using them for
sweeping inputs. This way we'd avoid locking large UTXOs when sweeping
inputs and also provide an opportunity to aggregate wallet UTXOs.

* contractcourt+itest: relax anchor sweeping for CPFP purpose

This commit changes from always sweeping anchor for a local force close
to only do so when there is an actual time pressure. After this change,
a forced anchor sweeping will only be attempted when the deadline is
less than 144 blocks.

* docs: update release notes

* itest: update test `testMultiHopHtlcLocalChainClaim` to skip CPFP

Since we now only perform CPFP when both the fee rate is higher and the
deadline is less than 144, we need to update the test to reflect that
Bob will not CPFP the force close tx for the channle Alice->Bob.

* itest: fix `testMultiHopRemoteForceCloseOnChainHtlcTimeout`

* itest: update related tests to reflect anchor sweeping

This commit updates all related tests to reflect the latest anchor
sweeping behavior. Previously, anchor sweeping is always attempted as
CPFP when a force close is broadcast, while now it only happens when the
deadline is less than 144. For non-CPFP purpose sweeping, it will happen
after one block is mined after the force close transaction is confirmed
as the anchor will be resent to the sweeper with a floor fee rate, hence
making it economical to sweep.
2023-10-12 17:18:59 +02:00
Yong
ca9cdacd5f
github: print debug logs for failed unit tests (#8083) 2023-10-12 12:50:11 +02:00
dependabot[bot]
3b933d5c5e
build(deps): bump golang.org/x/net from 0.10.0 to 0.17.0 in /healthcheck (#8085)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.10.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-12 10:46:07 +02:00
dependabot[bot]
3f67420722
build(deps): bump golang.org/x/net from 0.10.0 to 0.17.0 (#8084)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.10.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-12 10:45:45 +02:00
Amin Bashiri
039e9effe7
lnd: add http header timeout to config 2023-10-11 22:05:50 -06:00
András Bánki-Horváth
ad5cd9c8bb
multi: extend InvoiceDB methods with a context argument (#8066)
* multi: extend InvoiceDB methods with a context argument

This commit adds a context to InvoiceDB's methods. Along this refactor
we also extend InvoiceRegistry methods with contexts where it makes
sense. This change is essential to be able to provide kvdb and sqldb
implementations for InvoiceDB.

* channeldb: restrict invoice tests to only use an InvoiceDB instance

* docs: update release notes for 0.18.0
2023-10-11 13:42:59 +02:00
Eugene
9478b85e59
htlcswitch/hop: use InvalidOnionVersion for replayed packets (#7937)
* htlcswitch/hop: use InvalidOnionVersion for replayed packets

The link will send an update_fail_malformed_htlc, so we need to set
the BADONION bit. Since there isn't a replay-specific error, we
set the failure code to InvalidOnionVersion which has the BADONION bit.

* release-notes: update for 0.17.1
2023-10-11 10:08:43 +02:00
Oliver Gugger
abb1e3463f
scripts: kill lnd on windows to access log files (#8076)
For some reason lnd doesn't properly shut down on some windows itests,
and the process still running makes it impossible to access its log
files.
So for the Windows integration test, we attempt to kill the whole
process tree once the process indicates it is done.
2023-10-10 16:15:41 +02:00
Matt Morehouse
2d98dcf520
tlv: fuzz test encoding/decoding (#7889)
* tlv: fuzz tests for primitives

* tlv: fuzz tests for BigSize

We use a new harness to compare decoded values instead of encoded
values, since there may be some unparsed bytes in the original data.

* tlv: fuzz tests for truncated integers

These fuzz tests are identical to non-truncated integers, except that we
allow the fuzzer to choose decode lengths shorter than the length of
normal integers.

* tlv: fuzz tests for streams

* fixup! tlv: fuzz tests for truncated integers

loop over decode length

* fixup! tlv: fuzz tests for streams

better documentation
2023-10-10 14:01:41 +02:00
Olaoluwa Osuntokun
4f346060df
Merge pull request #8067 from lightningnetwork/0-18-staging-rebased
branch: merge 0.18 staging branch into master
2023-10-09 11:20:11 -07:00
Yong
ec2377db79
funding: remove dead code and sanity check pending chan ID (#7887)
* funding: remove unused field `newChanBarriers`

This commit removes the occurance of `newChanBarriers` as it's not used
anywhere.

* funding: rename method names to clear the funding flow

Slightly refactored the names so it's easier to see which side is
processing what messages.

* lnwallet: sanity check empty pending channel ID

This commit adds a sanity check to make sure an empty pending channel ID
will not be accepted.
2023-10-09 10:58:18 +02:00
Carla Kirk-Cohen
b994b6f9e0 docs: add release notes 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
32ea77b96b lncli: add blinded route cli flags to query routes
Note: This commit can be dropped before merge, it's mostly added
to make the PR easier to manually test against other
implementations that have bolt 12 invoices implemented already!
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
b42a621438 lntest: add coverage for single hop blinded route query routes 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
eb31ff553b lntest/itest: add coverage for querying routes to blinded paths 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
0e179fae1e routing: remove 0-value warning log in pathfinding
Blinded routes can now have "hints" that have zero value edges, so we
remove this log to avoid spamming logs.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
cae22dc862 lnrpc: add blinded payment to QueryRoutes request 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
63b4ac8057 lnrpc/refactor: move query routes request parsing into method 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
c2aebe2aa9 lnrpc: surface blinded payment fields in hops 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
014683ee66 routing: include route blinding fields in blinded portion of path
This commit updates route construction to backfill the fields
required for payment to blinded paths and set amount to forward
and expiry fields to zero for intermediate hops (as is instructed
in the route blinding specification).

We could attempt to do this in the first pass, but that loop
relies on fields like amount to forward and expiry to calculate
each hop backwards, so we keep it simple (stupid) and post
processes the blinded portion, since it's computationally cheap
and more readable.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
c9609b8214 multi: add blinded route to route requests expressed as hints
Add the option to include a blinded route in a route request (exclusive
to including hop hints, because it's incongruous to include both), and
express the route as a chain of hop hints.

Using a chain of hints over a single hint to represent the whole path
allows us to re-use our route construction to fill in a lot of the
path on our behalf.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
48e36d93d4 multi/refactor: add RouteRequest to hold FindRoute parameters
This commit introduces a single struct to hold all of the parameters
that are passed to FindRoute. This cleans up an already overloaded
function signature and prepares us for handling requests with blinded
routes where we need to perform some additional processing on our
para (such as extracting the target node from the blinded path).
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
11a007dc16 routing: account for blinded routes in fee calculation
When we introduce blinded routes, some of our hops are expected
to have zero amounts to forward in their hop payload. This commit
updates our hop fee logic to attribute the full blinded route's
fees to the introduction node. We can't actually know where/how
these fees are distributed, so we collect them all at the
introduction node.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
940b491051 routing: only pack amount and cltv if populated
With the addition of blinded routes, we now need to account for the
possibility that intermediate nodes payloads will not have an amount
and expiry set because that information is provided by the recipient
encrypted data blob. This commit updates our payload packing to only
optionally include those fields.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
fee0e05708 multi: add blinded path TLVs to onion payload / hops
This commit adds the encrypted_data, blinding_point and total_amt_msat
tlvs to the known set of even tlvs for the onion payload. These TLVs
are added in two places (the onion payload and hop struct) because
lnd uses the same set of TLV types for both structs (and they
inherently represent the same thing).

Note: in some places, unit tests intentionally mimic the style
of older tests, so as to be more consistently readable.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen
539a275faa routing: add representation of blinded payments
This commit adds a representation of blinded payments, which include a
blinded path and aggregate routing parameters to be used in payment to
the path.
2023-10-06 16:38:33 -07:00
yyforyongyu
20e7e801c0 routing+channeldb: use HTLCAttempt instead of HTLCAttemptInfo
This commit refactors the params used in lifecycle to prefer
`HTLCAttempt` over `HTLCAttemptInfo`. This change is needed as
`HTLCAttempt` also wraps settled and failure info, which is useful in
the following commits.
2023-10-06 16:38:33 -07:00
yyforyongyu
a6be939bfa routing: add newPaymentLifecycle to properly init lifecycle
This commit adds a new method to properly init a payment lifecycle so we
can easily see the default values used here.
2023-10-06 16:38:33 -07:00
yyforyongyu
34d0e5d4c5 routing+channeldb: make MPPayment into an interface
This commit turns `MPPayment` into an interface inside `routing`. Having
this interface gives us the benefit to write more granular unit tests
inside payment lifecycle. As seen from the modified unit tests, several
hacky ways of testing the `SendPayment` method is now replaced by a mock
over `MPPayment`.
2023-10-06 16:38:33 -07:00
yyforyongyu
c412ab5ccb routing: add exitWithErr to handle error logging 2023-10-06 16:38:33 -07:00
yyforyongyu
e5840f6216 channeldb+routing: add NeedWaitAttempts to decide waiting for attempts
This commit adds a new method, `NeedWaitAttempts`, to properly decide
whether we need to wait for the outcome of htlc attempts based on the
payment's current state.
2023-10-06 16:38:33 -07:00
yyforyongyu
89ac071e56 channeldb: add HasSettledHTLC and PaymentFailed fields to state 2023-10-06 16:38:33 -07:00
yyforyongyu
52c00e8cc4 multi: move payment state handling into MPPayment
This commit moves the struct `paymentState` used in `routing` into
`channeldb` and replaces it with `MPPaymentState`. In the following
commit we'd see the benefit, that we don't need to pass variables back
and forth between the two packages. More importantly, this state is put
closer to its origin, and is strictly updated whenever a payment is read
from disk. This approach is less error-prone comparing to the previous
one, which both the `payment` and `paymentState` need to be updated at
the same time to make sure the data stay consistant in a parallel
environment.
2023-10-06 16:38:31 -07:00
yyforyongyu
bf99e42f8e routing: rename handleSendError to handleSwitchErr
This commit renames the `handleSendError` to be `handleSwitchErr` to
explicitly express that it's handling the error from htlcswitch.
2023-10-06 16:34:47 -07:00
yyforyongyu
42f1c0f1cc routing: refactor createNewPaymentAttempt and sendPaymentAttempt
This commit moves the creations of hop and htlcAdd message from
`createNewPaymentAttempt` to `sendPaymentAttempt` to clean up the code
and further pave the way to decomposite the lifecycle.
2023-10-06 16:34:47 -07:00
yyforyongyu
3c8784dca3 routing: change variable name numShardsInFlight -> numAttemptsInFlight 2023-10-06 16:34:47 -07:00
yyforyongyu
942697ae73 routing: shorten variable name currentState -> ps 2023-10-06 16:34:47 -07:00
yyforyongyu
3259557a46 routing: fix format and add more docs 2023-10-06 16:34:47 -07:00
yyforyongyu
25d82fd62b rpcserver+sweep: fix linter re unused params 2023-10-06 16:34:47 -07:00
yyforyongyu
24fa35ec80 multi: make sure CPFP won't exceed max allowed fee rate
This commit updates the `fee()` method in `weightEstimator` to make sure
when doing CPFP we are not exceeding the max allowed fee rate. In order
to use the max fee rate, we need to modify several methods to pass the
configured value to the estimator.
2023-10-06 16:34:47 -07:00
yyforyongyu
42ff52bbfb sweep: cap to max fee rate instead of failing
This commit caps the estimated fee rate at the configged max fee rate
instead of returning an error.
2023-10-06 16:34:47 -07:00
yyforyongyu
32fccc434b docs: update release note for maxfeerate 2023-10-06 16:34:47 -07:00
yyforyongyu
063fb9dd43 multi: make max fee rate configurable 2023-10-06 16:34:47 -07:00
yyforyongyu
258fe7999b sweep+itest: change MaxFeeRate to use SatPerVbyte 2023-10-06 16:34:47 -07:00
yyforyongyu
bea0ffdf81 chainfee: add new unit SatPerVByte 2023-10-06 16:34:47 -07:00
yyforyongyu
60a44c3f53 sweep: lower the max allowed fee rate for sweeping inputs
This commit changes the DefaultMaxFeeRate from 10,120 sat/vb to 1,000
sat/vb.
2023-10-06 16:34:47 -07:00
yyforyongyu
66b8700c0b multi: add debug logs to catch slow shutdown 2023-10-06 16:34:47 -07:00
yyforyongyu
ba007d9373 itest: fix itest logs upload
When one of the itest tranches fails, because we are running tests in
parallel, other tranches will still be running, which caused 7z to fail
at zipping the logs because race reads. This commit fixes it by making
sure we are waiting other tranches to finish before moving to zipping
and uploading the logs.
2023-10-06 16:34:47 -07:00
Matt Morehouse
3549e329df lnwire: encode channel_update type in onion errors
For about a year [1], the spec has prescribed encoding channel_updates
with their type prefix (0x0102) in onion failure messages. LND can
decode correctly with or without the prefix but hasn't been writing the
prefix during encoding. This commit starts writing the prefix.

[1] https://github.com/lightning/bolts/pull/979
2023-10-06 16:34:47 -07:00
Elle Mouton
53b33c75c4 config: edit error strings to account for signet option 2023-10-06 16:34:47 -07:00
Elle Mouton
1211e7eb7b multi: use "bitcoin" chain name constant
Make use of the `bitcoinChainName` constant instead of re-writing the
"bitcoin" string.
2023-10-06 16:34:47 -07:00
Elle Mouton
8a195ed761 sample-lnd.conf: replace ${chain} with "bitcoin" 2023-10-06 16:34:47 -07:00
Elle Mouton
275201de5b scripts: remove litecoin strings from script 2023-10-06 16:34:47 -07:00
Elle Mouton
a454a8ab44 docs: add release note for 7867 2023-10-06 16:34:47 -07:00
Elle Mouton
23a63ef328 config: update to satisfy linter 2023-10-06 16:34:47 -07:00
Elle Mouton
a7e723e570 lncli: remove chain option from profile 2023-10-06 16:34:47 -07:00
Elle Mouton
7fa05f92f5 htlcswitch: remove Network type 2023-10-06 16:34:47 -07:00
Elle Mouton
77908d6c92 lnrpc: deprecate chains field in GetInfoResponse 2023-10-06 16:34:47 -07:00
Elle Mouton
031dbd7760 multi: remove ChainRegistry 2023-10-06 16:34:47 -07:00
Elle Mouton
2a7fffe441 lnrpc: remove litecoin from lightning.proto 2023-10-06 16:34:47 -07:00
Elle Mouton
215e0f26fe docker: remove litcoin docker scripts 2023-10-06 16:34:47 -07:00
Elle Mouton
0d89a45abe docs: remove Litecoin references from INSTALL.md file 2023-10-06 16:34:47 -07:00
Elle Mouton
be90bcbe46 multi: remove litecoin references and comments 2023-10-06 16:34:47 -07:00
Elle Mouton
a24a4c2996 zpay32: remove litecoin tests 2023-10-06 16:34:47 -07:00
Elle Mouton
94c4642db6 lncfg+config: only allow btcd or bitcoind backends 2023-10-06 16:34:47 -07:00
Elle Mouton
913aa36fe9 chainreg: remove Litecoin support
This commit removes the Litecoin, LtcMode and LitcoinMode members from
the chainreg `Config` struct.
2023-10-06 16:34:47 -07:00
Elle Mouton
a76bdf606b chainreg: let IsTestnet consider bitcoin only 2023-10-06 16:34:47 -07:00
Elle Mouton
d128c18cc5 keychain+chainreg: remove Litecoin CoinType 2023-10-06 16:34:47 -07:00
Elle Mouton
3912d5a0c6 multi: remove Litecoin config options
This commit removes the `Litecoin`, `LtcMode` and `LitecoindMode`
members from the main LND `Config` struct. Since only the bitcoin
blockchain is now supported, this commit also deprecates the
`cfg.Bitcoin.Active` config option.
2023-10-06 16:34:47 -07:00
Elle Mouton
ba93cde07a sample-lnd.conf: remove litecoin conf options 2023-10-06 16:34:47 -07:00
yyforyongyu
f6664d572e docs: update release notes for payment status 2023-10-06 16:34:47 -07:00
yyforyongyu
36f9d7b8db routerrpc: make sure error is transformed into grpc error code 2023-10-06 16:34:47 -07:00
yyforyongyu
17a0a8de06 cmd+lntest: use the new rpc field Payment_INITIATED 2023-10-06 16:34:47 -07:00
yyforyongyu
65879a45e6 lnrpc: update routerrpc to use the new status 2023-10-06 16:34:47 -07:00
yyforyongyu
c175386c4d channeldb+routing: apply method Terminated to decide a payment's terminal state
This commit applies the new method `Terminated`. A side effect from
using this method is, we can now save one query `fetchPayment` inside
`FetchInFlightPayments`.
2023-10-06 16:34:47 -07:00
yyforyongyu
fac6044501 channeldb: add unit test for decidePaymentStatus 2023-10-06 16:34:47 -07:00
yyforyongyu
390f3c8253 channeldb: expand PaymentStatus to explicitly represent payment status
This commit introduces more granular statuses to better determine a
payment's current state. Based on whether there are inflight HTLCs, the
state of each of the HTLCs, and whether the payment is failed, a total
of 5 states are derived, which can give a finer control over what action
to take based on a given state.

Also, `fetchPayment` now uses `decidePaymentStatus`. After applying the
new function, the returned payment status would be different,

```
| inflight | settled | failed | reason |       previous  ->   now          |
|:--------:|:-------:|:------:|:------:|:---------------------------------:|
|   true   |   true  |  true  |   yes  |    StatusInFlight(unchanged)      |
|   true   |   true  |  true  |   no   |    StatusInFlight(unchanged)      |
|   true   |   true  |  false |   yes  |    StatusInFlight(unchanged)      |
|   true   |   true  |  false |   no   |    StatusInFlight(unchanged)      |
|   true   |   false |  true  |   yes  |    StatusInFlight(unchanged)      |
|   true   |   false |  true  |   no   |    StatusInFlight(unchanged)      |
|   true   |   false |  false |   yes  |    StatusInFlight(unchanged)      |
|   true   |   false |  false |   no   |    StatusInFlight(unchanged)      |
|   false  |   true  |  true  |   yes  |    StatusSucceeded(unchanged)     |
|   false  |   true  |  true  |   no   |    StatusSucceeded(unchanged)     |
|   false  |   true  |  false |   yes  |    StatusSucceeded(unchanged)     |
|   false  |   true  |  false |   no   |    StatusSucceeded(unchanged)     |
|   false  |   false |  true  |   yes  |     StatusFailed(unchanged)       |
|   false  |   false |  true  |   no   |     StatusInFlight(unchanged)     |
|   false  |   false |  false |   yes  |     StatusFailed(unchanged)       |
|   false  |   false |  false |   no   |  StatusInFlight -> StatusInitiated|
```
2023-10-06 16:34:47 -07:00
yyforyongyu
09b67af48d channeldb: add method Registrable to decide adding HTLCs
This commit adds a new method, `Registrable`, to help decide whether
adding new HTLCs to a given payment is allowed. A new unit test,
`TestRegistrable` is also added to test it.
2023-10-06 16:34:47 -07:00
yyforyongyu
c71601124a channeldb: fix variable name used in RegisterAttempt
Renamed `p` to `payment` to since it's used by the method's pointer receiver.
2023-10-06 16:34:47 -07:00
yyforyongyu
105c275b91 channeldb: add method updatable to decide updating payments
This commit adds a new method, `updatable`, to help decide whether
updating a given payment is allowed.
2023-10-06 16:34:47 -07:00
yyforyongyu
a6f4f0dfc9 channeldb: add method removable to decide removing payments
This commit adds a new method, `removable`, to help decide whether
deleting a payment is allowed.
2023-10-06 16:34:47 -07:00
yyforyongyu
de33c3e009 channeldb: add method initializable to decide initiating payment
This commit adds a new method, `initializable`, to help decide whether
initiating a payment is allowed.
2023-10-06 16:34:47 -07:00
yyforyongyu
30fd29371c channeldb: add new payment status StatusInitiated
This commit adds a new payment status, `StatusInitiated`, to properly
represent the state where a payment is newly created without attempting
any HTLCs. Since the `PaymentStatus` is a memory representation of a
given payment's status, the enum used for the statuses are directly
updated.
2023-10-06 16:34:47 -07:00
yyforyongyu
6be3817eed channeldb: return error when payment is not initialized
This commit changes `fetchPaymentStatus` to return an error when the
payment creation info bucket cannot be found. Instead of using the
ambiguous status `StatusUnknown`, we tell the callsite explictly that
there's no such payment. This also means the vague `StatusUnknown` can
now be removed as it has multiple meanings.
2023-10-06 16:34:47 -07:00
yyforyongyu
21cecc40e1 channeldb: return error when payment is not found in duplicate payments
We also update the legacy code to return an error when the payment is
not found.
2023-10-06 16:34:47 -07:00
Suheb
b7d1c6666f docs/release-notes: add template for 0.18.0
Signed-off-by: saubyk <39208279+saubyk@users.noreply.github.com>
2023-10-06 16:34:47 -07:00
Vincent
80bfd17cf2
docs: add instructions to generate type hints (#8025)
* Add instructions to generate type hints 

Use mypy to generate .pyi files as well. These files are useful for type hinting in IDEs.

* Update python.md

fix lines that got swapped in copy-paste

* remove mypy 

mypy is not a dependency
2023-10-06 16:47:17 +02:00
Oliver Gugger
dce4bb16be
Merge pull request #8063 from guggero/fix-linter
cmd/lncli: fix linter complaint by running make fmt
2023-10-06 13:14:17 +00:00
Oliver Gugger
7ef11e8ae4
cmd/lncli: fix linter complaint by running make fmt 2023-10-05 22:47:02 +02:00
Olaoluwa Osuntokun
92fe545b0a
Merge pull request #8053 from kilrau/fix/lncli-desc
lncli: fix description of connect/disconnect peer
2023-10-05 13:27:46 -07:00
Kilian
682827c7af
lncli: fix description of connect/disconnect peer 2023-10-05 18:13:32 +02:00
Oliver Gugger
31ba616b1c
Merge pull request #7925 from Crypt-iQ/funding_maturity
funding: wait for coinbase maturity before sending channel_ready
2023-10-05 15:26:30 +00:00
Oliver Gugger
563d6d5427
Merge pull request #7970 from bartoli/master
Fix missing space in message
2023-10-05 15:20:14 +00:00
Oliver Gugger
529dc203a5
Merge pull request #8017 from Rooke/master
trivial: Fix spelling errors
2023-10-05 08:42:08 +00:00
Oliver Gugger
3ffd59a8c9
Merge pull request #7998 from bota87/master
sample-lnd.conf: fix typo
2023-10-05 08:06:31 +00:00
bota87
6041f97fb6 sample-lnd.conf: fix typo 2023-10-04 21:59:17 +02:00
Olaoluwa Osuntokun
13e1fd3f09
Merge pull request #8056 from guggero/release-template-link-fix
GitHub: fix link in release template
2023-10-04 11:13:49 -07:00
Oliver Gugger
3b0d918ea4
GitHub: fix link in release template
Fixes #8055.
This PR fixes a broken link in the release page template.
2023-10-04 09:36:51 +02:00
Olaoluwa Osuntokun
2fb150c8fe
build: bump version to v0.17.0
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2023-10-03 10:20:31 -07:00
Olaoluwa Osuntokun
caa9bf9222
Merge pull request #8043 from Roasbeef/0-17-rc6
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
build: bump version to v0.17.0 rc6
2023-09-28 13:45:52 -05:00
Olaoluwa Osuntokun
4e6bb71c0f
build: bump version to v0.17.0 rc6 2023-09-28 12:00:41 -05:00
Olaoluwa Osuntokun
bb7a257359
Merge pull request #8037 from yyforyongyu/fix-weight-calc
lnwallet+rpcserver: fix weight calculation for taproot channels
2023-09-28 11:21:29 -05:00
Olaoluwa Osuntokun
edeb0d7db5
Merge pull request #8041 from Roasbeef/background-peer-prune
peer: launch persistent peer pruning in background goroutine
2023-09-28 11:18:10 -05:00
yyforyongyu
522518922f
lnwallet+rpcserver: fix weight calculation for taproot channels 2023-09-28 19:42:13 +08:00
yyforyongyu
62d240bba1
itest: add testSendDirectPayment
Adds a new test to check direct payments between two nodes. The fee rate
is tuned to 1 sat/vb to catch edge cases.
2023-09-28 19:42:11 +08:00
Olaoluwa Osuntokun
eae9dd07f0
peer: launch persistent peer pruning in background goroutine
This PR is a follow up, to a [follow
up](https://github.com/lightningnetwork/lnd/pull/7938) of an [initial
concurrency issue](https://github.com/lightningnetwork/lnd/pull/7856)
fixed in the peer goroutine.

In #7938, we noticed that the introduction of `p.startReady` can cause
`Disconnect` to block. This happens as `Disconnect` cannot be called
until `p.startReady` has been closed. `Disconnect` is also called from
`InboundPeerConnected` (the case of concurrent peers, so we need to
remove one of the connections) while the main server mutex is held. If
`p.Start` blocks for any reason, then this leads to the deadlock as: we
can't disconnect until we've finished starting, and we can't finish
starting as we need the disconnect caller to exit as it has the mutex.

In this commit, we now make the call to `prunePersistentPeerConnection`
async. The call to `prunePersistentPeerConnection` eventually wants to
grab the server mutex, which triggers the circular waiting scenario
above.

The main learning here is that no calls to the main server mutex path
can block from `p.Start`. This is more or less a stop gap to resolve the
issue initially introduced in v0.16.4. Assuming we want to move forward
with this fix, we should reexamine `p.startReady` all together, and also
revisit attempt to refactor this section of the code to eliminate the
mega mutex in the server in favor of a dedicated event loop.
2023-09-27 21:24:50 -05:00
Olaoluwa Osuntokun
1ebfe95772
Merge pull request #8035 from Roasbeef/0-17-rc5
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
build: bump version to v0.17.0 rc5
2023-09-26 18:21:07 -05:00
Olaoluwa Osuntokun
f63a2b9507
build: bump version to v0.17.0 rc5 2023-09-26 16:11:45 -05:00
Olaoluwa Osuntokun
01a05fdea7
Merge pull request #8031 from guggero/chan-acceptor-taproot-chan
chanacceptor+lnrpc: add simple taproot channel support
2023-09-26 16:08:19 -05:00
Oliver Gugger
d16e7a5eef
itest: add itest for externally funded taproot chans 2023-09-26 21:45:17 +02:00
Oliver Gugger
d94ae3f509
lnrpc+rpcserver: add musig2 to ChanPointShim 2023-09-26 21:45:17 +02:00
Oliver Gugger
ebf98c6d51
chanacceptor: add simple taproot channels 2023-09-26 21:45:16 +02:00
Oliver Gugger
3821baa0c8
Merge pull request #8024 from Roasbeef/htlc-resolver-c-queue
contractcourt: modify the incoming contest resolver to use concurrent…
2023-09-26 16:03:10 +00:00
Olaoluwa Osuntokun
abe888f719
contractcourt: modify the incoming contest resolver to use concurrent queue
In this commit, we modify the incoming contest resolver to use a
concurrent queue. This is meant to ensure that the invoice registry
subscription loop never blocks. This change is meant to be minimal and
implements option `5` as outlined here:
https://github.com/lightningnetwork/lnd/issues/8023.

With this change, the inner loop of the subscription dispatch method in
the invoice registry will no longer block, as the concurrent queue uses
a fixed buffer of a queue, then overflows into another queue when that
gets full.

Fixes https://github.com/lightningnetwork/lnd/issues/7917
2023-09-25 18:48:30 -05:00
Michael Rooke
78d9996620
trivial: Fix spelling errors
- Fixes some spelling in code comments and a couple of function names
2023-09-21 22:35:33 -04:00
eugene
8f20cd82fb
funding: add TestFundingManagerCoinbase test
This tests that the funding manager doesn't immediately consider
a coinbase transaction that is also a funding transaction usable
until the maturity has been reached.
2023-09-21 11:33:42 -04:00
eugene
5e6ebf561b
chanfunding: introduce NewShimIntent for testing
This is needed so that the next commit can create a ShimIntent
without having to export the ShimIntent's fields.
2023-09-21 11:33:42 -04:00
eugene
0cf3552515
funding: wait for coinbase maturity before sending channel_ready 2023-09-21 11:33:38 -04:00
Oliver Gugger
a1b0a7eb02
Merge pull request #8021 from petertodd/2023-09-fix-ots-name
Fix capitalization of OpenTimestamps in release notes
2023-09-21 10:56:46 +00:00
Peter Todd
d5b88dde72
Fix capitalization of OpenTimestamps in release notes 2023-09-21 02:10:14 -04:00
Olaoluwa Osuntokun
ec585431a9
Merge pull request #8004 from Roasbeef/0-17-rc4
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
build: bump version to v0.17.0 rc4
2023-09-18 18:44:29 -07:00
Olaoluwa Osuntokun
8948dfa113
build: bump version to v0.17.0 rc4 2023-09-18 13:58:41 -07:00
Olaoluwa Osuntokun
9f4a8836db
Merge pull request #7981 from ellemouton/handleRogueUpdates
watchtower: handle rogue updates
2023-09-18 13:56:52 -07:00
Olaoluwa Osuntokun
12be6a37a7
Merge branch 'master' into handleRogueUpdates 2023-09-18 13:55:41 -07:00
Olaoluwa Osuntokun
7412482406
Merge pull request #7994 from Roasbeef/remote-signer-musig2-nonces
multi: add ability to specify local nonces for musig2 signer rpc, add itest for remote signer taproot chans
2023-09-18 13:54:14 -07:00
Olaoluwa Osuntokun
2359481226
Merge pull request #7983 from Roasbeef/blocking-and-mutex-profile
lnd+config: add ability to obtain blocking and mutex profiles
2023-09-18 11:45:40 -07:00
Olaoluwa Osuntokun
23a153abae
lnd+config: add ability to obtain blocking and mutex profiles
In this commit, we add the ability to obtain blocking and mutex
profiles. The blocking profile will show which goroutines are
consistently blocked on synchronization primitives like channels, or
I/O. The mutex profile will show which mutexes are very contested.

The blocking profile can be enabled with a new arg: `--blockingprofile`.
The mutex profile can be enabled with a new arg: `--mutexprofile`. These
are both ignored if the profile port isn't set.

Activating these profiles requires the caller to pass in a sampling
rate. For now I've set it just to `1` to test things out. Unfortunately
documentation is rather scarce, so there aren't any good guides re what
these values should be set to. AFAICT, these add more overhead than the
other prowling options, so they shouldn't necessarily be enabled
persistently in production.
2023-09-18 11:44:49 -07:00
Olaoluwa Osuntokun
6c3a55d89c
itest: add remote signer test case for taproot chans
This ensures that taproot chans can be used with the remote signer
configuration.
2023-09-18 11:42:20 -07:00
Olaoluwa Osuntokun
8405590152
lnrpc/signrpc+lnwallet/rpcwallet: expose local nonces over RPC
In this commit, we update the set of protos to accept the local secret
nonces over RPC. This is actually a 97 byte value, as it includes the
two 32 byte nonces, as well as the 33 byte value of the public key of
the signer.

This is needed in order to be able to open taproot channels over the RPC
interface.
2023-09-18 11:42:15 -07:00
Olaoluwa Osuntokun
ce93b236aa
input+lnwallet: modify musig2 interfaces use explicit optional local nonces
In this commit, we modify the musig2 interfaces to instead use an
explicit value for the local nonces. Before this commit, we used the
functional option, but we want to also support specifying this value
over RPC for the remote signer. The functional option pattern is opaque,
so we can't get the nonce value we need. To get around this, we'll just
make this an explicit pointer, then map this to the functional option at
the very last moment.
2023-09-18 11:42:13 -07:00
Olaoluwa Osuntokun
327b0c92bd
Merge pull request #7991 from Roasbeef/ws-bufio-max-msg
lnrpc: increase max message size for ws proxy
2023-09-18 11:33:02 -07:00
Olaoluwa Osuntokun
247c1d8dc8
lnrpc: increase max message size for ws proxy
In this commit, we increase the max message size for the ws proxy. We
have a similar setting for the normal gRPC server which was tuned to be
able to support decoding `GetNetworkInfo` as the channel graph got
larger. We keep the default buffer size of 64 KB, but allow that to be
expanded to up to 4 MB (current value) to decode larger messages.

One alternative would be to modify the `Split` function to break up
larger lines into smaller ones. We'd need to double check that the
libraries at a higher level of abstraction can handle the chunks. The
scan function would look something like:
```go
splitFunc := func(data []byte, eof bool) (int, []byte, error) {
        if len(data) >= chunkSize {
                return chunkSize, data[:chunkSize], nil
        }

        return bufio.ScanLines(data, eof))
}
scanner.Split(splitFunc)
```
2023-09-18 11:32:34 -07:00
Olaoluwa Osuntokun
2d5c0c9b4e
Merge pull request #7985 from Roasbeef/graceful-data-loss-fc
lnwallet+contractcourt: gracefully handle auto force close post data …
2023-09-15 18:30:53 -07:00
Olaoluwa Osuntokun
de54a603b7
lnwallet+contractcourt: gracefully handle auto force close post data loss
In this commit, update the start up logic to gracefully handle a
seemingly rare case. In this case, a peer detects local data loss with a
set of active HTLCs. These HTLCs then eventually expire (they may or may
not actually "exist"), causing a force close decision. Before this PR,
this attempt would fail with a fatal error that can impede start up.

To better handle such a scenario, we'll now catch the error when we fail
to force close due to entering the DLP and instead terminate the state
machine at the broadcast state. When a commitment transaction eventually
confirms, we'll play it as normal.

Fixes https://github.com/lightningnetwork/lnd/issues/7984
2023-09-15 18:29:09 -07:00
Elle Mouton
95c2bfe181
docs: add entry for 7981 2023-09-14 10:33:07 +02:00
Elle Mouton
273b934f62
wtdb+lnrpc: return correct NumAckedUpdates from wtclientrpc 2023-09-14 10:33:04 +02:00
Elle Mouton
2a9339805e
watchtower: account for rogue updates
In this commit, we introduce the concept of a rogue update. An update is
rogue if we need to ACK it but we have already deleted all the data for
the associated channel due to the channel being closed. In this case, we
now no longer error out and instead keep count of how many rogue updates
a session has backed-up.
2023-09-14 10:33:02 +02:00
Elle Mouton
c33cd0ea38
wtdb: refactor getRangesWriteBucket
A pure refactor commit that passes the required buckets to the
`getRangesWriteBucket` instead of re-fetching them.
2023-09-14 10:30:00 +02:00
Elle Mouton
adb87dcfb8
wtclient: demo un-acked update of closed channel bug
This commit adds a new test to the tower client to demonstrate a bug
that can happen if a channel is closed while an update for it has yet to
be acked by the tower server. This will be fixed in an upcomming commit.
2023-09-14 10:28:56 +02:00
Elle Mouton
ff0d8fc619
watchtower: completely remove the mock tower client DB
Remove the use of the mock tower client DB and use the actual bbolt DB
everywhere instead.
2023-09-13 12:21:04 +02:00
Elle Mouton
f889c9b1cc
watchtower: use bbolt db instead of mock DB for client tests
The watchtower client test framework currently uses a mock version of
the tower client DB. This can lead to bugs if the mock DB works slightly
differently to the actual bbolt DB. So this commit ensures that we only
use the bbolt db for the tower client tests. We also increment the
`waitTime` used in the tests a bit to account for the slightly longer DB
read and write times. Doing this switch resulted in one bug being
caught: we were not removing sessions from the in-memory set on deletion
of the session and so that is fixed here too.
2023-09-13 12:13:22 +02:00
Olaoluwa Osuntokun
90effda090
Merge pull request #7977 from Roasbeef/lnd-17-rc3
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
build: bump version to v0.17.0 rc3
2023-09-12 16:27:45 -07:00
Olaoluwa Osuntokun
1628240960
build: bump version to v0.17.0 rc3 2023-09-12 15:13:40 -07:00
Olaoluwa Osuntokun
8c53620021
Merge pull request #7966 from yyforyongyu/add-force-sweep-outgoing
contractcourt: make sure we force sweep outgoing htlcs
2023-09-12 10:12:49 -07:00
Olaoluwa Osuntokun
c77192a64d
Merge pull request #7960 from Roasbeef/update-kv-db
build: update to kvdb v1.4.3
2023-09-12 10:07:32 -07:00
Olaoluwa Osuntokun
0c815af7ff
build: update lnd sub modules, and btcd + btcutil 2023-09-11 20:35:06 -07:00
Olaoluwa Osuntokun
bb67131ce5
kvdb/sqlbase: use positive+negative build tags for new sql error parsing
In this commit, we use exhaustive build tags to ensure that we can
always build the `sqlbase` package, independent of the set build tags.
To do this, we move the type declarations _into_ the parsing functions.
This then allows us to create two versions for each db: with the db, and
without it.

To avoid a module tag round trip to get this working, we use a local
replace for now. Once this is merged in, we can do the tag (along side
rc3), then remove the replace.
2023-09-11 20:35:01 -07:00
Olaoluwa Osuntokun
30eb90d901
build: update to kvdb v1.4.3
We needed a tag after updating the module with retry for
sqlite/postgres.
2023-09-11 20:34:58 -07:00
bartoli
92059a5278
Update channel.go
Fix missing space between words
2023-09-09 17:56:34 +02:00
yyforyongyu
8787c6c227
contractcourt: make sure we force sweep outgoing htlcs 2023-09-08 20:30:43 +08:00
Matt Morehouse
5863b9f2fc
htlcswitch: fuzz hop.Payload and route.Hop
hop.Payload and route.Hop are analogs, with onion payloads encoded from
route.Hops and decoded to hop.Payloads. For checking equality of
encoding/decoding, we implement a helper function to convert
hop.Payloads into route.Hops.
2023-09-07 17:15:43 -05:00
Matt Morehouse
9c51bea790
htlcswitch: fuzz lightning-onion onions and payloads
Fuzz tests for:
- HopData
- HopPayload
- OnionPacket
2023-09-07 17:15:40 -05:00
rockstardev
f1c2739118 Add watchtowerrpc to install tags
Co-authored-by: d11n <mail@dennisreimann.de>
2023-09-06 15:44:35 -05:00
Olaoluwa Osuntokun
fd58cbfe6b
Merge pull request #7954 from yyforyongyu/fix-chainfee-unit-test
multi: fix unit test flakes
2023-09-05 15:46:56 -07:00
Olaoluwa Osuntokun
84b2f2d0f8
Merge pull request #7955 from yyforyongyu/fix-rand-retry-delay
kvdb/sqlbase: fix params used in `randRetryDelay`
2023-09-05 15:44:49 -07:00
yyforyongyu
c568ba9fa2
github+Makefile: add new action make tidy-module-check
This commit adds `tidy-module` and `tidy-module-check` to make sure the
modules are always tidy.
2023-09-06 02:48:13 +08:00
yyforyongyu
8813bc7ba8
kvdb/sqlbase: fix build errors
We copy the `sqldb/sqlerrors.go` into `kvdb/sqlbase` to avoid import
cycles.
2023-09-06 02:48:12 +08:00
yyforyongyu
5296509474
Makefile+action: add make unit-module to test submodules
This commit adds a new command `make unit-module` to run unit tests for
submodules to avoid future build errors.
2023-09-06 02:47:55 +08:00
yyforyongyu
08f4940e88
kvdb/sqlbase: fix params used in randRetryDelay 2023-09-06 02:47:55 +08:00
Oliver Gugger
f7cb44382e
Merge pull request #7944 from positiveblue/docker-build-img
multi: bump Go versions
2023-09-05 18:47:24 +00:00
positiveblue
49e099f0a0
lnrpc: run make rpc
The docker image have been updated so we are using another protobuf
version to generate the files. The generate files include the version of
the compiler used to creating them, so we need this commit to pass the
`rpc-check` step in our CI.
2023-09-05 10:11:51 -07:00
positiveblue
09d21345e1
multi: bump Go version
Bump all build go versions to v1.21.0
Bump the minimum build package version to v1.19.0

Debian "buster" is not longer supported. Security updates have been
discontinued since June 30th 2022. We will build using the latest
version, "bookworm".
2023-09-05 10:11:42 -07:00
Oliver Gugger
4d2481a0c3
Merge pull request #7957 from yyforyongyu/workspace-sync
gomod: sync versions for submodules
2023-09-05 13:05:35 +02:00
yyforyongyu
50f2c277d7
aezeed: fix flake in TestDecipherIncorrectMnemonic 2023-09-05 07:44:02 +08:00
yyforyongyu
a252cb4528
contractcourt: fix test flake in TestTaprootBriefcase
When the numTweaks is zero, we should return a nil instead of
initializing an empty map as we'd get the following error,

```
Diff:
--- Expected
+++ Actual
@@ -11007,4 +11007,3 @@
},
-  BreachedHtlcTweaks: (contractcourt.htlcTapTweaks) {
-  },
+  BreachedHtlcTweaks: (contractcourt.htlcTapTweaks) <nil>,
```
2023-09-05 07:44:02 +08:00
yyforyongyu
1968034075
chainntnfs: fix testHistoricalConfDetailsTxIndex
Fix the following uint test flake,
```
--- FAIL: TestHistoricalConfDetailsTxIndex (0.00s)
    --- FAIL: TestHistoricalConfDetailsTxIndex/rpc_polling_enabled (1.16s)
        bitcoind_test.go:174: should have found the transaction within the mempool, but did not: TxNotFoundIndex
FAIL
```
2023-09-05 07:44:01 +08:00
yyforyongyu
d8924d26ce
chainfee: fix unit test for WebAPIEstimator 2023-09-05 07:44:01 +08:00
yyforyongyu
68e6cd5c2e
gomod: run go work sync to sync modules
This commit is the result of running `go work sync` and `go mod tidy`
that syncs module versions for all submodules.
2023-09-05 07:27:20 +08:00
yyforyongyu
61d882b999
gomod: fix version conflict in golang.org/x/time
This commit fixes the error,
```
go: version constraints conflict:
	github.com/dhui/dktest@v0.3.16 requires golang.org/x/time@v0.0.0-20220224211638-0e9765cccd65, but golang.org/x/time@v0.0.0-20210220033141-f8bda1e9f3ba is requested
	github.com/golang-migrate/migrate/v4@v4.16.1 requires golang.org/x/time@v0.0.0-20220224211638-0e9765cccd65, but golang.org/x/time@v0.0.0-20210220033141-f8bda1e9f3ba is requested
```

By calling `go get golang.org/x/time@v0.0.0-20220224211638-0e9765cccd65"
and `go mod tidy`.
2023-09-05 06:38:12 +08:00
yyforyongyu
036f2a0f03
kvdb: fix version conflict in github.com/ulikunitz/xz
Fix the following conflict,
```
go: conflicting replacements for github.com/ulikunitz/xz:
	github.com/ulikunitz/xz@v0.5.11
	github.com/ulikunitz/xz@v0.5.8
```
2023-09-05 05:48:36 +08:00
Olaoluwa Osuntokun
13568fd5b0
build: bump version to v0.17.0-rc2 (#7942)
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2023-08-30 20:14:25 -07:00
Olaoluwa Osuntokun
01c64712a3
multi: ensure link is always torn down due to db failures, add exponential back off for sql-kvdb failures (#7927)
* lnwallet: fix log output msg

The log message is off by one.

* htlcswitch: fail channel when revoking it fails.

When the revocation of a channel state fails after receiving a new
CommitmentSigned msg we have to fail the channel otherwise we
continue with an unclean state.

* docs: update release-docs

* htlcswitch: tear down connection if revocation processing fails

If we couldn't revoke due to a DB error, then we want to also tear down
the connection, as we don't want the other party to continue to send
updates. That may lead to de-sync'd state an eventual force close.
Otherwise, the database might be able to recover come the next
reconnection attempt.

* kvdb: use sql.LevelSerializable for all backends

In this commit, we modify the default isolation level to be
`sql.LevelSerializable. This is the strictness isolation type for
postgres. For sqlite, there's only ever a single writer, so this doesn't
apply directly.

* kvdb/sqlbase: add randomized exponential backoff for serialization failures

In this commit, we add randomized exponential backoff for serialization
failures. For postgres, we''ll his this any time a transaction set fails
to be linearized. For sqlite, we'll his this if we have many writers
trying to grab the write lock at time same time, manifesting as a
`SQLITE_BUSY` error code.

As is, we'll retry up to 10 times, waiting a minimum of 50 miliseconds
between each attempt, up to 5 seconds without any delay at all. For
sqlite, this is also bounded by the busy timeout set, which applies on
top of this retry logic (block for busy timeout seconds, then apply this
back off logic).

* docs/release-notes: add entry for sqlite/postgres tx retry

---------

Co-authored-by: ziggie <ziggie1984@protonmail.com>
2023-08-30 16:48:00 -07:00
Olaoluwa Osuntokun
eb0d8af645
peer: eliminate circular waiting by calling maybeSendNodeAnn async (#7938)
In this commit, we attempt to fix circular waiting scenario introduced
inadvertently when [fixing a race condition
scenario](https://github.com/lightningnetwork/lnd/pull/7856). With that
PR, we added a new channel that would block `Disconnect`, and
`WaitForDisconnect` to ensure that only until the `Start` method has
finished would those calls be allowed to succeed.

The issue is that if the server is trying to disconnect a peer due to a
concurrent connection, but `Start` is blocked on `maybeSendNodeAnn`,
which then wants to grab the main server mutex, then `Start` can never
exit, which causes `startReady` to never be closed, which then causes
the server to be blocked.

This PR attempts to fix the issue by calling `maybeSendNodeAnn` in a
goroutine, so it can grab the server mutex and not block the `Start`
method.

Fixes https://github.com/lightningnetwork/lnd/issues/7924

Fixes https://github.com/lightningnetwork/lnd/issues/7928

Fixes https://github.com/lightningnetwork/lnd/issues/7866
2023-08-30 15:47:45 -07:00
Yong
d24f12bd0b
contractcourt: fix potential panic during startup (#7936)
Related to this fix 5a28582719, we may not
have the historical data for old channels so we skip it here too.
2023-08-29 10:27:09 -07:00
Oliver Gugger
73bf21e0f2
Merge pull request #7932 from guggero/psbt-funding-taproot-chans
psbt: fix channel funding address for simple taproot channels
2023-08-29 14:06:17 +02:00
Oliver Gugger
590dc0c3b3
itest: unify PSBT channel funding tests, add taproot
With this commit we unify three existing PSBT channel funding
integration tests into a single one with the goal of testing all three
cases with simple taproot channels as well.
2023-08-29 10:57:38 +02:00
Oliver Gugger
646444cdfe
chanfunding: fix PSBT funding for taproot chans 2023-08-29 10:57:38 +02:00
Oliver Gugger
c6fcceb35b
Merge pull request #7909 from patrickReiis/master
itest: fix typo [skip ci]
2023-08-28 16:39:40 +02:00
Jamal James
cbb4c27a44
docs: fix simple-taproot-channels typo [skip ci] (#7926) 2023-08-25 15:48:37 -07:00
Elle
15d2ff0c4d
netann+docs: remove nil value from variadic list (#7922)
The nil value in the variadic list causes a panic when the variadic
parameters are iterated over.
2023-08-24 11:47:42 -07:00
Olaoluwa Osuntokun
dde1495e1d
build: bump Go version to v1.21.0, lnd version to v0.17.0 rc1 (#7914)
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
* build: update Go version to 1.21.0

* build: bump version to v0.17.0 rc1
2023-08-23 17:33:11 -07:00
Suheb
c07ec0462c
docs/release-notes: update 0.17 release notes to new format (#7907)
Added a table of contents at the top and various sections to navigate to, to make it easy to parse and read the release notes.
2023-08-23 15:21:20 -07:00
Olaoluwa Osuntokun
251bcad899
Merge pull request #7877 from ellemouton/bumpOnion
multi: update lightning-onion version
2023-08-23 12:22:15 -07:00
P. Reis
5fc77b6ee5
doc: fix typo
Changed "chanenl" to "channel"
2023-08-23 12:55:01 -03:00
Elle Mouton
dfec4a65cb
multi: update lightning-onion version
Update the lighting-onion dependency to include the lates changes which
support route blinding.
2023-08-23 12:09:53 +02:00
Olaoluwa Osuntokun
e2f5374f67
Merge pull request #7904 from lightningnetwork/simple-taproot-chans-staging
multi: merge simple taproot channels staging branch into master
2023-08-22 19:24:31 -07:00
Olaoluwa Osuntokun
a87631c957
itest: add case for taproot chans to htlc timeout resolver itests 2023-08-22 17:43:51 -07:00
Olaoluwa Osuntokun
92da6b1d44
multi: fix linter warnings with updated linter 2023-08-22 16:34:47 -07:00
Olaoluwa Osuntokun
7506383074
itest: update zero conf multi-hop tests to remove extra blocks mined
In the master branch, the blocks are mined earlier, so we don't need to
mine an extra set.
2023-08-22 16:34:42 -07:00
Olaoluwa Osuntokun
562163ea3d
docs/release-notes: add release notes for taproot chans 2023-08-22 16:34:39 -07:00
Olaoluwa Osuntokun
3f8d33d7ab
funding: add SIMPLE_TAPROOT case to TestCommitmentTypeFundmaxSanityCheck 2023-08-22 16:34:36 -07:00
Olaoluwa Osuntokun
5f1e0bf772
multi: add new SCB version for the taproot chan type 2023-08-22 16:34:34 -07:00
Olaoluwa Osuntokun
94f45b2b82
itest: use explicit chan type negotiation for taproot chan cases
The prior commit removed implicit negotiation, so we'll need to make
sure to use the explicit chan type feature vector when we go to
negotiate.
2023-08-22 16:34:31 -07:00
Olaoluwa Osuntokun
384b1b1c12
feature: use +100 staging bit for taproot channels
In this commit, we carry out a new notion introduced during a recent
spec meeting to use a feature bit plus 100 before the feature has been
finalized in the spec.

We split into the Final and Staging bits.
2023-08-22 16:34:28 -07:00
Olaoluwa Osuntokun
fcbf6f2483
lnwallet: add taproot case to TestForceClose
This adds some extra assertions to ensure things like the taproot
commitment weight estimation is correct.
2023-08-22 16:34:25 -07:00
Olaoluwa Osuntokun
ff055ce0a4
lnwallet: uniformly use sighash default everywhere for taproot chans
We use a helper function to ensure that anytime we're about to make a
normal sighash, we consult the channel type to check if we should use
the default value or sighash all explicitly.
2023-08-22 16:34:23 -07:00
Olaoluwa Osuntokun
dd05dd55d4
funding: add explicit chan type support for zeroconf+scid+taproot
We also remove the old implicit negotiation as well, as we'll be
updating tests to use explciit when required.
2023-08-22 16:34:20 -07:00
Olaoluwa Osuntokun
4b65c71213
lnwallet: for musig2 coop close fee estimation
Co-op close for musig2 chans needs to use the proper witness size.
2023-08-22 16:34:17 -07:00
Olaoluwa Osuntokun
a2b277cf1d
multi: fix linter errors 2023-08-22 16:34:15 -07:00
Olaoluwa Osuntokun
d3e4bca772
itest: add taproot support to revocation itests 2023-08-22 16:34:12 -07:00
Olaoluwa Osuntokun
7c5be4d056
itest: add taproot support for all variants of runMultiHopHtlcClaimTest 2023-08-22 16:34:06 -07:00
Olaoluwa Osuntokun
5739061f13
lnwallet: add first+second level taptweaks to htlc retribution
The first and second level taptweaks need to be stored in order to
ensure the breach arb can play revocations at both the first and second
level.
2023-08-22 16:34:04 -07:00
Olaoluwa Osuntokun
28c086f1fc
htlcswitch: remove call to InitRemoteMusigNonces
In this commit, we remove the internal call to `InitRemoteMusigNonces`.
We don't need this since when we go to process the remote party's chan
reest message, we'll already call this method. Otherwise, we'll get an
error here since the pending verification nonce has been wiped out after
each call.
2023-08-22 16:34:02 -07:00
Olaoluwa Osuntokun
5379823346
itest: add taproot chans to testChannelForceClosure 2023-08-22 16:34:00 -07:00
Olaoluwa Osuntokun
82a5addd3d
lnwallet: add error logging to getSignedCommitTx 2023-08-22 16:33:58 -07:00
Olaoluwa Osuntokun
da3ab2728b
itest: add taproot chan support to basic channel funding
We keep in line with the existing test that uses implicit negotiation.
In the future, we should modify to also have explicit negotiation as
well.
2023-08-22 16:33:56 -07:00
Olaoluwa Osuntokun
2b952af629
feature+lncfg: restore simple- prefix for taproot chans arg 2023-08-22 16:33:54 -07:00
Olaoluwa Osuntokun
d98136e850
funding: add support for implicit negotiation for taproot chans
Otherwise, in the itests (which are mainly based on implicit
negotiation), we won't try to open taproot chans when we actually need
to.

We may want to revisit this however, since it may lock in parties trying
to use the defaults that aren't currently setting the explicit commit
type during funding.
2023-08-22 16:33:52 -07:00
Olaoluwa Osuntokun
bed9455d60
lnwallet: fix taproot co-op close nonce bug
The local nonce needs to be the one that's finalized to simulate us
receiving the remote nonce, then generating the local nonce in a JIT
style.
2023-08-22 16:33:50 -07:00
Olaoluwa Osuntokun
93e8428b6b
lnwallet: for taproot channels allow the co-op close tx to be RBF'd
This is a preparatory change for the upcoming "simple channel close"
feature which'll utilize RBF to allow either side to resign the co-op
close transaction for broadcast at any point.
2023-08-22 16:33:48 -07:00
Olaoluwa Osuntokun
4b0139c9ba
lnwallet: update channel state machine to use new ScriptDescriptor interface
In this commit, we update the channel state machine to use the new
ScriptDescriptor interface. This fixes some subtle issues with the
existing commits, as for p2wsh we always sign the same witness script,
but for p2tr, the witness script differs depending on which branch is
taken.

With the new abstractions, we can treat p2wsh and p2tr as the same
mostly, right up until we need to obtain a control block or a tap tweak.

All tests have been updated accordingly.
2023-08-22 16:33:46 -07:00
Olaoluwa Osuntokun
a244a30f32
input: create new ScriptDesciptor interface
In this commit, we add a new interface, the `ScriptDesciptor` to
abstract over details of a given output script. The purpose of this
interface, and the taproot superset, is to be able to paper over the
differences of a p2wsh vs a p2tr output. With this new interface, we can
treat them as the same, but then use a type assertion to get at any
control block related methods if needed.
2023-08-22 16:33:44 -07:00
Olaoluwa Osuntokun
7e2d04a310
contractcourt: update UTXO nursery to support taproot chans 2023-08-22 16:33:42 -07:00
Olaoluwa Osuntokun
cdcde6e0a5
contractcourt: update breach arbiter to support taproot chans
In this commit, we update the breach arb to support taproot channels. We
utilize the new taproot briefcase space to store both control blocks,
and also the first+second level scripts for the set of HTLCs.
2023-08-22 16:33:40 -07:00
Olaoluwa Osuntokun
df2a2d83ea
contractcourt: update htlcSuccessResolver for taproot chans 2023-08-22 16:33:38 -07:00
Olaoluwa Osuntokun
23f7ee39c7
contractcourt: update htlcTimeoutResolver for taproot chans 2023-08-22 16:33:36 -07:00
Olaoluwa Osuntokun
47f70dae3a
contractcourt: update commitSweepResolver for taproot chans 2023-08-22 16:33:34 -07:00
Olaoluwa Osuntokun
2010239b63
contractcourt: update the anchor resolver for taproot chans 2023-08-22 16:33:32 -07:00
Olaoluwa Osuntokun
47d4eb341d
contractcourt: store new taproot resolution info in new key
We pull the information from the sign descriptors and store them in the
resolutions. However, the resolvers created end up duplicating the
resolution data, so we update the sign descs as needed during start up.
2023-08-22 16:33:30 -07:00
Olaoluwa Osuntokun
a1788fe4a2
contractcourt: add new taproot briefcase to store ctrl block and tap tweaks
In this commit, we add a new taproot specific briefcase to store the
control block and tap tweaks for all taproot outputs. We chose this
route as many of the existing fields are serialized in line, so we
aren't able to serialize this new taproot specific information in the
existing briefcase.
2023-08-22 16:33:27 -07:00
Olaoluwa Osuntokun
fa07a2d248
input: HtlcSucceedInput to support sweeping for taproot chans 2023-08-22 16:33:25 -07:00
Olaoluwa Osuntokun
b00cf25590
input: add new HtlcSecondLevelAnchorInput types for taproot chans 2023-08-22 16:33:22 -07:00
Olaoluwa Osuntokun
2b92c15ca9
input: update the mock signer for the musig2 API changes 2023-08-22 16:33:19 -07:00
Olaoluwa Osuntokun
b39f5884ad
input: update IsHtlcSpendRevoke for taproot chans
For taproot channels, the revocation witness is a single sig as the
keyspend path is used.
2023-08-22 16:33:17 -07:00
Olaoluwa Osuntokun
995e6cd66b
lnwallet: update NewBreachRetribution to handle taproot chans
For our local output, we need a valid control block. To sweep the remote
output, we use the taptweak so we can spend the keyspend path.
2023-08-22 16:33:14 -07:00
Olaoluwa Osuntokun
1f887a1b14
lnwallet: add support for taproot chans to createHtlcRetribution
As these are revoked HTLCs, we need to set the taptweak since the
revocation case is just a keyspend.
2023-08-22 16:33:12 -07:00
Olaoluwa Osuntokun
52b122a8bb
lnwallet: NewUnilateralCloseSummary for local taproot output sweep 2023-08-22 16:33:09 -07:00
Olaoluwa Osuntokun
b72f368673
lnwallet: update NewLocalForceCloseSummary for local taproot output sweep 2023-08-22 16:33:07 -07:00
Olaoluwa Osuntokun
ad5305b99c
lnwallet: update newIncomingHtlcResolution for taproot chans
Similar to the outgoing resolutions, the main change here is ensuring
the sign method and control block are properly set for the various spend
types.
2023-08-22 16:33:04 -07:00
Olaoluwa Osuntokun
a0a3c7aa89
lnwallet: update newOutgoingHtlcResolution for taproot chans
For taproot channels, we need to thread through the control block in the
sign descriptor. We also ensure that the proper sign method is set. We
leverage the new input.Signature generalization be able to support
handling both schnorr and ECDSA signatures for the second level output.
2023-08-22 16:33:01 -07:00
Olaoluwa Osuntokun
ee59e3f181
lnwallet: update NewAnchorResolution to support taproot anchors 2023-08-22 16:32:59 -07:00
Olaoluwa Osuntokun
a128b74dc1
lnwallet: add tapscript tree to ScriptInfo
In this commit, we add the tapscript tree to the ScriptInfo struct, as
in many cases the caller needs the tree in order to generate the control
block or obtain the taptweak which is needed to spend revoked outputs.
2023-08-22 16:32:56 -07:00
Olaoluwa Osuntokun
a74c30fbdd
lnwallet: update HtlcSuccessFee + HtlcTimeoutFee for taproot chans
There's no fee, as taproot channels are always zero fee HTLC.
2023-08-22 16:32:54 -07:00
Olaoluwa Osuntokun
ebc61818a3
lnwallet: update CommitWeight to return taproot commit weight 2023-08-22 16:32:51 -07:00
Olaoluwa Osuntokun
8d0435397d
input: add new SecondLevelScriptTree to support second level HTLC spends 2023-08-22 16:32:48 -07:00
Olaoluwa Osuntokun
4c7da7df49
input: update all taproot script spends to optionally make the ctrl block
In this commit, we update all the taproot scripts spends to optionally
make the control block. This is useful in cases where we've already
created the control block, or may not have the items needed to construct
it in the first place.

We also add the control block to the sign descriptor itself.
2023-08-22 16:32:46 -07:00
Olaoluwa Osuntokun
405a435a84
input: add weight estimation + tests for all taproot witness gen types 2023-08-22 16:32:44 -07:00
Olaoluwa Osuntokun
d3c7c51f7e
input: add new witness gen types for all taproot spends 2023-08-22 16:32:42 -07:00
Olaoluwa Osuntokun
0d3bed66c0
lnwallet: properly set witness script in CommitScriptToSelf 2023-08-22 16:32:40 -07:00
Olaoluwa Osuntokun
a5f67b451e
input: add new ParseSignature helper func 2023-08-22 16:32:37 -07:00
Olaoluwa Osuntokun
7323e9373b
feature+lncfg: add new CLI flag to opt into taproot chans 2023-08-22 16:32:35 -07:00
Olaoluwa Osuntokun
6dc43ad253
cmd/lncli: add new taproot channel type for openchannel 2023-08-22 16:32:33 -07:00
Olaoluwa Osuntokun
4aa9bba4ef
rpc: update open channel parsing to detect taproot chans 2023-08-22 16:32:31 -07:00
Olaoluwa Osuntokun
7ceb46d653
lnrpc: add new channel type for taproot channels 2023-08-22 16:32:29 -07:00
Olaoluwa Osuntokun
9f6ed65d80
funding: add unit tests for reg+zero conf taproot chans 2023-08-22 16:32:27 -07:00
Olaoluwa Osuntokun
91e855d59a
lntest: update SingleMockSigner to support musig2 2023-08-22 16:32:25 -07:00
Olaoluwa Osuntokun
d4a6be1c9f
contractcourt: for taproot channels, wait for conf in closeObserver
This ensures that we end up playing the target output on chain for
taproot channels.
2023-08-22 16:32:23 -07:00
Olaoluwa Osuntokun
638516879f
lnwallet: add extra sanity check in VerifyCommitSig 2023-08-22 16:32:20 -07:00
Olaoluwa Osuntokun
410baae0c7
lnwallet: generate local nonces if non passed in for taproot chans
This ensures that when loading the channel again after a normal chan
reest, we generate the local nonces, which ensures we can then process
nonces the remote party sends us in their chan reest message.
2023-08-22 16:32:18 -07:00
Olaoluwa Osuntokun
9ce817511d
contractcourt: update chain watcher to understand the taproot pkscript
In this commit, we update the chain watcher to be able to generate the
correct pkScript so it can register for confirmation and spend
notifications for taproot channels.
2023-08-22 16:32:15 -07:00
Olaoluwa Osuntokun
e8b6e0ca45
htlcswitch: add awareness of new partial sig fields and musig2 nonces 2023-08-22 16:32:13 -07:00
Olaoluwa Osuntokun
7d7513aa3c
routing+funding: add new makeFundingScript to support reg and taproot channels
In this commit, we start to set _internally_ a new feature bit in the
channel announcements we generate. As these taproot channels can only be
unadvertised, this will never actually leak to the public network. The
funding manager will then set this field to allow the router to properly
validate these channels.
2023-08-22 16:32:10 -07:00
Olaoluwa Osuntokun
15978a8691
funding+peer: add support for new musig2 channel funding flow
In this commit, we add support for the new musig2 channel funding flow.
This flow is identical to the existing flow, but not both sides need to
exchange local nonces up front, and then signatures sent are now partial
signatures instead of regular signatures.

The funding manager also gains some new state of the local nonces it
needs to generate in order to send the funding locked message, and also
process the funding locked message from the remote party.

In order to allow the funding manger to generate the nonces that need to
be applied to each channel, then AddNewChannel method has been modified
to accept a set of options that the peer will then use to bind the
nonces to a new channel.
2023-08-22 16:32:07 -07:00
Olaoluwa Osuntokun
a8416300dd
funding: update explicitNegotiateCommitmentType to recognize taproot chans 2023-08-22 16:32:05 -07:00
Olaoluwa Osuntokun
32f4f4cea7
feature: add SimpleTaprootChannelsOptional to the set of default chan types 2023-08-22 16:32:02 -07:00
Olaoluwa Osuntokun
aaba144804
multi: fix linter warnings 2023-08-22 16:32:00 -07:00
Olaoluwa Osuntokun
da1282c17e
lnwallet: refactor revocation tests to test for tweakless+taproot 2023-08-22 16:31:57 -07:00
Olaoluwa Osuntokun
3270a29e3e
lnwallet: handle nonce init in ProcessChanSyncMsg
In this commit, we update the logic to handle nonce init in
ProcessChanSyncMsg. Once a channel is already open, this is where we'll
get the new nonce data from the remote party we'll use to gain the nonce
we need to sign for their next state.
2023-08-22 16:31:54 -07:00
Olaoluwa Osuntokun
911becb431
lnwallet: move nonce generation into generateRevocation
Before this commit, we would conditionally generate nonces in
RevokeCurrentCommitment. We move this to generateRevocation as this is
called when doing channel sync, and we want to make sure we send the
correct set of nonces.
2023-08-22 16:31:52 -07:00
Olaoluwa Osuntokun
76f0f67b7c
channeldb: update ChanSyncMsg to populate nonce info
In this commit, we update the ChanSyncMsg to populate nonce information.
With this change, we can now hide nonce generation further down in the
pipeline and ensure that all callers will have the expected fields
populated.
2023-08-22 16:31:49 -07:00
Olaoluwa Osuntokun
349eee3263
input: ensure sessionOpts is properly threaded through 2023-08-22 16:31:47 -07:00
Olaoluwa Osuntokun
d2bc4f29e1
lnwallet: fix bug in deriveMusig2Shachain
In this commit, we fix a bug in the `deriveMusig2Shachain` function
where it didn't actually use the passed in revocation root as part of
the hmac invocation.

We also modify the function to be more generally useable as well, as now
the caller can just pass in the revocation root things should be derived
from.
2023-08-22 16:31:44 -07:00
Olaoluwa Osuntokun
83f1bd4717
lnwallet: return structured error from VerifyCommitSig 2023-08-22 16:31:41 -07:00
Olaoluwa Osuntokun
3879138018
lnwallet: update internal co-op close flow to support musig2 keyspend
In this commit, we update the co-op close flow to support the new musig2
keyspend flow. We'll use some new functional options to allow a caller
to pass in an active musig2 session. If this is present, then we'll use
that to complete the musig2 flow by signing with a partial signature,
and then ultimately combining the signatures at the end.
2023-08-22 16:31:38 -07:00
Olaoluwa Osuntokun
c9fc508083
lnwallet/chanvalidate: update ValidateChannel to recognize taproot chans 2023-08-22 16:31:36 -07:00
Olaoluwa Osuntokun
b38f9000d5
lnwallet: update testAddSettleWorkflow to test the new taproot flow 2023-08-22 16:31:33 -07:00
Olaoluwa Osuntokun
39d5dffd56
lnwallet: update genHtlcSigValidationJobs to be taproot aware
In this commit, we update the genHtlcSigValidationJobs function to be
taproot aware. As we actually need a schnorr signature for the taproot
validation, we need to coerce the entire wire type into a schnorr sig
with the ForceSchnorr() method.
2023-08-22 16:31:31 -07:00
Olaoluwa Osuntokun
5336f03ac6
lnwallet: update to genRemoteHtlcSigJobs to generate taproot jobs
In this commit, we update the genRemoteHtlcSigJobs function to be able
to generate taproot jobs. We also modify the sigpool to now use a
input.Signature everywhere. This'll allow us to pass around both ECDSA
and Schnorr signatures via the same interface.

We use a tapscript sighash in this case, as all the HTLC spends will
actually be script path spends.
2023-08-22 16:31:28 -07:00
Olaoluwa Osuntokun
ca21c4bdb4
lnwallet: update channel state machine to add musig session initialization
In this commit, we update the channel state machine with a new set of
functional options that can be used to create/set the musig session
state. When a channel is made during the funding process, the set of
nonces we want to use is already known, so we allow them to be passed
in. Similarly, once the channel is confirmed, then we'll need to create
another channel instance that this times carries the newly generated
nonces to send along side funding_locked.

We also add some utility methods to permit callers to properly generate
nonces in the various contexts.
2023-08-22 16:31:25 -07:00
Olaoluwa Osuntokun
d2526c75f4
lnwallet: update genHTLC script to support segwit v0 + v1 (taproot) HTLCs 2023-08-22 16:31:23 -07:00
Olaoluwa Osuntokun
2a22f5b959
lnwallet: update CreateHtlcTimeoutTx+CreateHtlcSuccessTx for taproot 2023-08-22 16:31:20 -07:00
Olaoluwa Osuntokun
11c62e3951
lnwallet+htlcswitch: add NewCommitState struct, modify send/recv sig to accept
In this commit, we add a new NewCommitState struct. This preps us for
the future change wherein a partial signature is also added to the mix.
All related tests and type signatures have also been updated
accordingly.
2023-08-22 16:31:18 -07:00
Olaoluwa Osuntokun
72d41ae408
lnwallet: export MusigCommitType enum
We need to export the enum as it'll now be used in areas such as the
chan closer.
2023-08-22 16:31:15 -07:00
Olaoluwa Osuntokun
a5d8f69516
peer: soft-disable towers with taproot channels
In this commit, we modify the starting logic to note attempt to add a
tower client for taproot channels. Instead, we'll just log that this
isn't available yet.
2023-08-22 16:31:13 -07:00
Olaoluwa Osuntokun
c6308130aa
lnwallet: add test case for musig2 channel funding 2023-08-22 16:31:10 -07:00
Olaoluwa Osuntokun
67ecefaac3
lnwallet: integrate new taproot channels into internal funding flow
In this commit, we build on all the prior commits and integrate the new
taproot channels into the existing internal funding flow. Along the way,
we do some refactoring to unify things like signing and verifying
incoming commitment transaction signatures.

For our local nonce, we use the existing functional option type to
derive the nonce based on the initial shachain pre-image we'll use as
our revocation.
2023-08-22 16:31:07 -07:00
Olaoluwa Osuntokun
9e8b00241f
lnwallet: set new musig2 bool for chanfunding.Request in handleFundingReserveRequest 2023-08-22 16:31:05 -07:00
Olaoluwa Osuntokun
5e511e35fd
lnwallet: update CommitScriptAnchors to add taproot awareness
We also update some of the resolutions (even though they aren't hooked
up yet), as they need to be able to properly re-create the set of
scripts.
2023-08-22 16:31:02 -07:00
Olaoluwa Osuntokun
cb0229d437
lnwallet: update CommitScriptToRemote to add taproot awareness 2023-08-22 16:31:00 -07:00
Olaoluwa Osuntokun
0e7e29455a
lnwallet: update CommitScriptToSelf to add taproot awareness 2023-08-22 16:30:57 -07:00
Olaoluwa Osuntokun
f7ba08e147
lnwallet: add new CommitmentTypeSimpleTaproot chan type
In this commit, we add a new wallet level channel type, along with the
new fields we'll need to accept from both parties within the
contribution messages. In this case, we now have a local nonce, along
with the internal musig session.
2023-08-22 16:30:54 -07:00
Olaoluwa Osuntokun
05b5391614
channeldb: add new db type for taproot channels 2023-08-22 16:30:52 -07:00
Olaoluwa Osuntokun
1ed6439c3a
lnwallet: add initial unit test coverage for musig chan session 2023-08-22 16:30:49 -07:00
Olaoluwa Osuntokun
001c5b0e0b
input: use multmutex to increase concurrency for musig session manager
By using the multimutex here, we'll no longer rely on a single mutex for
the entire musig session set like we used to. Instead, we can use the
session ID to key into a map of mutexes and use those directly.
2023-08-22 16:30:47 -07:00
Olaoluwa Osuntokun
dafc2a3e5a
lnwallet: add new structs to abstract over the asymmetric musig commitment state
In this commit, we add a series of abstractions that'll allow us to
easily do funding and also state updates for the new taproot channels. A
partial session is defined by the knowledge of a verification nonce.
Once the remote party sends a signature, we learn of their signing
nonce, and can then complete a session. By using a JIT nonce approach,
we ensure that the signer can generate their nonces randomly and also
at the very last step to avoid having to maintain state.

For our local nonces, we also have an option to use a counter based
nonce derived from the shachain instead of fully random nonces. This
allows us to not have to store ay additional state. Instead, when we
need to go to broadcast, we can just regenerate the nonce then use that
to broadcast.
2023-08-22 16:30:44 -07:00
Olaoluwa Osuntokun
95d627af4e
lnwallet/chanfunding: update assemblers to support musig2
In this commit, we update the set of intents and assemblers to recognize
musig2. For this change, we use a new bool, `musig2`, then use that to
determine if we need to use the new taproot funding scripts or not.
2023-08-22 16:30:42 -07:00
Olaoluwa Osuntokun
9a65806c09
input+wallet: extract musig2 session management into new module
In this commit, we extract the musig2 session management into a new
module. This allows us to re-use the session logic elsewhere in unit
tests so we don't need to instantiate the entire wallet.
2023-08-22 16:30:39 -07:00
Olaoluwa Osuntokun
4733da5ccb
input: eliminate CSV trick for HTLC outputs 2023-08-22 16:30:36 -07:00
Olaoluwa Osuntokun
6ce7f5d29e
input: use explicit CSV 1 script for to remote output
We undo the prior hack here to make the final script more readable. The
difference is just 1 byte between the two.
2023-08-22 16:30:34 -07:00
Olaoluwa Osuntokun
0c74f894c4
input: fix linter errors 2023-08-22 16:30:31 -07:00
Olaoluwa Osuntokun
8fc8640432
input: use script path for revocation clause for to_local output
In this commit, we modify the to_local script to use a script path for
the revocation scenario. With this change, we ensure that the internal
key is always revealed which means the anchor outputs can still always
be swept.
2023-08-22 16:30:28 -07:00
Olaoluwa Osuntokun
7f05c765c3
input: restore usage of NUMS key for to_remote output
In this commit, we restore usage of the NUMS key for the to remote
output, as this allows a remote party to scan the chain in order to find
their remote output that in emergency recovery scenarios.
2023-08-22 16:30:26 -07:00
Olaoluwa Osuntokun
5e921376c4
input: add exhaustive unit tests for new taproot scripts 2023-08-22 16:30:23 -07:00
Olaoluwa Osuntokun
b8d1596428
input: add new maybeAppendSighashType helper func 2023-08-22 16:30:20 -07:00
Olaoluwa Osuntokun
3393cc182d
input: add spending funcs for second level HTLC tapscript ctrl blocks 2023-08-22 16:30:18 -07:00
Olaoluwa Osuntokun
89a365758a
input: add taproot second level HTLC scripts 2023-08-22 16:30:15 -07:00
Olaoluwa Osuntokun
d8fa0516e9
input: add spending funcs for taproot receiver HTLC ctrl blocks 2023-08-22 16:30:13 -07:00
Olaoluwa Osuntokun
b2d244cf2a
input: add taproot script funcs for receiver HTLCs 2023-08-22 16:30:10 -07:00
Olaoluwa Osuntokun
164b60675b
input: add spending funcs for taproot sender HTLCs 2023-08-22 16:30:07 -07:00
Olaoluwa Osuntokun
7e7de11cfd
input: add tapscript utils for the sender HTLC script
Unlike the old HTLC scripts, we now need to handle the various control
block interactions. As is, we opt to simply re-compute the entire tree
when needed, as the tree only has two leaves.
2023-08-22 16:30:05 -07:00
Olaoluwa Osuntokun
734dc0f085
input: add TaprootOutputKeyAnchor for taproot anchor outputs 2023-08-22 16:30:02 -07:00
Olaoluwa Osuntokun
50bf3b6177
input: add TaprootCommitScriptToRemote for taproot to remote script 2023-08-22 16:30:00 -07:00
Olaoluwa Osuntokun
5f81919284
input: add TaprootCommitScriptToSelf for taproot to self script 2023-08-22 16:29:57 -07:00
Olaoluwa Osuntokun
9d0c04bfa2
input: add GenTaprootFundingScript based on musig2
In this commit, we add GenTaprootFundingScript, which'll return the
taproot pkScript and output for a taproot+musig2 channel. This uses
musig2 key aggregation with sorting activated.

The final key produced uses a bip86 tweak, meaning that the output key
provably doesn't commit to any script path. In the future, we may want
to permit this, as then it allows for a greater degree of
programmability of the funding output.
2023-08-22 16:29:55 -07:00
Olaoluwa Osuntokun
92868cfaa5
input: add PayToTaprootScript helper func
In this commit, we add a helper function to take a taproot output key
and turn it into a v1 witness program.
2023-08-22 16:29:52 -07:00
Olaoluwa Osuntokun
9851a6147b
lnwire: TestLightningWireProtocol quick check tests for taproot fields 2023-08-22 16:29:49 -07:00
Olaoluwa Osuntokun
7ae4bf0672
lnwire: sort records in ExtractRecords
This ensures that the caller doesn't need to worry about the TLV type
ordering of the records the pass into the function.
2023-08-22 16:29:47 -07:00
Olaoluwa Osuntokun
25dfbadd23
lnwire: add ShutdownNonce to Shutdown 2023-08-22 16:29:45 -07:00
Olaoluwa Osuntokun
ca4609e394
lnwire: add LocalNonce to RevokeAndAck 2023-08-22 16:29:42 -07:00
Olaoluwa Osuntokun
4a62652ad2
lnwire: add PartialSig to CommitSig 2023-08-22 16:29:40 -07:00
Olaoluwa Osuntokun
5223b6f381
lnwire: add LocalNonce to ChannelReestablish 2023-08-22 16:29:38 -07:00
Olaoluwa Osuntokun
8afb60da17
lnwire: add LocalNonce to FundingLocked 2023-08-22 16:29:36 -07:00
Olaoluwa Osuntokun
79c473cc46
lnwire: add PartialSig to FundingSigned 2023-08-22 16:29:34 -07:00
Olaoluwa Osuntokun
292b8db8f0
lnwire: add PartialSig to FundingCreated 2023-08-22 16:29:31 -07:00
Olaoluwa Osuntokun
ee279fbde3
lnwire: add LocalNonce to AcceptChannel 2023-08-22 16:29:29 -07:00
Olaoluwa Osuntokun
7c5ba067ab
lnwire: add LocalNonce to OpenChannel 2023-08-22 16:29:27 -07:00
Olaoluwa Osuntokun
14949c972d
lnwire: add new musig2 partial signature type
In this commit, we add the new types that'll house musig signatures with
and without their nonces. We send the nonce along with the sig
everywhere but the co-op close flow.
2023-08-22 16:29:24 -07:00
Olaoluwa Osuntokun
5b7caaea6d
lnwire: add new Musig2Nonce TLV record 2023-08-22 16:29:22 -07:00
Olaoluwa Osuntokun
b368e476c5
lnwire: update Sig to support both ECDSA and schnorr sigs
In this commit, we update the Sig type to support ECDSA and schnorr
signatures. We need to do this as the HTLC signatures will become
schnorr sigs for taproot channels. The current spec draft opts to
overload this field since both the sigs are actually 64 bytes in length.
The only consideration with this move is that callers need to "coerce" a
sig to the proper type if they need schnorr signatures.
2023-08-22 16:29:19 -07:00
Olaoluwa Osuntokun
eccc77315b
lnwire: add feature bits for simple taproot chans 2023-08-22 16:29:17 -07:00
Oliver Gugger
e49f6fcdd3
Merge pull request #7648 from guggero/initial-forwarding-policy
funding: fix flake in itest caused by persistent fee param changes
2023-08-22 15:15:28 +02:00
yyforyongyu
6820b08b53
funding: put assertNoFwdingPolicy in wait.NoError 2023-08-22 11:10:15 +08:00
yyforyongyu
0a6b05d2de
funding: catching barrier signal in receivedChannelReady
There is a race condition,
- goroutine_1: performing `stateStep` under `channelReadySent`. Once
  `receivedChannelReady` returns true, it will mark the channel state as
  `addedToRouterGraph`, which will delete the initial forwarding policy
  for private channels.
- goroutine_2: performing `handleChannelReady`, which processes the
  remote's channelReady message. It will ask brontide to `AddNewChannel`
  in the end.
- goroutine_3: performing `handleNewActiveChannel` in brontide, which
  will query the initial forwarding policy and fail to find it because
  it's already deleted in goroutine_1.

To fix it, we require `receivedChannelReady` to also check that the
channel's barrier signal in the map `handleChannelReadyBarriers` doesn't
exist, as this signal is removed once `handleChannelReady` finishes
adding the channel in brontide.
2023-08-22 09:52:49 +08:00
yyforyongyu
32d8208272
funding: add new method handleChannelReadyReceived
This commit is a pure code move. We add a new method
`handleChannelReadyReceived` to handle the channel's state change after
the remote's channel ready message is received.
2023-08-22 09:52:46 +08:00
yyforyongyu
d9e0464929
funding: defer initial forwarding policy deletion
This commit moves the deletion of the initial forwarding policy to the
end of `stateStep` to make sure the router has persisted it to disk
before the deletion.
2023-08-22 08:21:53 +08:00
yyforyongyu
38b106ccf3
funding: rename channelReady to channelReadySent for clarity 2023-08-22 07:04:17 +08:00
Oliver Gugger
d822d75f00
server+funding: remove previous link update mechanism
Because we now send the correct initial forwarding policy to Brontide,
the correct initial values are inserted into the link and we no longer
need to update the link in a later step.
2023-08-22 06:22:34 +08:00
Oliver Gugger
fb36806724
peer: load initial forwarding policy from channel DB 2023-08-22 06:22:34 +08:00
Oliver Gugger
7ac445caaf
funding: make sure initial policy is always set 2023-08-22 06:22:34 +08:00
Oliver Gugger
d5c504c8de
multi: use fwding policy from models pkg 2023-08-22 06:22:33 +08:00
Oliver Gugger
59b5fb1565
channeldb+funding: move policy encoding into channel DB 2023-08-22 06:22:33 +08:00
Oliver Gugger
36fcf65e97
funding+channeldb: rename fwding -> forwarding 2023-08-18 09:44:23 +02:00
Oliver Gugger
eda34a8d2a
channeldb: move fwding policy code to new file 2023-08-18 09:44:06 +02:00
Oliver Gugger
4770cb0aaf
manager: also store initial time lock delta and HTLC settings
This will allow us to also set the TimeLockDelta and HTLC settings
when creating the channel. We leave the actual implementation of
the RPC and CLI changes to another PR, this is just to make
things more consistent.
2023-08-18 09:44:06 +02:00
Oliver Gugger
5b9aa63cec
funding: extract defaultForwardingPolicy 2023-08-18 09:44:06 +02:00
Oliver Gugger
665179ece2
funding+server: don't use wallet DB for channel operations
Since the actual wallet backends might be different between the wallet
DB and the actual channel state DB, we pass in the correct struct to the
funding manager.
2023-08-18 09:44:05 +02:00
Oliver Gugger
4a03074fe8
Merge pull request #7894 from yyforyongyu/fix-lnwire-test-flake
trivial: fix unit test flake for `Ping` message
2023-08-18 09:42:59 +02:00
Oliver Gugger
4f9c09922a
Merge pull request #7881 from guggero/bump-neutrino-lib
mod: bump neutrino dependency to v0.16.0
2023-08-17 17:57:34 +02:00
yyforyongyu
70bd6d1a11
lnwire: fix unit test flake for Ping message 2023-08-17 23:51:04 +08:00
Oliver Gugger
d1dd2b4d11
mod: bump neutrino dependency to v0.16.0 2023-08-17 10:09:43 +02:00
Oliver Gugger
b565f4f536
Merge pull request #7880 from yyforyongyu/fix-channel-arb
trivial: fix loggings, variable names and conf notification order
2023-08-15 16:25:54 +02:00
Oliver Gugger
4ab2454880
Merge pull request #7879 from ziggie1984/remove-last-sweep-logic
Remove publishing last sweep tx logic during startup.
2023-08-15 16:21:43 +02:00
ziggie
160eab280a
docs: add release-notes. 2023-08-15 11:23:13 +02:00
ziggie
87fc58ecfe
multi: Add a channel.db migration.
The new migration removes the sweeper-last-tx top level bucket
from the channel.db database.
2023-08-15 10:00:30 +02:00
ziggie
07502a8fb0
sweep: Remove publishing last-tx logic.
We remove the publishing of the last published sweep tx during the
startup of the sweeper. This republishing can lead to situations
where funds of the default wallet might be locked for neutrino
backend clients.
Moreover all related tests are removed as well.
2023-08-15 10:00:29 +02:00
Olaoluwa Osuntokun
c6a68d193c
Merge pull request #7177 from morehouse/fix_chantype_negotiation
funding: fix channel type negotiation bug
2023-08-14 17:15:52 -07:00
Oliver Gugger
55cc35c6ba
Merge pull request #7870 from feelancer21/check-script-fix
scripts: Direct 'lnd --help' output to a file
2023-08-14 12:30:29 +02:00
Oliver Gugger
1f9736bafb
Merge pull request #7888 from hieblmi/fix-updatechanpolicy-typos
typos: fix updatechanpolicy typos
2023-08-14 09:52:48 +02:00
Oliver Gugger
2734fc52e1
Merge pull request #7886 from guggero/release-notes-fix
release-notes: remove duplicate Misc section, fix formatting and punctuation
2023-08-14 09:40:11 +02:00
Matt Morehouse
e6a2167f38
funding: refactor negotiateCommitmentType
- use a switch instead of nested ifs to improve readability
- improve some variable names
- reword comments
2023-08-11 11:20:07 -05:00
Slyghtning
ab117a0ed4
typos: fix updatechanpolicy typos 2023-08-11 17:04:36 +02:00
Oliver Gugger
1057422aba
release-notes: fix formatting, punctuation 2023-08-11 11:27:27 +02:00
Oliver Gugger
00a4b8a837
release-notes: collapse duplicate Misc section 2023-08-11 08:50:49 +02:00
yyforyongyu
92671ad250
contractcourt: register conf notification before publish tx
This commit moves the confirmation registration before publishing the tx
to make sure the conf event won't be missed.
2023-08-10 20:36:41 +08:00
yyforyongyu
a1671a8674
contractcourt: rename htlcResolvers to resolvers
This commit changes the name returned from `prepContractResolutions`
from `htlcResolvers` to `resolvers` to avoid confusion as there are
multiple types of resolvers returned.
2023-08-10 20:25:15 +08:00
Oliver Gugger
d930dcec40
Merge pull request #7819 from ziggie1984/abandonchannel-rebroadcaster
Cancel the Rebroadcasting of a Transaction when Abandoning a Channel
2023-08-10 10:43:24 +02:00
yyforyongyu
aff4320208
multi: improve logging re resolution flow 2023-08-10 13:50:03 +08:00
Olaoluwa Osuntokun
8f693fe020
Merge pull request #7518 from yyforyongyu/fix-channel-ready-race
Fix race between `channel_ready` and link update
2023-08-08 17:10:31 -07:00
yyforyongyu
f9d4212ecc
peer: send msgs to chanStream for both active and pending channels
This commit now sends messages to `chanStream` for both pending and
active channels. If the message is sent to a pending channel, it will be
queued in `chanStream`. Once the channel link becomes active, the early
messages will be processed.
2023-08-09 01:29:19 +08:00
yyforyongyu
a9da25b238
golangci: update linter settings for test files 2023-08-09 01:29:19 +08:00
yyforyongyu
0dd2aa0aef
multi: add itest to check race between channel_ready and update_add_htlc
This commit adds a new itest case to check the race condition found in
issue #7401. In order to control the funding manager's state, a new dev
config for the funding manager is introduced to specify a duration we
should hold before processing remote node's channel_ready message.

A new development config, `DevConfig` is introduced in `lncfg` and will
only have effect if built with flag `integration`. This can also be
extended for future integration tests if more dev-only flags are needed.
2023-08-09 01:29:19 +08:00
yyforyongyu
6b41289538
multi: patch unit tests for handling pending channels 2023-08-09 01:29:19 +08:00
yyforyongyu
d28242c664
peer: return an error from updateNextRevocation and patch unit tests
This commit makes the `updateNextRevocation` to return an error and
further feed it through the request's error chan so it'd be handled by
the caller.
2023-08-09 01:29:18 +08:00
yyforyongyu
927572583b
multi: remove pending channel from Brontide when funding flow failed
This commit adds a new interface method, `RemovePendingChannel`, to be
used when the funding flow is failed after calling `AddPendingChannel`
such that the Brontide has the most up-to-date view of the active
channels.
2023-08-09 01:29:18 +08:00
yyforyongyu
3ed579d06f
funding: make failFundingFlow takes both channel IDs
This commit adds a new struct `chanIdentifier` which wraps the pending
channel ID and active channel ID. This struct is then used in
`failFundingFlow` so the channel ID can be access there.
2023-08-09 01:29:18 +08:00
yyforyongyu
048d7d7c36
docs: update release note for race fix 2023-08-09 00:17:23 +08:00
yyforyongyu
3eb7f54a6d
peer: add method handleLinkUpdateMsg to handle channel update msgs 2023-08-09 00:17:23 +08:00
yyforyongyu
e46bd8e177
multi: add AddPendingChannel to peer interface
The funding manager has been updated to use `AddPendingChannel`. Note
that we track the pending channel before it's confirmed as the peer may
have a block height in the future(from our view), thus they may start
operating in this channel before we consider it as fully open.

The mocked peers have been updated to implement the new interface method.
2023-08-09 00:17:22 +08:00
yyforyongyu
f39c568c94
peer: track pending channels in Brontide
This commit adds a new channel `newPendingChannel` and its dedicated
handler `handleNewPendingChannel` to keep track of pending open
channels. This should not affect the original handling of new active
channels, except `addedChannels` is now updated in
`handleNewPendingChannel` such that this new pending channel won't be
reestablished in link.
2023-08-09 00:17:22 +08:00
Oliver Gugger
dfe95d74ea
Merge pull request #7875 from ellemouton/moveStateServerRestRegister
refactor: move State server REST registration
2023-08-08 15:00:27 +02:00
feelancer21
2914f8007f
scripts: Direct 'lnd --help' output to a file
We are directing the output of 'lnd --help' to a file, as there
is currently an issue when an option is mentioned in the help
text.
2023-08-08 11:47:21 +02:00
Elle Mouton
b9560b067a
refactor: move State server REST registration
This commit moves the registration of the State server with a REST proxy
into the `RegisterWithRestProxy` method in order to keep all the REST
registrations in one place.
2023-08-08 11:43:25 +02:00
ziggie
87cfcea8a3
docs: add release-notes. 2023-08-08 09:32:39 +02:00
ziggie
dd912911fa
lnd: cancel rebroadcasting a tx.
When abandoning a channel we make sure we cancel the rebroadcasting
of the transaction.
2023-08-08 09:31:17 +02:00
ziggie
2708626d62
lnwallet: add CancelRebroadcast method.
Adding the ability to stop rebroadcasting a transaction. This is
useful when we want to abandon a channel and grantee that this
transaction will not confirm accidentally.
2023-08-08 09:31:16 +02:00
Oliver Gugger
bf5aab9d52
Merge pull request #7788 from ellemouton/bumpNeutrino
go.mod: bump neutrino and btcwallet versions
2023-08-07 08:46:20 +02:00
Elle Mouton
5203b35316
go.mod: bump neutrino and btcwallet versions 2023-08-05 08:53:39 +02:00
Oliver Gugger
aa7e7a1e5a
Merge pull request #7770 from feelancer21/sample-lnd-conf-update-defaults
Revision of default values in sample-lnd.conf and building of a check script
2023-08-04 13:10:29 +02:00
Olaoluwa Osuntokun
03b26bb909
Merge pull request #7859 from guggero/txnotifier-details-copy
chainntnfs: remove block info from conf detail copy
2023-08-03 14:36:32 -07:00
feelancer21
df440446f7
docs: release notes for #7770 2023-08-03 18:04:26 +02:00
feelancer21
8b78c1b9e2
workflows: change step name of sample conf check
We now also check the default values themselves and not just the
existence of the command line flags in the file.
2023-08-03 18:04:25 +02:00
feelancer21
3e1e666065
docs: Documentation of sample-conf-check in MAKEFILE.md
Added an entry for sample-conf-check in MAKEFILE.md.
2023-08-03 18:04:25 +02:00
feelancer21
cbd8f0a819
Makefile: Calling the script check-sample-lnd-conf.sh
The existing sample-conf-check is replaced by a call of the
check-sample-lnd-conf.sh.
2023-08-03 18:04:25 +02:00
feelancer21
aa6bc0828a
scripts: Add check script for sample-lnd.conf
The new script perfoms the following checks on the sample-lnd.conf file:
 1. Checks that all relevant options of lnd are included.
 2. Verifies that defaults are labeled if there are also further examples.
 3. Checks that all default values of lnd --help are mentioned correctly,
    including empty defaults and booleans which are set to false by
    default.
2023-08-03 18:04:18 +02:00
feelancer21
178f646692
sample-lnd.conf: Cleanup of defaults and examples
If there is only one entry in the sample-lnd.conf, it must reflect the
default value. If additional examples are provided, they should follow
the following format.

; Default:
;   option=defaultvalue
; Example
;   option=examplevalue

Booleans have been changed to 'false' to align with the default behavior
of Go. Additionally, the description for various parameters has been
adjusted.
2023-08-03 17:48:45 +02:00
Oliver Gugger
4332413fba
chainntnfs: remove block info from conf detail copy
Noticed this while updating to latest master in another project:
If there are two notifications for the same output being registered and
the first one does _NOT_ request the block to be included, then the
second one also will not receive the block, even if it explicitly
requests it.
This is caused by the block being removed from the original confirmation
set instead of a copy (as it is done in NotifyHeight and
UpdateConfDetails).
2023-08-02 15:23:14 +02:00
Oliver Gugger
19c121c7a3
Merge pull request #7846 from morehouse/refactor_mailcourier
htlcswitch: split mailCourier by courierType
2023-08-02 10:52:46 +02:00
Oliver Gugger
d62bed22a3
Merge pull request #7857 from hieblmi/wallet-balance-account
lnrpc: adding account name to the `WalletBalance` rpc
2023-08-02 10:45:46 +02:00
Olaoluwa Osuntokun
1871970543
Merge pull request #7343 from positiveblue/sqldb
sqldb: new package supporting sql backends
2023-07-31 10:49:42 -07:00
Matt Morehouse
b1a3c46759
htlcswitch: TODO for obviating type assertions
memoryMailBox uses multiple container/list.List objects to track
messages and packets, which use interface{} to accept objects of any
type. go1.18 added generics to the language, which means we could use a
typed list instead, allowing us to stop using forced type assertions
when reading objects from the list.

I'm not aware of any standard library implementation of a typed list yet,
so let's just add a TODO for now.
2023-07-31 09:52:33 -05:00
Slyghtning
6282e0cf86
docs: update release notes 2023-07-28 22:24:55 +02:00
Slyghtning
2c3420679d
lncli: add account to WalletBalance command 2023-07-28 22:24:55 +02:00
Slyghtning
dd2a89a6ee
lnd: WalletBalance checks on account basis 2023-07-28 22:24:55 +02:00
Slyghtning
442f1ac4d4
lnrpc: WalletBalanceRequest adds account 2023-07-28 22:24:53 +02:00
Olaoluwa Osuntokun
f64ebfb975
Merge pull request #7844 from hieblmi/add-slyghtning-to-signers
scripts: add gpg key for hieblmi [skip ci]
2023-07-27 11:20:00 -07:00
Olaoluwa Osuntokun
10bd338b33
Merge pull request #7799 from positiveblue/fix-build-route
routing: fix `index out of range` panic
2023-07-27 11:17:31 -07:00
Olaoluwa Osuntokun
8f5fee98a6
Merge pull request #7856 from Roasbeef/p2p-wg-fix
peer: ensure the peer has been started before Disconnect can be called
2023-07-27 11:14:37 -07:00
Olaoluwa Osuntokun
325e844a96
peer: ensure the peer has been started before Disconnect can be called
In this commit, we make sure that all the `wg.Add(1)` calls succeed
before we attempt to wait on the shutdown of all the goroutines. Under
rare scheduling scenarios, if both `Start` and `Disconnect` are called
concurrently, then this internal race error can be hit, causing the
panic to occur.

Fixes https://github.com/lightningnetwork/lnd/issues/7853
2023-07-27 10:59:39 -07:00
Olaoluwa Osuntokun
798821db17
peer: remove unused queueQuit channel
In this commit, we remove an unused `queueQuit` channel.
2023-07-27 10:59:29 -07:00
positiveblue
099907c43f
docs: add release note for 7343 2023-07-27 03:31:15 -07:00
positiveblue
5a7d7c2e4f
sqldb: add the sqldb package
This commit provides the scaffolding for using the new sql stores.
The new interfaces, structs and methods are in sync with other projects
like Taproot Assets.

- Transactional Queries: the sqldb package defines the interfaces required
to execute transactional queries to our storage interface.

- Migration Files Embedded: the migration files are embedded into the binary.

- Database Migrations: I kept the use of 'golang-migrate' to ensure our
codebase remains in sync with the other projects, but can be changed.

- Build Flags for Conditional DB Target: flexibility to specify our database
target at compile-time based on the build flags in the same way we do
with our kv stores.

- Update modules: ran `go mod tidy`.
2023-07-27 03:31:12 -07:00
Oliver Gugger
d46ee0bd74
Merge pull request #7842 from morehouse/refactor_handle_warning_error
peer: combine handleWarning and handleError
2023-07-27 10:32:07 +02:00
Oliver Gugger
5919615416
Merge pull request #7746 from ziggie1984/min-relay-fee
Handle Min Mempool Fee error so that lnd will startup correctly
2023-07-26 14:42:49 +02:00
Oliver Gugger
1d3796a6d4
Merge pull request #7820 from hieblmi/sync-batch-chan-open-params
lnrpc: sync BatchOpenChannel and OpenChannel params
2023-07-26 11:31:05 +02:00
Slyghtning
6e9edc9c88
docs: update release notes 2023-07-26 09:50:47 +02:00
Slyghtning
14be2cdae0
itest: batch channel fee params 2023-07-26 09:49:22 +02:00
Slyghtning
47bcf7af69
funding: add all parameters to batch open channel 2023-07-26 09:49:22 +02:00
Slyghtning
6631741766
lnrpc: sync BatchOpenChannel and OpenChannel params 2023-07-26 09:49:20 +02:00
ziggie
a9ad0e5208
docs: add release-notes for 0.17.0. 2023-07-26 00:18:08 +02:00
ziggie
521a67c795
lnd: define additional rebroadcaster function.
The MapCustomBroadcastError of the rebroadcaster is defined.
This let's us use the Rebroadcaster of the neutrino package (pushtx)
with other backends and guarantee a consistent behaviour. Prior
to this change the rebroadcaster would stop rebroadcasting
transactions because they did not meet the neutrino specific
broadcastErr type.
2023-07-26 00:18:08 +02:00
ziggie
c88ff14477
contractcourt: add tests for mempool rejection.
Add a test where the channel arbitrator starts up correctly
when a prior unilateral close of a channel did not broadcast
for specific reasons.
Also add a test which ensures that when a crib output is
rejected by the bitcoin backend the startup works correctly
for specific errors.
2023-07-26 00:03:17 +02:00
Olaoluwa Osuntokun
9ed064be75
Merge pull request #7516 from hieblmi/utxo-funding
funding: fund channel with selected utxos
2023-07-25 19:19:42 +02:00
positiveblue
83ccf61df9
routing: fix index out of range panic
Make sure that we do not crash the node trying to access an invalid
position for an array (-1) in `BuildRoute`.
2023-07-25 10:13:26 -07:00
positiveblue
aadf385f67
routing: split BuildRoute
Create a couple of subroutines that we can unit test separately.
2023-07-25 10:12:55 -07:00
Oliver Gugger
7fdb55bd30
Merge pull request #7827 from carlaKC/cleanup-invoicetests
invoices/test: Cleanup Invoice Registry Tests
2023-07-25 13:15:34 +02:00
Oliver Gugger
0e0e8d8631
Merge pull request #7854 from matheusdtech/itest-network-conn
itest: bind to local addr in network test
2023-07-25 09:20:40 +02:00
ziggie
8314f0a879
contractcourt: handle mempool min fee error.
In case the mempool backend signals that our transaction does not
meet fee requirements when publishing it we will continue to
start up now. The transaction will be rebroadcasted in the
background and a specific log message will be printed to let the
user know that he could increase his mempool size to at least
have this transaction in his own mempool.
2023-07-25 01:13:24 +02:00
ziggie
54bacec422
lnwallet: add new ErrMempoolFee error. 2023-07-25 01:12:39 +02:00
ziggie
6da0f2a157
mod: bump version of neutrino and btcwallet. 2023-07-25 01:12:39 +02:00
Carla Kirk-Cohen
4645fdfb0a
invoice/test: make all tests parallel
When we have tests using global variables and a mix of parallel and
non-parallel tests, odd races can appear when we run them.
2023-07-24 10:54:03 -04:00
Carla Kirk-Cohen
94e434d2f1
invoices/test: move payment address required global into test using it 2023-07-24 10:54:02 -04:00
Carla Kirk-Cohen
d080d07a22
invoices/test: remove duplicate test invoice amount global
We have testInvoiceAmt and testInvoiceAmount with the same value.
2023-07-24 10:54:01 -04:00
Carla Kirk-Cohen
40f695743a
invoice/test: move payment address optional into test using it
No need for a global when this is only used once.
2023-07-24 10:54:00 -04:00
Carla Kirk-Cohen
ceff879f37
invoices/test: replace global testInvoice with constructor
For our relatively "static" test invoice, add a simple constructor
using the globals defined, rather than having a global invoice which
risks being mutated.
2023-07-24 10:53:58 -04:00
Matheus Degiovani
13399e9e81
itest: bind to local addr in network test
This makes the test work even if the local OS has no outside network
connections available or if DNS lookups are failing.
2023-07-24 08:47:26 -03:00
Slyghtning
23467cbb66
docs: update release notes 2023-07-24 13:07:01 +02:00
Slyghtning
396cffcd70
itest: anchor reserve test for SendOutputs 2023-07-24 13:07:01 +02:00
Slyghtning
baa1419187
chanfunding: fix typo 2023-07-24 13:07:01 +02:00
Slyghtning
f0579cc509
lncli: add flag utxos for openchannel 2023-07-24 13:07:01 +02:00
Slyghtning
e4f0e58214
lnd: handles selected outpoints in parseOpenChannelReq 2023-07-24 13:06:59 +02:00
Slyghtning
d327c92188
lnwallet: adds selected Outpoints for funding 2023-07-24 12:10:54 +02:00
Slyghtning
50acd49283
lnrpc: adds field Outpoints to fund a selected set of coins 2023-07-24 12:10:54 +02:00
Slyghtning
ac523f93ee
chanfunding: adds ability to fund a selected set of coins 2023-07-24 12:10:53 +02:00
Matt Morehouse
15f6e7a80a
htlcswitch: split mailCourier by courierType
The goroutine is very long and littered with switches on courierType. By
separating the implementations into different methods for each
courierType we eliminate the cruft and improve readability.
2023-07-20 14:53:46 -05:00
Slyghtning
37c0e521e8
scripts: add gpg key for Slyghtning [skip ci] 2023-07-20 16:28:21 +02:00
Matt Morehouse
e2f2b07149
peer: combine handleWarning and handleError
The two methods were nearly identical, so we can simplify by combining
them.
2023-07-19 12:40:16 -05:00
Oliver Gugger
c3cd93c98a
Merge pull request #7723 from morehouse/fuzz_zpay32_checksum
zpay32: improve fuzz tests
2023-07-19 16:58:44 +02:00
Matt Morehouse
9200abf96e
zpay32: allow fuzzer to choose invoice net
We add a parameter to select which network will be used for the fuzz
tests, rather than hardcoding the network.
2023-07-19 09:04:26 -05:00
Matt Morehouse
e5fcc57bbc
docs: release note for #7723 2023-07-19 09:04:22 -05:00
Matt Morehouse
bd7ec84497
zpay32: help fuzzer generate valid encodings
It is very difficult for the fuzzer to create a valid checksum for each
serialized invoice, and we were therefore unable to fuzz deeper than
invoice decoding. We can help the fuzzer generate valid serialized
invoices by calculating and appending the checksum ourselves.

We also switch to using mainnet invoices to make it easier to find valid
invoices for seeding the fuzzer. We prepend the required "lnbc" prefix
ourselves to further help the fuzzer generate valid invoices.
2023-07-19 09:04:18 -05:00
Matt Morehouse
82753f091b
zpay32: use message signer from unit tests
The message signer from invoice_test.go is identical to the one created
in the fuzz test. We're already using the private key from
invoice_test.go, so we may as well use the complete message signer for
simplicity.
2023-07-19 09:04:13 -05:00
Matt Morehouse
4207be6e50
zpay32: remove unused method calls
The fuzz tests call inv.MinFinalCLTVExpiry() and inv.Expiry() supposedly
to ensure the invoice is well-formed. However, those methods can never
panic or return errors and therefore provide no benefit for this
purpose.
2023-07-19 09:04:03 -05:00
Oliver Gugger
0d2f2aa802
Merge pull request #6895 from ellemouton/towerHasUnackedUpdates
wtclient: replay pending and unacked updates
2023-07-19 12:19:49 +02:00
Elle Mouton
7bf07d8875
docs: add release note for 6895 2023-07-19 10:10:15 +02:00
Elle Mouton
3ea67983b5
wtclient: replay un-acked updates onto pipeline
In this commit, the bugs demonstrated in prior commits are fixed. In the
case where an session has persisted a CommittedUpdate and the tower is
being removed, the session will now replay that update on to the main
task pipeline so that it can be backed up using a different session.
2023-07-18 16:28:27 +02:00
Elle Mouton
c432899bf9
watchtower: add DeleteCommittedUpdate DB method
Add a new DeleteCommittedUpdate method to the wtdb In preparation for an
upcoming commit that will replay committed updates from one session to
another.
2023-07-18 16:28:27 +02:00
Elle Mouton
cfb81c00a6
wtclient: tower with unacked updates cant be removed after restart
This commit demonstrates that if a session has persisted committed
updates and the client is restarted _after_ these committed updates have
been persisted, then removing the tower will fail.
2023-07-18 16:28:27 +02:00
Elle Mouton
af1506bff1
wtclient: demo "tower has unacked updates" bug
In this commit, we demonstrate the situation where a client has
persisted CommittedUpdates but has not yet recieved Acks for them from
the tower. If this happens and the client attempts to remove the tower,
it will with the "tower has unacked updates" error.
2023-07-18 16:28:26 +02:00
Elle Mouton
552ef4bf81
wtclient: replay pending tasks on sessionQueue stop
This commit does a few things:
- First, it gives the sessionQueue access to the TowerClient task
  pipeline so that it can replay backup tasks onto the pipeline on Stop.
- Given that the above is done, the ForceQuit functionality of the
  sessionQueue and TowerClient can be removed.
- The bug demonstrated in a prior commit is now fixed due to the above
  changes.
2023-07-18 16:28:26 +02:00
Elle Mouton
449d6b5500
wtclient: fix handleStaleTower comment 2023-07-18 14:27:14 +02:00
Elle Mouton
25c4d3f1f7
wtclient: make sessionQueueSet thread safe
In preparation for an upcoming commit where multiple threads will have
access to the TowerClient sessionQueueSet, we turn it into a thread safe
struct.
2023-07-18 14:27:04 +02:00
Elle Mouton
c4fec3ebc9
wtclient: show that bound tasks are not replayed
This commit demonstrates a bug. It shows that if backup tasks have been
bound to a session with a tower (ie, the tasks are in the session's
pendingQueue) and then the tower is removed and a new one is added, then
the tasks from the pendingQueue are _not_ replayed to the session with
the new tower. Instead, they are silently lost. This will be fixed in an
upcoming commit.
2023-07-18 14:26:51 +02:00
Elle Mouton
feb35e65d8
wtclient: show that a client can switch towers
This commit adds a new watchtower client test to demonstrate that a
client is able to successfully switch to a new tower and continue
backing up updates to that new tower.
2023-07-18 14:26:35 +02:00
Elle Mouton
d8af5fcc92
wtclient: ensure that waitForUpdates has no race condition on timeout
Enforce that the fail timeout in `waitForUpdates` is greater than the
ping timeout.
2023-07-18 14:25:58 +02:00
Elle Mouton
d979f59331
wtclient: move server specific methods to serverHarness 2023-07-18 14:15:46 +02:00
Elle Mouton
2ed5788de3
wtclient: separate server from testHarness
In this commit, a serverHarness is added to the test framework. This
will allow us to create more mock servers appart from the main server.
2023-07-18 14:15:26 +02:00
Oliver Gugger
2bb28f7aaf
Merge pull request #7834 from bitcoincore-dev/1689267061/e8c11b989/ee55126b5-scripts/check-release-notes.sh
scripts/check-release-notes.sh: fix bash expression
2023-07-18 12:03:30 +02:00
Carla Kirk-Cohen
17f529bfad
invoices/test: rename newInvoice to reflect return value better
Test utils currently have two different test invoices - a minimalist
one that is used in a variety of test cases, and a customizable one
that is used specifically for tests concerning invoice expiry. The
latter is renamed and moved closer to the calling code to more clearly
indicate its use.
2023-07-17 09:39:40 -04:00
Oliver Gugger
bd3f570107
Merge pull request #7807 from lightningnetwork/dependabot/go_modules/google.golang.org/grpc-1.53.0
build(deps): bump google.golang.org/grpc from 1.41.0 to 1.53.0
2023-07-17 14:15:25 +02:00
Oliver Gugger
cbb1d943b2
Merge pull request #7831 from bitcoincore-dev/1689264113/6e68c3b2b/afbc9c629-consistent-username
docs: Make MacOS user path consistent across docs
2023-07-17 14:12:22 +02:00
@RandyMcMillan
2b7c9019eb
docs/grpc/java.md: use /Users/<username>/..
Make MacOS user path consistent across docs
2023-07-14 16:44:28 -04:00
@RandyMcMillan
ed94a8f3b4
docs/INSTALL.md: use /Users/<username>/..
Make MacOS user path consistent across docs
2023-07-14 16:41:52 -04:00
@RandyMcMillan
f2b3674b3a
scripts/check-release-notes.sh: fix bash expression 2023-07-13 12:51:40 -04:00
Oliver Gugger
a6fc5d0753
Merge pull request #7826 from carlaKC/race-testinvoice
invoices/test: fix data race in TestMppPaymentWithOverpayment
2023-07-13 17:32:27 +02:00
Carla Kirk-Cohen
590d898ba0
invoices/test: fix data race in TestMppPaymentWithOverpayment
Details of race:
- A global testInvoice is used in various invoice related tests.
- All tests are running with t.Parallel.
- TestMppPaymentWithOverpayment passes a reference to the testInvoice
  to AddInvoice which writes the AddIndex.
- TestMultipleSetHeightExpiry reads the testInvoice to make a copy.
2023-07-13 10:39:35 -04:00
Oliver Gugger
e8c11b9898
Merge pull request #7783 from guggero/bump-tor-dependency-ipv6-fix
mod: bump tor submodule to v1.1.1
2023-07-13 11:05:20 +02:00
Oliver Gugger
bc58dce176
docs: update release notes 2023-07-13 10:17:17 +02:00
Oliver Gugger
cffdc9a46f
mod: bump tor submodule to v1.1.1 2023-07-13 10:17:02 +02:00
Olaoluwa Osuntokun
acecb12f54
Merge pull request #7354 from positiveblue/invoice-sql-schema
sqldb: add invoice schema and sql queries
2023-07-12 17:03:26 -07:00
Oliver Gugger
7d202e69ef
Merge pull request #7739 from sputn1ck/autocert_fix
tlsmanager: fix autocert autogeneration
2023-07-12 10:03:01 +02:00
sputn1ck
92e0b08a7a
docs: add release note for 7739 2023-07-11 21:25:19 +02:00
sputn1ck
10f9748193
tlsmanager: fix autocert autogeneration
As the getConfig() function would previously overwrite the
GetCertificateFunction of the tls config, the autocert manager would
never be used.
2023-07-11 21:24:46 +02:00
Olaoluwa Osuntokun
33b470b4a6
Merge pull request #7768 from ProofOfKeags/spurious-htlc-rejections
invoices+htlcswitch: fix spurious htlc rejections from overly strict onion packet integrity checks
2023-07-11 10:51:22 -07:00
Oliver Gugger
54acf270a2
Merge pull request #7758 from guggero/gpg-homedir
scripts: use gpg --homedir flag to fix new behavior in 2.4
2023-07-11 10:33:57 +02:00
Oliver Gugger
52115ab19b
docs: add release notes 2023-07-11 09:18:43 +02:00
Oliver Gugger
8c9f4515b6
scripts: use gpg --homedir flag to fix new behavior in 2.4
With the latest Golang Docker base image we are using the new gpg
version 2.4 is now being installed in the lnd Docker base image.

Apparently the expected value for the --keyring flag is just a file name
and not an absolute path. The path of the file is indicated either by
the $HOME environment variable or the --homedir flag. It looks like 2.4
now finally stopped supporting an absolute path in the --keyring flag
and we need to update our gpg command to make the script work again.

This should be backward compatible and still work on older versions of
gpg.
2023-07-11 09:18:22 +02:00
positiveblue
8fcb404161
docs: add release note for 7354 2023-07-10 17:57:09 -07:00
positiveblue
ff1379a633
CI: Add sqlc code generation check 2023-07-10 17:57:09 -07:00
positiveblue
730db7ee8c
sqlc: generate go code from SQL
run `make sqlc`

All the code in this commit is auto-generated.
2023-07-10 17:57:06 -07:00
positiveblue
877b711360
sqldb: add invoice event queries 2023-07-10 17:56:29 -07:00
positiveblue
fb16287b31
sqldb: add invoice events SQL schema 2023-07-10 17:56:27 -07:00
positiveblue
6deb916216
sqldb: add AMP invoice queries 2023-07-10 17:53:57 -07:00
positiveblue
eda95e6607
sqldb: add AMP invoices SQL schema
Schema for AMP invocies.

AMP invoices can be paid multiple times and each payment to an AMP invoice
is identified by a `set_id`.

The A in AMP stands for `Atomic`. All the htlcs belonging to the same
AMP payment (share the same set_id) will be resolved at the same time
with the same result: settled/canceled.

AMP invoices do not have an "invoice preimage". Instead, each htcl has
its own hash/preimage. When a new htlc is added the hash for that htlc
is attached to it. When all the htlcs of a set_id have been received we
are able to compute the preimage for each one of them.
2023-07-10 17:53:56 -07:00
positiveblue
7aa2f390fe
sqldb: add invoice queries
Set of queries to deal with invoices. A couple of things to take into
account:

    - Because the queries are not rewritten at runtime, we cannot have a
      generic `INSERT` with different tuples.
    - Because the queries are not rewritten at runtime, we cannot build
      one query with only the filters that matter for that queries. The
      two options are a combinatorial approach (a new query for every
      permutation) or a generic query using the pattern

          ```
            SELECT *
            FROM table
            WHERE (
                -- Can be read as:
                -- Match the filter 1 value if filter_1 != nil
                column_1 >= sqlc.narg('filter_1') OR
                sqlc.narg('filter_1') IS NULL
            ) AND (
                column_2 >= sqlc.narg('filter_2') OR
                sqlc.narg('filter_2') IS NULL
            ) ...
          ```
2023-07-10 17:53:29 -07:00
positiveblue
e3663b9942
sqldb: add invoices SQL schema
This is the schema for "ordinal" BOLT11 invoices.

The invoices table aims to keep an entry for each invoice, BOLT11 or not,
that will be supported.

Invoice related HTLCs will be stored in a separete table than forwarded
htlcs.

SQLite does not support `SEQUENCE`. We achieve atomic autoincrementals
using primary keys with autoincrement/serial. An invoice `AddIndex`
translates to `invoices(id)` while `SettleIndex` is `invoice_payments(id)`.
2023-07-10 17:53:26 -07:00
positiveblue
43a9e2f1ca
multi: add sqlc support
sqlc is a tool that generates fully type-safe idiomatic code from SQL.
The result is Go code can then used execute the queries in the database.

The noraml flow looks like:
- The developer write some sql that will update the schema in the
  database: new tables, indices, etc
- The developer updates the set of queries that will use the new schema.
- `sqlc` generates type-safe interfaces to those queries.
- The developer can then write application code that calls the methods
  generated by sqlc.

The tool configuration needs to live in the repo's root and its name is
`sqlc.yaml`.

LND will support out of the box sqlite and postgres. The sql code needs to
be (almost) the same for both engines, so we cannot use custom functions
like `ANY` in postgres.

The SQLC config file needs to define what is the target engine, we will
set postgres but the generated code can be executed by sqlite too.

In some specific cases, we will `match and replace` some sql lines to be
sure the table definitions are valid for the targeted engine.
2023-07-10 17:36:58 -07:00
Oliver Gugger
287b0ac219
Merge pull request #7817 from ViktorTigerstrom/2023-07-add-viktor-key
scripts: add ViktorTigerstrom PGP key
2023-07-10 14:34:08 +02:00
Oliver Gugger
0045344692
Merge pull request #7814 from harsha-s/patch-2
Fix docker compose run issue
2023-07-10 13:36:16 +02:00
Viktor Tigerström
376aeec52a
scripts: add ViktorTigerstrom PGP key [skip ci] 2023-07-10 12:55:19 +02:00
Oliver Gugger
6002982baa
Merge pull request #7806 from lightningnetwork/dependabot/go_modules/kvdb/google.golang.org/grpc-1.53.0
build(deps): bump google.golang.org/grpc from 1.41.0 to 1.53.0 in /kvdb
2023-07-10 11:14:50 +02:00
Oliver Gugger
93c4b678be
GitHub: bump pinned dependency for grpc 2023-07-10 11:04:14 +02:00
Harsha
d9f3a12f57
Fix docker compose run issue
docker-compose run -d --name alice --volume simnet_lnd_alice:/root/.lnd lnd

 => ERROR [builder 4/4] RUN git clone https://github.com/btcsuite/btcd.git .     && git checkout v0.23  6.2s
------
 > [builder 4/4] RUN git clone https://github.com/btcsuite/btcd.git .     && git checkout v0.23.5     && go install -v . ./cmd/...:
#0 0.253 Cloning into '.'...
#0 6.059 error: pathspec 'v0.23.5' did not match any file(s) known to git
------
failed to solve: executor failed running [/bin/sh -c git clone https://github.com/btcsuite/btcd.git .     && git checkout $BTCD_VERSION     && go install -v . ./cmd/...]: exit code: 1
2023-07-10 01:00:57 +01:00
Keagan McClelland
7b179a8e64 htlcswitch: optimize tests to not tear down harness 2023-07-07 13:30:25 -06:00
Keagan McClelland
f2bb4ff559 invoices+htlcswitch: fix style nits 2023-07-07 13:17:01 -06:00
Keagan McClelland
61f48ccf4e docs: update release notes 2023-07-07 10:49:05 -06:00
Keagan McClelland
36bf471a1f invoices+htlcswitch: add tests for relaxed link and invoice checks 2023-07-07 10:48:57 -06:00
dependabot[bot]
63382faec1
build(deps): bump google.golang.org/grpc from 1.41.0 to 1.53.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.41.0 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.41.0...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-05 21:12:31 +00:00
dependabot[bot]
b9b34a086f
build(deps): bump google.golang.org/grpc from 1.41.0 to 1.53.0 in /kvdb
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.41.0 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.41.0...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-05 21:12:10 +00:00
Olaoluwa Osuntokun
86e7b4e1e0
Merge pull request #7794 from yyforyongyu/prepare-channel-ready-fix
brontide: refactor peer to prepare channel ready fix
2023-07-04 12:39:59 -07:00
Olaoluwa Osuntokun
55c991a1a7
Merge pull request #7775 from yyforyongyu/fix-logger-order
lnd: fix orders when initializing subsystem loggers
2023-07-04 12:39:39 -07:00
Olaoluwa Osuntokun
5015cd941e
Merge pull request #7797 from guggero/kvdb-1-4-2
mod: bump kvdb submodule to v1.4.2
2023-07-04 12:39:23 -07:00
Olaoluwa Osuntokun
df9b53b6af
Merge pull request #7766 from ffranr/export_unmarshall_outpoint
Export unmarshall outpoint functionality
2023-07-04 12:37:48 -07:00
Olaoluwa Osuntokun
f3437d6d2a
Merge pull request #7782 from guggero/fix-tor-dial-ipv6
tor: short circuit host lookup if connecting to IP
2023-07-04 12:37:36 -07:00
Keagan McClelland
1b1eedb434 htlcswitch: relax final onion packet check
The spec allows the final HTLC value and CLTV expiry to exceed
the value and expiry specified in the payload of the last hop
of the onion packet. We were over-restricting it to require
that it matches exactly.
2023-06-29 17:13:36 -06:00
Keagan McClelland
e0c0815c96 invoices: allow overpayment in mpps 2023-06-29 17:13:36 -06:00
Oliver Gugger
5c5ce1f707
Merge pull request #7780 from ziggie1984/max_local_csv
Change defaultMaxLocalCSVDelay to protect user from high delays
2023-06-29 20:52:26 +02:00
Oliver Gugger
2604aebdef
mod: bump kvdb submodule to v1.4.2
This is necessary after #7796 to apply the change made in the kvdb
submodule to the main module.
2023-06-29 13:37:58 -04:00
Oliver Gugger
5ea4251b3a
Merge pull request #7796 from hsjoberg/update-kvdb
kvdb: Update bbolt to 1.3.7 in order to address mmap issues
2023-06-29 19:35:26 +02:00
Hampus Sjöberg
3d69ed3d4c kvdb: Update bbolt to 1.3.7 in order to address mmap issues 2023-06-29 17:54:43 +02:00
ziggie
6cbb62a2df
docs: update release-notes 2023-06-28 07:08:32 +02:00
Olaoluwa Osuntokun
aa17c17f9a
Merge pull request #7772 from Roasbeef/release-notes-merge-queue
scripts: update release notes check for merge queue usage
2023-06-27 13:46:29 -04:00
yyforyongyu
195e951e58
peer: rename newChannels to newActiveChannel
As new pending channels will be tracked in the following commits, the
`newChannels` is now renamed to `newActiveChannel` to explicitly refer
to active, non-pending channels.
2023-06-27 20:19:37 +08:00
yyforyongyu
22d2819489
peer: add handleNewChannelMsg method to handle new channel request 2023-06-27 20:19:37 +08:00
yyforyongyu
60627f676f
peer: stop considering pending channels as active
This commit changes the method `isActiveChannel` such that the pending
channels are not consider as active.
2023-06-27 20:19:37 +08:00
yyforyongyu
ccb86a9d1d
peer: update and use SyncMap in Brontide
This commit applies methods `ForEach` and `Len` to `Brontide`.
2023-06-27 20:19:37 +08:00
yyforyongyu
a66d42c682
funding: use SyncMap to simplify map usage 2023-06-27 20:19:37 +08:00
ziggie
39f9673bc7
lnd: update defaultMaxLocalCSVDelay
Make sure our default local csv delay maximum is symetric
compared  to the remote default csv maximum.
2023-06-26 23:39:45 +02:00
rockstardev
3c60fc0857 Adding BtcPayServer related files and resources 2023-06-26 11:32:03 -05:00
Olaoluwa Osuntokun
d0ca48a435
Merge pull request #7767 from yyforyongyu/fix-mempool-leak
Fix mempool memory usage
2023-06-22 11:22:20 -05:00
Oliver Gugger
e95720cf3a
tor: short circuit host lookup if connecting to IP
With this commit we avoid calling LookupHost if we already have an IPv4
or IPv6 address, as we can return that directly.
This avoids asking Tor to resolve an IPv6 address, which it cannot do.
2023-06-22 09:43:22 +02:00
Oliver Gugger
13e198fbde
Merge pull request #7777 from yyforyongyu/fix-pprof-redirect
lnd: fix pprof server redirects
2023-06-22 09:20:31 +02:00
yyforyongyu
148732af61
lnd: fix pprof server redirects 2023-06-22 01:23:27 +08:00
yyforyongyu
b04a40e7b3
mod: update btcwallet version 2023-06-22 01:09:15 +08:00
Oliver Gugger
f1bca2a59c
Merge pull request #7774 from yyforyongyu/log-block-sync
lnd: add debug log when syncing blocks
2023-06-20 13:56:07 +02:00
yyforyongyu
2451e6ae50
lnd: fix orders when initializing subsystem loggers
This commit fixed a wrong ordering of initializing subsystem loggers. We
need to make sure "third party" loggers are initialized first such that
when we customize the names later in `lnd`'s packages, the overwriting
of the logger names will take effect.
2023-06-20 18:34:16 +08:00
Oliver Gugger
0d8d0fd261
Merge pull request #7763 from yyforyongyu/enhance-temp-miner
Better temp miner management and more verbose loggings
2023-06-19 10:37:01 +02:00
yyforyongyu
bd205aac13
lnd: add debug log when syncing blocks 2023-06-19 14:53:56 +08:00
yyforyongyu
29124dd3b4
itest+lntest: add helper methods to manage temp miners
This commit adds several methods to easily spawn a temp miner and
connect/disconnect it from the original miner.
2023-06-19 14:04:24 +08:00
yyforyongyu
bacb49ddba
peer+server: provide more verbose logging 2023-06-19 14:04:24 +08:00
Olaoluwa Osuntokun
7f95810359
Merge pull request #7710 from carlaKC/7297-updateaddtlvs
Channeldb: Store HTLC Extra TLVs in Onion Blob Varbytes
2023-06-16 14:31:11 -05:00
Oliver Gugger
02c1261a3d
Merge pull request #7728 from shaurya947/memo-pending-channels
lnrpc+itest: return channel Memo for Pending channels
2023-06-16 18:34:30 +02:00
Oliver Gugger
2e1b6597cf
Merge pull request #7771 from ellemouton/towerConfigDefaults
multi: add tower config defaults
2023-06-16 09:39:49 +02:00
Olaoluwa Osuntokun
f42b6a3949
scripts: update release notes check for merge queue usage
Without this commit, PRs can fail to be merged via the merge queue, as
it'll fail with this error:
```
Run scripts/check-release-notes.sh
PR gh-readonly-queue didn't update release notes
Error: Process completed with exit code 1.
```
2023-06-15 17:48:55 -05:00
shaurya947
44fdd02ab4
lnrpc+itest: return channel Memo for Pending channels
In a previous PR we added a Memo field for channels that could be
specified when opening a channel. This was a reference note-to-self
with no bearing on the functioning of the channel. In that PR, the
memo value was returned only through ListChannels. This commit builds
upon that PR by also returning the Memo field for channels returned by
PendingChannels RPC.
2023-06-15 15:16:06 -04:00
Elle Mouton
7484910968
docs: add release note for 7771 2023-06-15 11:36:44 +02:00
Elle Mouton
255d8bb355
lncfg: remove deprecated PrivateTowerURIs from Wtclient cfg
This commit removes the `PrivateTowerURIs` member from the `WtClient`
config struct. This field has been deprecated since v0.8.0-beta and
currently, LND would fail to start if the field was specified.
2023-06-15 11:36:44 +02:00
Elle Mouton
f3525e8b7c
multi: add default watchtower config to main LND config
In this commit, a `DefaultWatchtowerCfg` function is added which is used
to construct a default `lncfg.Watchtower` struct. This is then used to
populate the default watchtower config in the main LND config struct.
2023-06-15 11:36:44 +02:00
Elle Mouton
d9c4ada991
multi: add wtclient config defaults to lnd config
In this commit, a `DefaultWtClientCfg` function is added which
populates some default values for the `WtClient` struct. This is then
used to populate the wtclient defaults in the main LND config struct.
2023-06-15 11:15:32 +02:00
Olaoluwa Osuntokun
453fbb3358
Merge pull request #7565 from Torakushi/accounts
Fix non-deterministic behaviour for custom accounts
2023-06-14 23:28:42 -05:00
ffranr
51e2da6fbc
walletrpc: allow both txid fields populated during OutPoint unmarshall 2023-06-14 14:07:46 +01:00
ffranr
72a89520d4
walletrpc: export unmarshall lnrpc.OutPoint functionality 2023-06-14 14:07:46 +01:00
Torakushi
be4dae0ec5
update release-notes-0.17 2023-06-14 09:58:54 +02:00
Torakushi
77d3f00c3b
walletrpc+btcwallet: no custom account with various key scopes
Currently, a user can create a custom account with various key scopes.
This is not a desired behaviour.
2023-06-14 09:58:53 +02:00
Torakushi
dd5ed71669
btcwallet: remove LookupAccount because of non-deterministic result
In theory, it should be only one custom account with a given name. However,
users could have created custom accounts with various key scopes. In that case,
'LookupAccount' has a non deterministic behaviour. To fix that, we browse
through all key scopes (deterministically) and return the first account we found.
2023-06-14 09:58:52 +02:00
Torakushi
2ef5ea9742
btcwallet: fix non-deterministic behaviour in ListAccounts
In theory, it should be only one custom account with a given name. However,
due to a lack of check, users could have created custom accounts with various
key scopes. In that case, ListAccounts has to list all these accounts.
2023-06-14 09:58:38 +02:00
Oliver Gugger
cf1f44ab10
Merge pull request #7689 from guggero/housekeeping
Housekeeping (fix small issues, take over stale contributor PRs)
2023-06-13 17:42:53 +02:00
Oliver Gugger
f97f54e088
Merge pull request #7480 from maxwellsayles/fundExpiryOnPending
lnd: compute FundingExpiryBlocks in PendingOpenChannel message
2023-06-13 17:29:15 +02:00
Oliver Gugger
d1002cd218
docs: add contributors to release notes 2023-06-13 11:58:35 +02:00
Satarupa Deb
3835c371c9
watchtowerrpc: updated comments 2023-06-13 11:58:35 +02:00
Lele Calo
acee1d77aa
docker: add support for custom params RPCHOST and RPCCRTPATH
In this commit we add support for two more custom parameters in the
main entrypoint for the `lnd` Docker image script (`start-lnd.sh`)

The two parameters are:
* RPCHOST    to set a custom endpoint for the RPC server
* RPCCRTPATH to set a custom location for the certificate used when
  communicating with the RPC server
2023-06-13 11:58:34 +02:00
zx9r
3a5d67a16b
cmd/lncli: add confirmation to sendcoins 2023-06-13 11:58:34 +02:00
MG-ng
63b32b9e4a
cmd/lncli: add description for payinvoice command 2023-06-13 11:58:34 +02:00
BhhagBoseDK
e3055640aa
sample-lnd.conf: fix typo in comment.
Correcing minor typo.
2023-06-13 11:58:34 +02:00
Aljaz Ceru
d3a5307fc0
cmd/lncli: fix inconsistent argument naming in queryRoutes 2023-06-13 11:58:34 +02:00
Torkel Rogstad
681e3ceede
rpc: verify address is for correct net
Verify that the addresses we're decoding when sending coins onchain are
for the correct network. Without this check we'll convert the users
addresses to their equivalent on other networks, which is a gross
violation of the principle of least astonishment.
2023-06-13 11:58:34 +02:00
gabbyprecious
4ea24c0820
cmd/lncli: add unused flag to newAddr command 2023-06-13 11:58:33 +02:00
Oliver Gugger
03b4d88ed7
docs: mention lnd-itest for testing
Fixes #5418.
2023-06-13 11:58:33 +02:00
Oliver Gugger
7ca7526132
lnrpc: update description for VerifyMessage
Fixes #3596.
2023-06-13 11:58:33 +02:00
Oliver Gugger
31330f1ffc
walletrpc: add note to poorly named field
Fixes #2986.
2023-06-13 11:58:33 +02:00
Oliver Gugger
56dba2df03
multi: update linter, fix new issues 2023-06-13 11:58:33 +02:00
Maxwell Sayles
987b54f52e funding: update release notes to mention funding_expiry_blocks in
`PendingOpenChannel`.
2023-06-12 10:08:18 -07:00
Maxwell Sayles
f7bdbb9e73 funding: integration test to verify the value of FundingExpiryBlock on
pending channels that are waiting for funding confirmation.
2023-06-12 10:04:04 -07:00
Maxwell Sayles
663b28808a funding: provide FundingExpiryBlock field in PendingOpenChannel message. 2023-06-12 10:04:04 -07:00
Maxwell Sayles
9dea695079 funding: make MaxWaitNumBlocksFundingConf public to be used to compute
`FundingExpiryBlocks`.
2023-06-12 10:04:04 -07:00
Oliver Gugger
e549096b88
Merge pull request #7687 from morehouse/fuzz_addr_iter
wtclient: AddressIterator fuzz test
2023-06-12 12:25:08 +02:00
Oliver Gugger
6931a544e1
Merge pull request #7747 from ardevd/gen_protos_full_image_name
fix: use full image name for gen_protos_docker.sh
2023-06-12 11:13:11 +02:00
Oliver Gugger
753af11ed6
Merge pull request #7730 from guggero/grpc-keepalive
config+grpc: allow configuring gRPC keepalive params
2023-06-10 13:45:50 +02:00
Oliver Gugger
bf3668240f
docs: add release notes 2023-06-09 10:57:37 +02:00
Oliver Gugger
1515266269
sample-lnd.conf: describe grpc keepalive params 2023-06-09 10:57:37 +02:00
Oliver Gugger
f9f8f6406b
config+lnd: allow configuring gRPC keepalive settings
This change allows users to customize the gRPC keepalive settings. The
server ping values configure when the server sends out a ping by itself
and how quickly the client is expected to respond.
The client ping min wait configures the minimum time a client has to
wait before sending another ping. A connection might be closed by the
server if a client pings more frequently than the allowed min wait time.

We choose lower default values than the gRPC library used before:
 - ServerPingTime: 1 minute instead of 2 hours
 - ClientPingMinWait: 5 seconds instead of 5 minutes

This should by itself already make long-standing gRPC streams more
stable but also allow clients to set a custom client ping time of 5
seconds or more (a value of slightly more than 5000 milliseconds should
be chosen to avoid the server disconnecting due to slight timing skews).
2023-06-09 10:57:36 +02:00
Oliver Gugger
0005adaac8
Merge pull request #7752 from yyforyongyu/improve-logging
contractcourt: improve logging for failing dangling htlcs
2023-06-08 18:31:44 +02:00
yyforyongyu
3857b9e9a6
contractcourt: improve logging for failing dangling htlcs 2023-06-07 17:34:06 +08:00
ardevd
88e8bae75c fix: use full image name for gen_protos_docker.sh
By defining the full name for the docker image we avoid the issue that
occurs when using `podman` (tested on Fedora 38) where podman will prompt the
user for what docker repository to pull the image from.
2023-06-06 00:30:37 +02:00
Oliver Gugger
6833df5236
Merge pull request #7742 from Roasbeef/multimutex-param
multimutex: remove HashMutex, make Mutex type a type param
2023-06-05 09:43:10 +02:00
Oliver Gugger
8f382ffd95
Merge pull request #7238 from morehouse/chain_arbitrator_nit
contractcourt: fully use chanPoint variable
2023-06-05 09:41:45 +02:00
Carla Kirk-Cohen
8a9dd105fc
docs: add release notes 2023-06-02 11:01:45 -04:00
Carla Kirk-Cohen
7b1a288320
channeldb: store extra HTLC data in variable onion blob slot
Take advantage of the variable byte encoding for a known length field
to extend HLTCs with additional data.
2023-06-02 11:01:44 -04:00
Carla Kirk-Cohen
2fc8e9d617
multi: update channel db HTLC OnionBlob to array
We know that onion blobs in lightning are _exactly_ 1366 bytes in
lightning, but they are currently expressed as a byte slice in
channeldb's HTLC struct. Blobs are currently serialized as var bytes,
so we can take advantage of this known length and variable length
to add additional data to the inline serialization of our HTLCs, which
are otherwise not easily extensible (without creating a new bucket).
2023-06-02 11:01:43 -04:00
Olaoluwa Osuntokun
a7d6826f60
multimutex: remove HashMutex, make Mutex type a type param
In this commit, we eliminate some code duplication by removing the old
`HashMutex` struct as it just duplicates all the code with a different
type (uint64 and hash). We then make the main Mutex struct take a type
param, so the key can be parametrized when the struct is instantiated.
2023-06-01 17:39:49 -07:00
Matt Morehouse
c4be15205f
docs: release note for #7687. 2023-06-01 08:49:42 -05:00
Matt Morehouse
f53c8d6e91
wtclient: AddressIterator fuzz test
Test AddressIterator for the absence of panics, nil addresses, and empty
lists.

This fuzz test finds https://github.com/lightningnetwork/lnd/issues/7552
in seconds. No other panics found after 300+ CPU-hours of fuzzing.
2023-06-01 08:46:45 -05:00
Matt Morehouse
da10cb95b5
contractcourt: fully use chanPoint variable
When we create a temporary chanPoint variable to shorten up the code, we
should use it everywhere for consistency and clarity.
2023-05-31 10:56:08 -05:00
Oliver Gugger
f9d4600ff8
Merge pull request #7645 from shaurya947/bitcoind-minmempoolfee
sweep+lnrpc: enforce provided fee rate is no less than relay fee
2023-05-30 13:15:22 +02:00
Olaoluwa Osuntokun
20c1af9af6
Merge pull request #7726 from Roasbeef/htlc-must-sweep
contractcourt: force the sweeper to always resolve outgoing HTLCs
2023-05-29 12:49:32 -07:00
Olaoluwa Osuntokun
f170f8e104
docs/release-notes: add release notes for adamant htlc sweeps 2023-05-29 12:49:07 -07:00
Olaoluwa Osuntokun
7686d10075 contractcourt: force the sweeper to always resolve outgoing HTLCs
In this commit, we attempt to fix an issue that may lead to force closes due
to small value HTLCs. The sweeper has built in a "negative yield" heuristic
where it won't sweep something that'll result in paying more fees than the
HTLC amount. However for HTLCs, we want to always sweep them, as we don't
cancel back the HTLCs before the outgoing contract is fully resolved.

In the future, we'll start to make more uneconomical decisions about if we
should go to chain at all for small value HTLCs, and also do things like
cancel back early if the HTLC is small and we think we might be contested by
chain fees.
2023-05-26 15:15:36 -07:00
shaurya947
e2bd34b72c
docs: update release notes for 0.17 2023-05-26 11:16:52 -04:00
shaurya947
85ab96cd09
lnrpc: move CalculateFeeRate from rpcserver.go to rpc_utils.go
This refactor aims to house the CalculateFeeRate function in a more
"shareable" location. It used to be a non-exported function inside
of rpcserver.go. However, other routines, such as FundPsbt inside
of walletkit_server.go, could also rely on the same fee calculation
functionality. So we move the function to rpc_utils.go and export it,
and we will reuse it in the FundPsbt workflow in a future PR.
2023-05-26 11:16:51 -04:00
shaurya947
25097f0993
sweep: update fee estimator fee-below-floor test case
Handle error in test case, as well as add new test case for below
relay fee input.
2023-05-26 11:16:51 -04:00
shaurya947
2292f3fbd0
sweep: use relay fee rate as floor for specified fee rate
This ensures that for transactions where a fee rate is specified
(instead of a confirmation target), lnd doesn't accept transactions
which would be ultimately ignored by the underlying chain's RPC.
2023-05-26 11:16:42 -04:00
Oliver Gugger
bbbf7d33fb
Merge pull request #7722 from yyforyongyu/fix-payment-stream
routing+lnrpc: subscribe payment stream before sending it
2023-05-24 16:51:16 +02:00
Olaoluwa Osuntokun
b9b20acd41
Merge pull request #7711 from Roasbeef/commit-dance-stall-disconnect
htlcswitch+peer: actually actually disconnect if we detect a stalled remote channel state machine
2023-05-23 14:17:07 -07:00
Olaoluwa Osuntokun
4d633f04e3
htlcswitch: add new LinkFailureDisconnect action
In this commit, we add a new LinkFailureDisconnect action that'll be
used if we detect that the remote party hasn't sent a revoke and ack
when it actually should.

Before this commit, we would log our action, tear down the link, but
then not actually force a connection recycle, as we assumed that if the
TCP connection was actually stale, then the read/write timeout would
expire.

In practice this doesn't always seem to be the case, so we make a strong
action here to actually force a disconnection in hopes that either side
will reconnect and keep the good times rollin' 🕺.
2023-05-23 12:25:11 -07:00
Olaoluwa Osuntokun
cb5fc71659
htlcswitch: add new LinkFailureAction enum
In this commit, we add a new LinkFailureAction enum to take over the old
force close bool. Force closing isn't the only thing we might want to do
when we decide to fail the link, so this is a prep refactoring for an
upcoming change.
2023-05-23 12:24:55 -07:00
yyforyongyu
9ae4511a6f
itest: make sure invoice is settled in multi hop htlc test 2023-05-24 02:38:40 +08:00
Oliver Gugger
7dacf5edb9
Merge pull request #7709 from morehouse/fuzz_require
lnwire,wtwire: use require package for fuzz tests
2023-05-23 19:55:06 +02:00
Oliver Gugger
15525ff74c
Merge pull request #7618 from morehouse/derandomize_brontide_fuzz
brontide: deterministic fuzz targets
2023-05-23 16:36:38 +02:00
Matt Morehouse
c38bb899bb
docs: release note for #7709 2023-05-23 08:38:17 -05:00
Matt Morehouse
4c2e712581
wtwire: use require package for fuzz tests
Simplify code by using the require package instead of t.Fatal().
2023-05-23 08:37:22 -05:00
Matt Morehouse
460ba4ad82
lnwire: use require package for fuzz tests
Simplify code by using the require package instead of t.Fatal().
2023-05-23 08:37:22 -05:00
Matt Morehouse
354133e41e
docs: release note for #7618 2023-05-23 08:34:36 -05:00
Matt Morehouse
bad4a66279
brontide: derandomize fuzz tests
It is best to have deterministic fuzz targets, so that if a failure
occurs, it can be easily reproduced.

This commit swaps the cryptographically secure RNG for a deterministic
one seeded from fuzzer input.
2023-05-23 08:32:13 -05:00
Matt Morehouse
eb31d47094
brontide: remove handshake helper function
Move the functionality directly into completeHandshake instead. If a
failure does happen at any point during the handshake, it is beneficial
to know which line it happens on for debugging. The helper function was
hiding this information.
2023-05-23 08:32:13 -05:00
Matt Morehouse
6397497bb6
brontide: s/nilAndPanic/dumpAndFail
The nilAndPanic function does not actually nil the Curve fields as it
claims. dumpAndFail is a more descriptive name.
2023-05-23 08:32:10 -05:00
yyforyongyu
775032de29
docs: add release note for payment stream fix 2023-05-23 21:26:09 +08:00
yyforyongyu
de01e412d6
routing+lnrpc: subscribe payment stream before sending it
This commit moves the subscription of a given payment before it's been
sent so we won't miss any events.
2023-05-23 21:26:09 +08:00
Oliver Gugger
b95faaba45
Merge pull request #7720 from ellemouton/updateReleaseNotes
docs: move entry for 7705 to 0.16.3
2023-05-23 09:07:40 +02:00
Elle Mouton
dbc83f4e9e
docs: move entry for 7705 to 0.16.3 2023-05-23 06:55:36 +02:00
Oliver Gugger
8c58730c34
Merge pull request #7693 from gcaracuel/lncli_env_global_flags
lncli: Global flags to accept ENV vars overrides
2023-05-22 22:15:57 +02:00
gcaracuel
12e7c24520
lncli: Global flags to accept ENV vars overrides. 2023-05-22 17:13:18 +02:00
Oliver Gugger
a043cca77a
Merge pull request #7712 from ErikEk/neutrinorpc-deprecate-getblockhash
Neutrinorpc: deprecate getblockhash
2023-05-22 12:16:04 +02:00
erik
eff055e464 docs: release notes 2023-05-22 16:26:18 +07:00
erik
9ce02b96fe neutrinorpc: deprecate getblockhash 2023-05-22 16:26:10 +07:00
Oliver Gugger
3d53d6909a
Merge pull request #7681 from yyforyongyu/btcwallet-mempool
mod: update btcwallet's version
2023-05-22 10:24:17 +02:00
Oliver Gugger
d5f5565e50
Merge pull request #7494 from morehouse/fuzz_ci
github: run fuzz tests with unit tests
2023-05-22 10:14:44 +02:00
Matt Morehouse
59bd7b0538
docs: release note for #7494 2023-05-19 15:51:19 -05:00
Matt Morehouse
acace4d330
github: run fuzz tests with unit tests
We download and extract the fuzzing seed corpora into the LND tree so
that "make unit" automatically runs the fuzz tests on the seeds.
2023-05-19 15:48:11 -05:00
yyforyongyu
403b937dca
docs: add release notes 0.16.3 2023-05-20 00:33:56 +08:00
yyforyongyu
0b64ba94c0
itest: cleanup channels for testSwitchOfflineDeliveryOutgoingOffline 2023-05-20 00:33:56 +08:00
yyforyongyu
931481c4fe
itest: make sure edges are updated in mpp tests 2023-05-20 00:33:56 +08:00
yyforyongyu
c6cfc425a0
lntest+itest: clean mempool in testHtlcTimeoutResolverExtractPreimageRemote 2023-05-20 00:33:04 +08:00
Oliver Gugger
ac3e7be9a0
Merge pull request #7668 from shaurya947/open-channel-memo
multi: accept memo note when opening channel
2023-05-19 16:13:13 +02:00
Oliver Gugger
0a2d6b61aa
Merge pull request #7707 from ellemouton/wtclientFixes
watchtower: miscellaneous fixes
2023-05-19 12:22:04 +02:00
yyforyongyu
7f4bf7ce2b
mod: update btcwallet's version 2023-05-19 16:36:21 +08:00
shaurya947
be820919f0
docs: update release notes for 0.17.0 2023-05-18 13:02:30 -04:00
shaurya947
84fff6e0a7
itest: update channel creation itest with Memo field logic
We test both the happy path (valid memo is returned when querying),
as well as the unhappy path (invalid memo rejects the open action).
To accomplish this, we update the OpenChannelParams struct inside
the harness to accept the Memo.
2023-05-18 13:02:30 -04:00
shaurya947
c8e4d8e69b
rpcserver: attach channel Memo to *lnrpc.Channel struct
This allows us the memo to be returned in responses such as
listchannels.
2023-05-18 13:02:30 -04:00
shaurya947
396a4cb6c4
channeldb: persist channel Memo field and read it when fetching
We add a Memo field to the OpenChannel DB struct. We also persist
it using a tlv record. We then pass the Memo value from the
InitFundingReserveMsg when creating a new reservation for the channel.
Finally, we also read Memo field when fetching channel from DB.
2023-05-18 13:02:30 -04:00
shaurya947
db44924c5a
lnwallet: add Memo to InitFundingReserveMsg
We also pass the value of Memo from funding/manager.go.
2023-05-18 13:02:30 -04:00
shaurya947
7c6faa4c98
funding: add Memo to InitFundingMsg struct
We add byte-array field called Memo to the InitFundingMsg struct.
We also provide a value for this from
rpcserver.go#parseOpenChannelReq().
2023-05-18 13:02:30 -04:00
shaurya947
1724409647
rpcserver: enforce memo length is less than 500 characters
In this commit we ensure that the string length of the memo field
specified as part of the OpenChannelRequest is no longer than 500.
2023-05-18 13:02:24 -04:00
shaurya947
373e445cdc
lncli: add optional memo flag to openchannel cmd
This commit simply adds a new memo flag to the openchannel command.
Memo could be any note-to-self kind of useful information to go
along with the channel. The value isn't used yet, will be in the
next commit.
2023-05-18 12:51:18 -04:00
shaurya947
9feb3dd920
lnrpc: add memo field to OpenChannelRequest and ListChannelsResponse
This commit adds the memo field to the protobuf message and generates
the new go files.
2023-05-18 12:50:19 -04:00
Elle Mouton
8abe2f89e1
watchtower: use a stable blob identifier
In this commit, we add an Identifier method to the blob.Type struct
which returns a unique identifier for a given blob type. This identifier
is then used for initialising the disk overflow queue of the given
client.
2023-05-18 15:17:22 +02:00
Elle Mouton
db145bfd8e
wtclient: check un-checked errors
Some errors are not checked during startup and shutdown of the tower
client. These are checked now.
2023-05-18 15:13:24 +02:00
Matt Morehouse
c50d7048d6
docs: release note for #7177 2023-05-17 11:31:21 -05:00
Matt Morehouse
a8a50f32f5
funding: fix channel type negotiation bug
The bug manifests when a nil ChannelType is passed to the funding
manager in InitFundingMsg. A default value for ChannelType is selected
and sent in the OpenChannel message. However, a nil ChannelType is
stored in the reservation context. This causes our ChannelType checks in
handleFundingAccept to be bypassed.

Usually this makes us end up in the "peer unexpectedly sent explicit
ChannelType" case, where we can still recover by reselecting a default
ChannelType and verifying it matches the one the peer sent. But if the
peer sends a nil ChannelType, we miss it.

While fixing the bug, I also tried to simplify the negotiation logic, as
the complexity is likely what hid the bug in the first place.

Now negotiateCommitmentType only returns the ChannelType to be used in
OpenChannel/AcceptChannel and the CommitmentType to pass to the wallet.
It will even return a nil ChannelType when we're supposed to use implicit
negotiation, so we don't need to manually set it to nil for OpenChannel
and AcceptChannel.
2023-05-17 11:28:40 -05:00
Matt Morehouse
0ae9c63d64
funding: make expectsChanType a pointer
This allows us to expect chanType to be nil, which will be possible
after the next commit.
2023-05-17 11:27:41 -05:00
Matt Morehouse
34186dee19
funding: remove incorrect and repetitive comments
We don't actually do the logging described in the first comment, and the
second comment block repeats much of the first comment block.
2023-05-17 11:27:41 -05:00
Matt Morehouse
e59cd7f91d
funding: stop naming commit types chanType
negotiateCommitmentType returns both a chanType and a commitType, so it
is really confusing when the commitType is called chanType instead.
2023-05-17 11:27:41 -05:00
Matt Morehouse
ec85b5be72
funding: rename channelType parameter
This prevents us from confusing the channelType parameter with the
chanType local.
2023-05-17 11:27:41 -05:00
Oliver Gugger
2fd40d16f1
Merge pull request #7705 from ellemouton/macStoreRootKeyReEncyption
macaroons: ensure all root keys are re-encrypted or regenerated
2023-05-17 16:30:48 +02:00
Elle Mouton
0787cb1178
docs: add release note for 7705 2023-05-17 14:44:17 +02:00
Elle Mouton
f9d99153e0
macaroons: let ChangePassword re-encrypt all root keys
The ChangePasswords method should re-encrypt all the root keys found
in the store, not just the default root key.
2023-05-17 14:44:15 +02:00
Elle Mouton
5ffe5552db
macaroons: demo ChangePassword bug
This commits uses TestStoreChangePassword to demonstrate that currently
the ChangePassword function only changes the password of the default
root key and not that of other root keys. This will be fixed in an
upcoming commit.
2023-05-17 14:42:29 +02:00
Elle Mouton
d43ef314d3
macaroons: Let GenerateNewRootKey be applied to all root keys
With this commit, GenerateNewRootKey will regenerate the Default root
key and will then also check if any other root keys exist and regenerate
those as well.
2023-05-17 14:06:32 +02:00
Elle Mouton
00ff934169
macaroons: demo GenerateNewRootKey bug
This commit adds to the existing TestStoreGenerateNewRootKey to show
that the method only successfully regenerates the root key in the
default root key ID location. This will be fixed in an upcoming commit.
2023-05-17 14:02:57 +02:00
Oliver Gugger
bdb41e5867
Merge pull request #7380 from ellemouton/wtclientDiskQueue
watchtower: replace in-mem task queue with a disk over-flow queue
2023-05-16 12:28:53 +02:00
Elle Mouton
250d764256
docs: add release note for 7380 2023-05-16 10:57:50 +02:00
Elle Mouton
1cdf15a39b
server+lncfg: make max in-mem tasks configurable
Add a `MaxTasksInMemQueue` field to the `WtClient` config so that users
can change the default if they please.
2023-05-16 10:57:50 +02:00
Elle Mouton
56cd825695
watchtower: replace taskpipeline with disk overflow queue 2023-05-16 10:57:50 +02:00
Elle Mouton
e91fe50878
watchtower/wtclient: generic disk overflow queue
In this commit, a new generic DiskOverflowQueue implementation is added.
This allows a user to specify a maximum number of items that the queue
can hold in-memory. Any new items will then overflow to disk. The
producer and consumer of the queue items will interact with the queue
just like a normal in-memory queue.
2023-05-16 10:57:50 +02:00
Elle Mouton
66f6bf3955
watchtower/wtmock: add in-memory impl of Queue
This commit adds an in-memory implementation of the Queue interface.
This can be used for tests.
2023-05-16 10:57:49 +02:00
Elle Mouton
5cc7438d33
watchtower/wtdb: add bolt db impl of Queue
This commit adds a new generic DiskQueueDB type which is an
bbolt implementation of the Queue interface.
2023-05-16 10:57:49 +02:00
Elle Mouton
a946715b7e
watchtower/wtdb: add a generic Queue interface 2023-05-16 10:57:49 +02:00
Elle Mouton
01e2f10797
wtclient: demo that in-mem updates are lost
This commit adds a test to the wtclient. The test demonstrates that if a
client tries to back up states while it has no active sessions with a
server then those updates are accumlated in memory and lost on restart.
This will be fixed in upcoming commits.
2023-05-16 10:57:49 +02:00
Oliver Gugger
51a23b0901
Merge pull request #7688 from bshramin/update-docker-images
Update docker images
2023-05-15 19:12:59 +02:00
Amin Bashiri
a455b9166d lnrpc: update docker base image version 2023-05-15 10:21:47 -06:00
Amin Bashiri
35c0bd8f81 ltcd: update docker base image version 2023-05-15 10:21:39 -06:00
Amin Bashiri
7b6a45bcbf btcd: update docker base image version 2023-05-15 10:21:30 -06:00
Oliver Gugger
d8eb6dab82
Merge pull request #7649 from morehouse/fuzz_lnwire_signature
lnwire: signature parsing/conversion fuzz tests
2023-05-12 18:35:06 +02:00
Matt Morehouse
55aa7a7bb2
docs: release note for #7649 2023-05-12 11:08:54 -05:00
Matt Morehouse
e198e6693f
lnwire: add FuzzConvertFixedSignature test
Test conversion of fixed 64-byte signatures to DER-encoded signatures.
2023-05-12 11:07:57 -05:00
Matt Morehouse
a6a7066454
lnwire: add FuzzParseRawSignature test
Test parsing and serialization of raw DER-encoded signatures.
2023-05-12 11:07:54 -05:00
Oliver Gugger
c2d2d448fb
Merge pull request #7486 from sangaman/amt-paid-accepted
lnrpc: update docs for invoice amt_paid
2023-05-12 12:26:15 +02:00
Oliver Gugger
58a73bae39
Merge pull request #7049 from MStreet3/bug/fix-race-neutrinotest
Bug/fix race neutrinotest
2023-05-12 09:23:14 +02:00
Michael Street
5e33e790c5
docs: adds release notes 2023-05-11 18:30:38 -04:00
Michael Street
e73f54ec5d
deps: bumps btcwallet version 2023-05-11 18:24:18 -04:00
Oliver Gugger
71c4e72fad
Merge pull request #7659 from guggero/lncli-json-hex-replacement
lncli: replace deprecated fork for serializing protobuf as JSON with new one
2023-05-12 00:17:29 +02:00
Oliver Gugger
301be1bb08
docs: add release notes 2023-05-11 22:52:52 +02:00
Oliver Gugger
5583926fb9
lint: allow security replace directives 2023-05-11 22:52:52 +02:00
Oliver Gugger
b5d23bba06
mod+lnrpc: use hex encoding jsonpb fork 2023-05-11 22:52:52 +02:00
Oliver Gugger
9615ce20d6
mod: bump github.com/ulikunitz/xz to v0.5.11
There is a CVE (CVE-2021-29482) out there for versions previous to
v0.5.11 of the xz library.
2023-05-11 22:52:51 +02:00
Oliver Gugger
451f033855
mod: remove unused replace directive
With recent updates to some of our dependencies, the
github.com/dgrijalva/jwt-go package is not referenced in any transitive
dependency anymore which allows us to remove one of the replace
directives which was added as a security precaution before.
2023-05-11 22:52:51 +02:00
Oliver Gugger
ea8fe6f3f3
mod+lnrpc: bump google.golang.org/protobuf to v1.30.0 2023-05-11 22:52:00 +02:00
Oliver Gugger
f9436ec05d
mod+cmd/lncli: use google.golang.org/protobuf package 2023-05-11 22:51:16 +02:00
Oliver Gugger
fd9adaf6ce
Merge pull request #7646 from yyforyongyu/itest-reduce-blocks
itest: mine less blocks to speed up tests
2023-05-10 13:09:12 +02:00
Oliver Gugger
ae30581c3f
Merge pull request #7356 from ziggie1984/benchmarking-fundinglocked
Fix Benchmark Test (BenchmarkReadMessage/Funding_Locked) in the lnwire  package
2023-05-10 10:22:28 +02:00
yyforyongyu
1dc66302cd
itest: fix test flake in testHtlcTimeoutResolverExtractPreimageRemote 2023-05-10 02:01:54 +08:00
ziggie
0c31eb72e7
docs: add release notes for 0.17.0 2023-05-09 16:53:30 +02:00
ziggie
469dfd5f42
make: add benchmark tests
Add benchmark tests as a separate test run besides the current
unit tests.
2023-05-09 16:47:47 +02:00
ziggie
8f4e9d68d0
lnwire_test: fix BenchmarkReadMessage test
The addition of AliasScid in the tlv_stream field of the
funding_locked msg made the requirement for testdata of the
ExtraOpaqueData part for the funding_locked msg type more strict.
Now the input testdata for the funding_locked test is more specific
and includes the new added AliasScid tlv record.
2023-05-09 16:47:44 +02:00
yyforyongyu
3f2675f10d
itest: remove potential parallel usage of the watchtower default port 2023-05-09 21:41:53 +08:00
yyforyongyu
4bbb4ed978
lntest: skip killing dead process 2023-05-09 21:41:53 +08:00
yyforyongyu
cdc6f63f17
itest: reorder test cases to even out blocks per tranche 2023-05-09 21:41:53 +08:00
yyforyongyu
e018c02d40
itest: refactor createThreeHopNetwork to open channels async
This will save us 6 blocks each time we call this function.
2023-05-09 21:41:53 +08:00
Oliver Gugger
8df4edef1b
Merge pull request #7624 from ellemouton/marshalBytesAndStringTxid
multi: populate both string and byte TXID in lnrpc.Outpoint
2023-05-08 17:32:54 +02:00
Oliver Gugger
eaa8aa7496
Merge pull request #7678 from erikarvstedt/fix-cert-key-plaintext-detection
Restore support for `PKCS8`-encoded cert private keys
2023-05-08 15:12:41 +02:00
Erik Arvstedt
d21abf9fc0 docs: update release notes 2023-05-08 10:29:06 +02:00
Erik Arvstedt
3004deb045 lnd: Restore support for PKCS8-encoded cert private keys
c0f44a17b7, available since `v0.16.x`,
broke support for certificate private keys encoded in the widely-used
`PKCS8` format.
2023-05-08 07:33:25 +02:00
rockstardev
15d920456a Accepting signet as LND_ENVIRONMENT variable 2023-05-07 22:41:53 -05:00
Olaoluwa Osuntokun
04314d3254
Merge pull request #7667 from ziggie1984/log-fix-typo
[skip ci] htlcswitch: fix double sat/kw output
2023-05-04 11:59:54 -05:00
Oliver Gugger
728452636a
Merge pull request #7568 from carlaKC/7094-updatefeaturemanager
Add config options for custom feature bits
2023-05-04 18:35:23 +02:00
Carla Kirk-Cohen
820920a749
docs: add release notes 2023-05-04 10:42:44 -04:00
Carla Kirk-Cohen
ad6ccb415f
lncli: fix typo in updatenodeannouncement 2023-05-04 10:42:37 -04:00
Carla Kirk-Cohen
019da315a8
itest: add coverage for custom features 2023-05-04 10:42:17 -04:00
Carla Kirk-Cohen
fe7cad2695
features: disallow unsetting of config-set features 2023-05-04 10:35:49 -04:00
Carla Kirk-Cohen
4e36e2fd2b
multi: add custom feature bits to config options 2023-05-04 10:35:48 -04:00
Carla Kirk-Cohen
4e98f4da5e
feature/refactor: unexport set raw 2023-05-04 10:35:47 -04:00
Carla Kirk-Cohen
e41c65785f
multi: update node announcement features in feature manager first
Move merge of our features into the feature manager, rather than
updating our node announcement then retrospectively setting the
feature manger's set to the new vector. This allows us to use the
feature vector as our single source of truth for announcements.
2023-05-04 10:35:46 -04:00
Carla Kirk-Cohen
019127c4f4
multi: add restriction on maximum feature bit in invoices
Base 32 encoded bolt 11 invoices only allow 10 bits to express the
length of the feature vector in a tagged field, so there is a much
lower limit on the values invoice custom features can hold.

Other places in the protocol are theoretically limited by the maximum
message size, but since we express a feature bit as u16 we don't need
to be concerned about this.

The decision is made to track maximum per-set in the feature manager,
which is conceptually aware of sets and then validate in lnwire/features
against some arbitrary maximum value provided to the caller to keep
the base features package unaware of sets.
2023-05-04 10:35:45 -04:00
Carla Kirk-Cohen
5a139fd297
feature: add update function for safe feature update
Disallow update of any features that are defined by LND (since
just updating the feature, but not the functionality will result in
strange behavior). All known feature bits should be toggled using
protocol config options.
2023-05-04 10:35:44 -04:00
Carla Kirk-Cohen
1a9d743e18
lnwire: add feature vector update validation helpers 2023-05-04 10:35:43 -04:00
Carla Kirk-Cohen
3f9f0ea5d1
multi/refactor: separate methods for get and set node announcement
In preparation for a more complex function signature for set node
announcement, separate get and set so that readonly callers don't need
to handle the extra arguments.
2023-05-04 10:35:42 -04:00
Carla Kirk-Cohen
c6263c2fe6
multi/refactor: move node ann modification outside of sign method
In preparation for moving feature bit modification inside of the
feature manager, separate node modification from signing.
2023-05-04 10:35:41 -04:00
ziggie
1519742f8a
[skip ci] htlcswitch: fix double sat/kw output 2023-05-04 15:38:51 +02:00
Oliver Gugger
c6b736b169
Merge pull request #7631 from hieblmi/sendoutputs-reserve
rpc: anchor reserve check for `SendOutputs`
2023-05-04 10:30:32 +02:00
Slyghtning
79a06d1918 docs: update release notes 2023-04-29 22:44:26 +02:00
Slyghtning
77322dddb8 itest: anchor reserve test for SendOutputs 2023-04-29 22:44:26 +02:00
Slyghtning
8f5910bf91 rpc: fix code style 2023-04-29 22:44:26 +02:00
Slyghtning
903b5dde89 rpc: SendOutputs considers anchor reserve 2023-04-29 22:44:23 +02:00
rockstardev
cd70936a77 Adding BtcPayServer related files and resources 2023-04-29 08:39:47 -05:00
Olaoluwa Osuntokun
3c8c057ea9
Merge pull request #7641 from Roasbeef/btcwallet-async
build: update to btcwallet version with async mempool scan
2023-04-28 14:02:10 -05:00
Olaoluwa Osuntokun
33047e69d9
Merge pull request #7647 from yyforyongyu/skip-checkpoint-resolver
contractcourt: skip checkpoint htlc outgoing resolver if it's resolved
2023-04-28 14:01:14 -05:00
yyforyongyu
186569c610
contractcourt: skip checkpoint timeout resolver upon mempool spend
Previously when a block spend is found for the outpoint, our htlc
timeout resolver will do a checkpoint, which implicitly creates a db
record if there isn't one. Now, if the spend is found in mempool,
the resolver will be deleted once the contract is resolved. Later on
when the spend is found in the block again, the resolver will be created
again, but never gets resolved this time.
2023-04-28 20:38:01 +08:00
yyforyongyu
56dcda0f7c
contractcourt: add debug logs for unresolved contracts 2023-04-28 20:38:00 +08:00
Oliver Gugger
35917eb858
Merge pull request #7643 from ellemouton/lastFewFundingLockeds
multi: catch a few uncaught instances of "funding locked"
2023-04-28 10:05:16 +02:00
Olaoluwa Osuntokun
239da9268c
build: update to btcwallet version with async mempool scan
This version of btcwallet demotes some spammy logs (txns replaced in the
mempool), and makes the initial mempool scan async.

Fixes https://github.com/lightningnetwork/lnd/issues/7640
2023-04-27 16:27:26 -05:00
Elle Mouton
ef17b12a86
funding: update "funding locked" in error string
Replace a few uncaught instances of "funding locked" found in error
strings with "channel_ready"
2023-04-27 20:03:44 +02:00
Elle Mouton
9ea3f55694
multi: update "funding locked" comments
Replace a few un-caught instances of "funding locked" in some comments
with "channel_ready"
2023-04-27 20:02:34 +02:00
Oliver Gugger
7854b73892
Merge pull request #7592 from sangaman/gen-default-macaroons-independently
lnd: generate default macaroons independently
2023-04-27 14:04:27 +02:00
rockstardev
2f4b515afc Adding BtcPayServer related files and resources 2023-04-26 14:34:42 -05:00
Daniel McNally
16463d4bd4
lnd: generate default macaroons independently
This modifies the `genMacaroons` logic to indepently check for each of
the three default macaroons (admin, readonly, invoice) and generate
whichever are missing. Previously, this was an all or nothing routine.
In other words, either all three didn't exist on disk and all three are
created, or no macaroons are created. Although that works for the first
run of a new node, it can result in inconsistent states if only one or
two of the macaroons is deleted.

See https://github.com/lightningnetwork/lnd/discussions/7566.
2023-04-26 13:30:03 -04:00
Oliver Gugger
fdc1ae9d57
Merge pull request #7635 from GeorgeTsagk/node-sync-err
routing: log node pubkey as hex
2023-04-26 08:59:07 +02:00
Oliver Gugger
0bc82d3038
Merge pull request #7637 from yyforyongyu/fix-itest-panic
Fix panic when canceling rebroadcast for neutrino backend
2023-04-26 08:58:39 +02:00
yyforyongyu
403c1baca6
lnd: skip canceling rebroadcast for neutrino backend 2023-04-26 10:38:13 +08:00
George Tsagkarelis
dd93fc2539
routing: log node pubkey as hex 2023-04-25 21:27:24 +03:00
Elle Mouton
7b186716a1
multi: populate both string and byte TXID in lnrpc.Outpoint
This commit adds a a new `MarshalOutPoint` helper in the `lnrpc` package
that can be used to convert a `wire.Outpoint` to an `lnrpc.Outpoint`.
By using this helper, we are less likely to forget to populate both the
string and byte form of the TXID.
2023-04-24 16:19:26 +02:00
Oliver Gugger
4355ce62d2
Merge pull request #7623 from ellemouton/queueBackupIDOnly
wtclient: queue backup id only
2023-04-24 15:36:09 +02:00
Elle Mouton
9a1ed8c7b2
docs: update release notes 2023-04-24 13:15:40 +02:00
Elle Mouton
08cde98869
wtclient: add mutex locking in perUpdate
Lock the `backupMu` when accessing `c.chanCommitHeights` in the `New`
function. It is not strictly necessary right now but good to add it so
that there is no accidental oversight if the `perUpdate` method is ever
extracted and reused in future.
2023-04-24 13:15:40 +02:00
Elle Mouton
65dc20f2cc
wtclient: let task pipeline only carry wtdb.BackupID
Since the retrubution info of a backup task is now only constructed at
the time that the task is being bound to a session, the in-memory queue
only needs to carry the BackupID of the task.
2023-04-24 13:15:40 +02:00
Elle Mouton
2371bbf09a
wtclient: only fetch retribution info when needed.
Only construct the retribution info at the time that the backup task is
being bound to a session.
2023-04-24 13:15:40 +02:00
Elle Mouton
458ac32146
multi: build retribution info in TowerClient
Since the TowerClient now has a callback that it can use to retrieve the
retribution for a certain channel and commit height, let it use this
call back instead of requiring the info to be passed to it through
BackupState.
2023-04-24 13:15:40 +02:00
Elle Mouton
530a8cae5d
wtclient: lint the package
This commit fixes some lints in the wtclient package. This is done so
that upcoming logic changes are easier to parse.
2023-04-24 13:15:40 +02:00
Elle Mouton
85ec38f447
multi: pass BuildBreachRetribution callback to tower client
In this commit, a new BuildBreachRetribution callback is added to the
tower client's Config struct. The main LND server provides the client
with an implementation of the callback.
2023-04-24 13:15:40 +02:00
Elle Mouton
fe2304efad
channeldb: add a FetchChannelByID method
Add a FetchChannelByID method that allows a caller to fetch an
OpenChannel using an lnwire.ChannelID.
2023-04-24 13:15:40 +02:00
Elle Mouton
63442cbe51
channeldb: factor out generic FetchChannel logic
This commit introduces a new `channelSelector` method and moves all
generic logic from `FetchChannel` to it. This refactor will make it
easier to add new methods that require the same open-channel db
traversal with slightly different channel selection logic.
2023-04-24 13:15:39 +02:00
Elle Mouton
908cb6060b
channeldb: optimise FetchChannel method
This commit adds a small optimisation to the FetchChannel method.
Instead of iterating over each channel bucket, an identifiable error is
thrown once the wanted channel is found so that the iteration can stop
early.
2023-04-24 13:10:13 +02:00
Elle Mouton
aebdd2375c
channeldb: lint FetchChannel method
A few lint fixes of the FetchChannel method.
2023-04-24 13:10:12 +02:00
Elle Mouton
cab0560d5e
wtclient: cleanup the test file
This commit just does some linting of the client_test.go file so that
future commits are easier to parse.
2023-04-24 13:10:12 +02:00
Olaoluwa Osuntokun
588a7eb9ca
Merge pull request #7599 from Roasbeef/sweeper-rebroadcaster-interaction
sweep: remove conflicted sweep txns from the rebroadcaster
2023-04-21 13:58:50 -07:00
Olaoluwa Osuntokun
3d2daeefd8
sweep: remove conflicted sweep txns from the rebroadcaster
In this commit, we an existing gap in our rebroadcast handling logic. As
is, if we're trying to sweep a transaction and a conflicting transaction
is mined (timeout lands on chain, anchor swept), then we'll continue to
try to rebroadcast the tx in the background.

To resolve this, we give the sweeper a new closure function that it can
use to mark conflicted transactions as no longer requiring rebroadcast.
2023-04-21 11:53:08 -07:00
Oliver Gugger
aff6d4c958
Merge pull request #7614 from yyforyongyu/fix-pprof-err
lntest+lnd: gracefully shutdown pprof server
2023-04-21 14:23:51 +02:00
yyforyongyu
e547118de0
lntest: increase channel close timeout 2023-04-20 18:52:46 +08:00
yyforyongyu
24c028ff52
lntest: make sure error from shutdown is caught 2023-04-20 18:52:46 +08:00
yyforyongyu
4243c5b95f
lnd: properly shutdown the optional pprof server
This commit makes sure when lnd is shutting down, the optional pprof
server is also gracefully shutting down.
2023-04-20 18:52:46 +08:00
Olaoluwa Osuntokun
f56c9e9c8a
Merge pull request #7609 from Roasbeef/80-block-cltv
chainreg: increase default CLTV value to 80 blocks (~13 hrs)
2023-04-19 11:42:27 -07:00
Olaoluwa Osuntokun
7e1628d89d
chainreg: increase default CLTV value to 80 blocks (~13 hrs)
In this commit, we increase the default CTLV value to 80 blocks.
Initially this was set to 144 blocks in the early days, but then was
lowered to 40 blocks as the lnd implementation matured. By setting this
to a higher value, we increase the safety window (MTTR) when it comes to
node downtime, and also add some buffer room around time locks which may
become more stressed in the future assuming the current mempool load
remains persistent.
2023-04-19 11:39:37 -07:00
Olaoluwa Osuntokun
d908becf73
Merge pull request #7613 from ellemouton/fndMgrDefaultPolicyValuesFix
funding: use default forwarding policy if persisted values not found
2023-04-19 11:29:23 -07:00
Elle Mouton
784dc8d530
funding: use default fwding policy if persisted values not found
In this commit, a bug is fixed in the funding manager that could result
in the funding process erroring out if the persisted initial forwarding
policy is not found. This could occur if a node restarts after opening a
channel that is not yet fully confirmed and also upgrades their node
from a pre-0.16 version to 0.16 since the values are only expected to be
persisted after 0.16.
2023-04-19 11:51:32 +02:00
Oliver Gugger
d9396741fa
Merge pull request #7607 from yyforyongyu/itest-fix-close-chan
lntest: add temporary wait when closing channels
2023-04-19 10:48:43 +02:00
Oliver Gugger
68dc01977c
Merge pull request #7608 from morehouse/docker_autoclean
make: clean up container after linting
2023-04-19 10:39:09 +02:00
Olaoluwa Osuntokun
ec3cb6939a
Merge pull request #7564 from yyforyongyu/mempool-watch
contractcourt: add mempool watcher to notify mempool events
2023-04-18 14:22:23 -07:00
Matt Morehouse
526075be57
make: clean up container after linting
Currently `make lint` creates a new container each time it runs. We can
automatically delete these containers once linting is done by using the
--rm flag.
2023-04-18 15:20:14 -05:00
yyforyongyu
66d1392f7f
chainreg: update bitcoind polling config 2023-04-19 01:24:04 +08:00
yyforyongyu
d5db1950cd
mod: update btcwallet version 2023-04-19 01:18:20 +08:00
yyforyongyu
f72d6dfaf5
docs: update release notes for mempool watch 2023-04-19 01:18:20 +08:00
yyforyongyu
e715b8ed1f
itest+lntest: add itest for mempool preimage watch 2023-04-19 01:18:19 +08:00
yyforyongyu
774db0dfe1
lntest: add more methods to assert mempool state 2023-04-19 01:18:19 +08:00
yyforyongyu
dccf9c77ca
lnd+contractcourt: add more debug logs
This commit adds more debug logs for witness beacon and channel
arbitrator.
2023-04-19 01:18:19 +08:00
yyforyongyu
e9c10bf0a1
chainntnfs: remove subscriptions when the relevant tx is confirmed
This commit removes the subscribed inputs from mempool notifier when the
relevant transaction is confirmed.
2023-04-19 01:18:19 +08:00
yyforyongyu
556c38fefd
contractcourt+lnd: watch for preimage reveal in mempool
This commit extends the current htlc timeout resolver to also watch for
preimage spend in mempool for a full node backend.

If mempool enabled, the resolver will watch the spend of the htlc output
in mempool and blocks **concurrently**, as if they are independent.

Ideally, a transaction will first appear in mempool then in a block.
However, there's no guarantee it will appear in **our** mempool since
there's no global mempool, thus we need to watch the spend in two places
in case it doesn't go through our mempool.

The current design favors the spend event found in blocks, that is, when
the tx is confirmed, we'd abort the monitoring and conitnue since the
outpoint cannot be double spent and re-appear in mempool again. This is
not true in the rare case of reorg, and we will handle reorg seperately.
2023-04-19 01:18:19 +08:00
yyforyongyu
7ef8072724
contractcourt: refactor spendHtlcOutput for clarity
Also fixes the docs and rename `isSuccessSpend` to `isPreimageSpend`.
2023-04-19 01:18:19 +08:00
yyforyongyu
e81d62fc70
chainntnfs+chainreg: add interface MempoolWatcher
This commit adds the interface `MempoolWatcher` and uses it in the chain
registry.
2023-04-19 01:18:19 +08:00
yyforyongyu
ad5e798392
chainntnfs+chainreg: add mempool watcher to BtcdNotifier
This commit adds the mempool watcher to btcd notifier to allow the
notifier managing the starting and stopping of the watcher.
2023-04-19 01:18:18 +08:00
yyforyongyu
454e76cbb6
chainntnfs+chainreg: add mempool watcher to BitcoindNotifier
This commit adds the mempool watcher to bitcoind notifier to allow the
notifier managing the starting and stopping of the watcher.
2023-04-19 01:18:18 +08:00
yyforyongyu
8b42151edc
chainntnfs: patch unit tests for mempool notifier 2023-04-19 01:18:18 +08:00
yyforyongyu
3b77e9c51f
chainntnfs: add method UnsubscribeEvent to cancel a subscription
This commit adds the method `UnsubscribeEvent` to cancel a single
subscription.
2023-04-19 01:18:18 +08:00
yyforyongyu
5743dd9601
chainntnfs: allow multiple subscriber to the same input
This commit changes the `subscribedInputs` to store a map of subscribers
so multiple subscribers are allowed to receive events from the same
outpoint.
2023-04-19 01:18:18 +08:00
yyforyongyu
81ee3b9fbe
chainntnfs: introduce mempool notifier
This commit adds a mempool notifier which notifies the subscriber the
spending event found in the mempool for a given input.
2023-04-19 01:18:18 +08:00
yyforyongyu
6aaca568c1
lntest: add temporary wait when closing channels
A temporary solution to avoid the `link failed to shutdown` error.
2023-04-19 01:07:04 +08:00
Oliver Gugger
517f8ed842
Merge pull request #7597 from guggero/persistent-fee-params
Update `channelLink` policy correctly when opening channel with custom fee parameters
2023-04-18 13:36:24 +02:00
Oliver Gugger
d54bc8974a
docs: add release notes 2023-04-18 11:48:49 +02:00
Oliver Gugger
5fbaed6b06
peer: add TODO about initial forwarding policy
The right way to solve the problem of the link not being up to date with
custom user set forwarding policies once the channel is announced would
be to pass in those custom values when the link is created initially.
This requires a bit more of a refactor and is not addressed in this bug
fix.
2023-04-18 11:47:03 +02:00
Oliver Gugger
7eafdd0e08
Merge pull request #7604 from ziggie1984/fmt-fix
Log Output Fix (Missing Value)
2023-04-18 11:04:54 +02:00
Oliver Gugger
1eebbe3f42
itest: update channel open test to send payment
This commit enhances the custom fee policy channel open test by adding a
second channel and testing forwarding payments through the channel with
the custom forwarding policies.
This was able to reproduce the bug reported in #5796 which was fixed in
a previous commit of this PR.
2023-04-18 09:52:14 +02:00
ziggie
461e5f4ac2
docs: update release notes 2023-04-18 09:46:00 +02:00
ziggie
58aae0757e
netann: fix logging output 2023-04-18 09:44:37 +02:00
Oliver Gugger
ebf11bc2f1
itest: move lnd_custom_{message => message_test}.go
This recently added file didn't follow the golang naming convention for
tests.
2023-04-18 09:40:18 +02:00
Oliver Gugger
af70af2710
funding+server: update switch after sending channel update
With this commit we give the funding manager the ability to inform the
switch about custom channel policies, right after we've announced the
channel to the network.
This change is necessary because before #6753 a channel could only be
opened with the default forwarding policies, so the switch automatically
had the "correct" default values. Since #6753 added the ability to
specify forwarding policies at channel open time, we announced those
policies to the network but never updated the switch to inform it about
the changed policies (previously changing the policies was only possible
through the UpdateChannelPolicy RPC which did call the switch).
2023-04-18 09:40:18 +02:00
Oliver Gugger
68881f5c20
funding: refactor manager test 2023-04-18 09:40:17 +02:00
Olaoluwa Osuntokun
37911e2413
Merge pull request #7603 from Torakushi/batch_open_channel_p2tr
funding: use p2tr by default for batch_open_channel
2023-04-17 11:42:34 -07:00
Torakushi
894fc9f2ea
update release-notes-0.16.1 2023-04-17 17:37:56 +02:00
Torakushi
0445fef7ad
funding: use p2tr by default for batch_open_channel
In LND v0.15.1, batch_open_channel used p2tr by default
for change output. However, in a later version, a breaking
change has been fixed in FundPSBT to make the change type
configurable (default to p2wkh). As batch_open_channel
uses FundPsbt, we need to put back p2tr as default for
change output
2023-04-17 17:37:51 +02:00
Olaoluwa Osuntokun
66a85bf9db
Merge pull request #7473 from emilioziniades/realign-witness-types
input+lnrpc: realign witness types
2023-04-13 16:09:01 -07:00
rockstardev
c855d83a4b Updating to bullseye for arm 2023-04-13 00:14:07 -05:00
rockstardev
90231dd41c New golang only available with buster docker images 2023-04-12 23:24:40 -05:00
rockstardev
1b4bbca8ad Updating loop to 0.22 2023-04-12 23:13:20 -05:00
rockstardev
21703127a4 Updating builder docker images for new golang version 2023-04-12 23:13:08 -05:00
rockstardev
4c434438e3 Adding BtcPayServer related files and resources 2023-04-12 22:56:21 -05:00
Emilio Ziniades
ea341bddd5
lnrpc: test witness type mapping 2023-04-12 21:58:17 +02:00
Emilio Ziniades
d8b9a2d042
input: note to update witness type protobuf 2023-04-12 21:58:12 +02:00
Emilio Ziniades
396a138fb7
lnrpc: add allWitnessTypes map
Refactor `PendingSweeps` to use `allWitnessTypes` map, and
return an error from `PendingSweeps` if an unknown witness
type is used, instead of logging a warning.
2023-04-12 21:58:00 +02:00
Emilio Ziniades
e9547daae2
lnrpc: update and regenerate witness type proto 2023-04-12 21:57:35 +02:00
Olaoluwa Osuntokun
158e93f114
Merge pull request #7464 from guggero/script-builder-capacity
input: reduce memory allocation for ScriptBuilder
2023-04-11 15:07:47 -07:00
Olaoluwa Osuntokun
30010dbaa1
Merge pull request #7593 from guggero/remote-signing-docs
docs: update remote signing docs
2023-04-11 14:51:02 -07:00
Oliver Gugger
b875084cbe
docs: update remote signing docs
With this commit we update the docs according to the latest changes that
were necessary to support loop and pool (which requires all 255
internally used accounts to be imported at wallet creation time).

Fixes #7567.
2023-04-11 20:44:01 +02:00
Oliver Gugger
b6b536a1b9
Merge pull request #7550 from ardevd/proto-gen-dockerize-go
lnrpc: fully dockerize protobuf generation
2023-04-11 18:57:02 +02:00
ardevd
7c7c95e58a lnrpc: fully dockerize protobuf generation
Remove the need for golang on the host by utilizing golang docker
containers to obtain protobuf and grpc gateway versions.
2023-04-11 16:25:11 +02:00
Oliver Gugger
5046399991
Merge pull request #7588 from Roasbeef/simnet-walletrpc-cointype-fix
config: fix bug in walletrpc interaction due to mismatched coin type
2023-04-11 13:46:43 +02:00
Oliver Gugger
559cb47ec2
Merge pull request #7513 from guggero/publish-tx-logging
wallet: improve logging around transaction broadcast failures
2023-04-11 12:53:06 +02:00
Oliver Gugger
154e654dc0
docs: add release notes 2023-04-11 12:49:27 +02:00
Oliver Gugger
26254d0730
docs: add release notes 2023-04-11 11:15:37 +02:00
Oliver Gugger
3beaf7c4c1
channeldb: use input.GenMultiSigScript 2023-04-11 11:15:36 +02:00
Oliver Gugger
79c275253c
input: set initial script allocation size
The default allocation of 500 bytes for the script that is
used in NewScriptBuilder is way too much for most of our scripts.
With the new functional option we can tune the allocation to exactly
what we need.
2023-04-11 11:15:36 +02:00
Oliver Gugger
a47345bd6f
input: add script size unit and benchmark tests 2023-04-11 11:15:36 +02:00
Oliver Gugger
4bf97477ee
mod: bump btcd version 2023-04-11 10:33:19 +02:00
Oliver Gugger
9b3e4bd5c2
Merge pull request #7584 from lightningnetwork/dependabot/go_modules/golang.org/x/net-0.7.0
build(deps): bump golang.org/x/net from 0.4.0 to 0.7.0
2023-04-11 09:32:17 +02:00
Olaoluwa Osuntokun
bb3d344fa4
Merge pull request #7563 from yyforyongyu/syncmap-methods
lnutils: add methods `ForEach`, `Len` and `LoadOrStore` to `SyncMap`
2023-04-10 17:00:19 -07:00
Olaoluwa Osuntokun
9580584f73
Merge pull request #7442 from 84adam/postgres-docs-schema-84adam
docs: add notes on contents of Postgres DB as Key-Value store to Postgres.md
2023-04-10 16:51:19 -07:00
Olaoluwa Osuntokun
ed0095fbba
config: fix bug in walletrpc interaction due to mismatched coin type
In this commit, we fix a bug that would cause the walletrpc on the
simnet chain to not be able to respond to all RPC calls. The issue is
that for the SimNet backend, within chainparams.go:
6e0a67d05b/chainreg/chainparams.go (L45-L51),
we set a new CoinType for Simnet in order to match the RegTest value.

Later on, when we go to verify the on disk accounts against the
in-memory cointype, we fall through to an error case as the in-memory
cointype is 115, while the on disk cointype is 1.

To fix this, when we know we're doing simnet mode, we'll override the
cointype similar to the way we did/do for LTC.

Fixes https://github.com/lightningnetwork/lnd/issues/6807.
2023-04-10 11:43:21 -07:00
yyforyongyu
8887938429
lnutils: add unit test for SyncMap 2023-04-07 17:34:48 +08:00
yyforyongyu
d1d75d0815
lnutils: add methods ForEach, Len and LoadOrStore to SyncMap 2023-04-07 17:34:45 +08:00
Olaoluwa Osuntokun
6e0a67d05b
Merge pull request #7582 from Roasbeef/go-1-20-3
build: update build system to Go 1.20.3
2023-04-06 11:38:49 -07:00
Olaoluwa Osuntokun
a72fb7d3f5
Merge pull request #7585 from lightningnetwork/0-16-1-staging
lnd: manual merge docker bump into master branch
2023-04-06 11:38:22 -07:00
Olaoluwa Osuntokun
591ff120b6
Merge pull request #6903 from hieblmi/fundmax-flag
funding: add `fundmax` flag to `OpenChannelRequest`
2023-04-06 10:57:29 -07:00
dependabot[bot]
3960e1538a
build(deps): bump golang.org/x/net from 0.4.0 to 0.7.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.4.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.4.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-05 23:49:31 +00:00
Olaoluwa Osuntokun
f9f08079d0
Merge pull request #7576 from lightningnetwork/0-17-0-staging
lnd: merge v0.17.0 staging branch into master
2023-04-05 16:48:50 -07:00
Olaoluwa Osuntokun
2596a33529
Merge pull request #7575 from lightningnetwork/0-16-1-staging
lnd: merge the 0.16.1 staging branch into master
2023-04-05 16:48:25 -07:00
Slyghtning
e352899f22 docs: update release notes 2023-04-05 23:10:04 +02:00
Slyghtning
94900acaa0 funding unit: fundmax sanity check for new channel commitment types. 2023-04-05 23:10:04 +02:00
Slyghtning
ff45fc7e71 itest: respect the reserved wallet balance when using fundmax 2023-04-05 23:10:04 +02:00
Bjarne Magnussen
8c1cf21707 chanfunding: allow to set a reserved amount not used for funding 2023-04-05 23:10:03 +02:00
Bjarne Magnussen
d7f578b0d9 lntest/itest: adds tests for fundmax flag of cli:openchannel 2023-04-05 23:09:12 +02:00
Slyghtning
b9bded33d1 lncli: fundmax flag for openchannel 2023-04-05 23:09:12 +02:00
Slyghtning
5d88693852 lnd+lnwallet: fundmax flag for openchannel 2023-04-05 23:09:11 +02:00
Bjarne Magnussen
0e5b3e77cb lnd: handles the FundMax field inside parseOpenChannelReq
Adds handling of the `FundMax` field when parsing an
`OpenChannelRequest` with `rpcServer.parseOpenChannelReq`.
2023-04-05 23:05:07 +02:00
Bjarne Magnussen
e82410d24a lnrpc: adds a field FundMax to OpenChannelRequest 2023-04-05 23:05:07 +02:00
Bjarne Magnussen
0c8aa81ed5 chanfunding: adds ability to fund up to some maximum amount
Allows to define a maximum amount to provision a channel
opening with using a new field `FundUpToMaxAmt` on the
`Request` struct. Also adds a new coin select function
`CoinSelectUpToAmount` to select coins up to a maximum
amount respecting a minimum amount.
2023-04-05 23:05:06 +02:00
Olaoluwa Osuntokun
c0f4defe0b
build: update build system to Go 1.20.3 2023-04-05 11:28:34 -07:00
Olaoluwa Osuntokun
981771022b
Merge pull request #7574 from Roasbeef/16-99-version-bump
build: bump version to v0.16.99
2023-04-04 19:55:32 -07:00
Olaoluwa Osuntokun
febf1ab0d5
build: bump version to v0.16.99
In this commit, we bump the version of the master branch to v0.16.99.
This reflects the fact that master will be a super set of all the minor
releases until v0.17, and will also include changes towards v0.17.
2023-04-04 19:51:15 -07:00
Oliver Gugger
b7697a7257
Merge pull request #7377 from positiveblue/split-update-invoice
channeldb: split `UpdateInvoice` logic
2023-03-16 16:39:29 +01:00
positiveblue
034853a0a8
docs: add release notes 2023-03-14 19:26:18 -07:00
positiveblue
09e87ea99b
channeldb: add serializeAndStoreInvoice helper func 2023-03-14 19:26:18 -07:00
positiveblue
65fc8d72c6
channeldb: clean updateInvoice func
All the updates type are now catched in a switch statement, we can
delete the rest of the body of this function + add a default path for
not matched flows.
2023-03-14 19:26:18 -07:00
positiveblue
6ff6c45a6b
channeldb: split addHTLCs logic in the UpdateInvoice method 2023-03-14 19:26:18 -07:00
positiveblue
27fbc2f60b
channeldb: split cancelInvoice logic in the UpdateInvoice method 2023-03-14 19:26:15 -07:00
positiveblue
cbaec4382a
channeldb: split settleHodlInvoice logic in the UpdateInvoice method 2023-03-14 19:01:52 -07:00
positiveblue
a3f6d5c97e
channeldb: split cancelHTLCs logic in the UpdateInvoice method
Previous to this commit we were able to call `UpdateInvoice` with an
updated that added and cancelled htlcs at the same time. The function
returned an error if there was overlapping between the two htlc set.
However, that behavior was not used in the LND code itself.

Eventually we want to split this method in multiple ones, among them one
for canceling htlcs and another one for adding them. For that reason,
this behavior is not supported anymore.
2023-03-14 18:56:01 -07:00
positiveblue
84387992ec
invoices: add UpdateType to InvoiceUpdateDesc
Make the kind of update explicit in the `InvoiceUpdateDesc` struct.
2023-03-13 13:11:06 -07:00
Daniel McNally
9cc9e40b89
lnrpc: update docs for invoice amt_paid
This corrects the documentation for the `amt_paid` and `amt_paid_msat`
fields on the `Invoice` message to indicate that the fields will be set
if the state of the invoice is either accepted or settled, not only
settled. This reflects the actual behavior of lnd, as demonstrated in
the below `lncli` output:

```
"amt_paid": "10000",
"amt_paid_sat": "10",
"amt_paid_msat": "10000",
"state": "ACCEPTED",
```
2023-03-06 20:23:25 -05:00
84adam
713dece401 docs: add notes on contents of Postgres DB as Key-Value store to Postgres.md 2023-02-28 21:36:24 -07:00
d11n
3f80670831
Merge pull request #6 from sgiammy/feature/signet-support-entrypoint
accept 'signet' as LND_ENVIRONMENT variable
2022-11-07 14:49:39 +01:00
rockstardev
1c4bd230e1
Cleaning up README, adding new version 2022-11-04 10:48:01 -05:00
rockstardev
f52aff64f7
Merge branch 'version/0.15.4-beta-loop-0.20.2' 2022-11-04 10:36:33 -05:00
rockstardev
3f25db755c
Merge branch 'version/0.15.4-beta' 2022-11-04 10:09:39 -05:00
rockstardev
8d7079d997
Adding BtcPayServer related files and resources 2022-11-04 10:53:46 +01:00
rockstardev
9c2807eba4
Adding BtcPayServer related files and resources 2022-11-01 21:54:18 +09:00
Oliver Gugger
96fe51e2e5
Merge pull request #7098 from lightningnetwork/btcd-bump-23-3
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
mod+build: bump btcd version to v0.23.3 and bump lnd version to v0.15.4-beta
2022-11-01 13:44:01 +01:00
Oliver Gugger
c8a3fbe265
funding: fix linter error 2022-11-01 13:34:01 +01:00
Oliver Gugger
64f20b6b5b
build: bump version to v0.15.4-beta 2022-11-01 13:20:04 +01:00
Oliver Gugger
77cd2bf5e4
docs: add release notes for 0.15.4-beta 2022-11-01 13:19:40 +01:00
Oliver Gugger
d65833fca4
mod: bump btcd to v0.23.3 2022-11-01 13:18:15 +01:00
Olaoluwa Osuntokun
b4e7131bdb
build: bump version to v0.15.3-beta
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2022-10-17 10:52:17 -07:00
Olaoluwa Osuntokun
f674960e4e
Merge pull request #7017 from Roasbeef/v0-15-3-branch
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
release: create release branch for v0.15.3
2022-10-14 15:29:50 -04:00
Olaoluwa Osuntokun
34cd2f5d7c
build: bump version to v0.15.3-beta.rc1 2022-10-14 15:28:48 -04:00
Oliver Gugger
4c6f9eca5a docs: update remote signing update hint to v0.15.3-beta [skip ci]
This commit bumps the recommended version to upgrade to for remote
signing setups.
2022-10-13 12:57:35 -04:00
eugene
69b7d9666d funding: ignore maxWaitNumBlocksFundingConf for zero conf channels
This is so that if the funding transaction hasn't been confirmed
in 2016 blocks, the channel isn't marked as closed by the responder.
2022-10-13 12:57:35 -04:00
rockstardev
77dbf5d22e
Cleaning up README, adding 0.15.2-beta version 2022-10-12 15:47:39 -05:00
rockstardev
0a6f48ae0b
Merge branch 'version/0.15.2-beta' 2022-10-12 15:30:10 -05:00
rockstardev
cd045c0c65
Cleaning up README, adding new version 2022-10-12 15:14:32 -05:00
rockstardev
700c66ea86
Merge branch 'version/0.15.0-beta'
# Conflicts:
#	.circleci/config.yml
#	Makefile
#	build/version.go
#	chainreg/no_chain_backend.go
#	channeldb/graph_test.go
#	config_builder.go
#	contractcourt/briefcase.go
#	discovery/gossiper.go
#	docs/INSTALL.md
#	docs/release-notes/release-notes-0.14.2.md
#	go.mod
#	go.sum
#	htlcswitch/decayedlog_test.go
#	lnrpc/lightning.pb.go
#	lnrpc/lightning.proto
#	lnrpc/lightning.swagger.json
#	lnrpc/routerrpc/router.pb.go
#	lnrpc/rpc_utils.go
#	lnrpc/signrpc/signer_server.go
#	lnrpc/walletrpc/walletkit.pb.go
#	lnrpc/walletrpc/walletkit_server.go
#	lntest/harness_net.go
#	lntest/harness_node.go
#	lntest/itest/lnd_channel_force_close_test.go
#	lntest/itest/lnd_channel_policy_test.go
#	lntest/itest/lnd_open_channel_test.go
#	lntest/itest/lnd_psbt_test.go
#	lntest/itest/lnd_remote_signer_test.go
#	lnwallet/btcwallet/btcwallet.go
#	lnwallet/btcwallet/psbt.go
#	lnwallet/btcwallet/psbt_test.go
#	lnwallet/btcwallet/signer.go
#	lnwallet/btcwallet/signer_test.go
#	lnwallet/chainfee/estimator_test.go
#	lnwallet/interface.go
#	lnwallet/rpcwallet/healthcheck.go
#	lnwallet/rpcwallet/rpcwallet.go
#	log.go
#	macaroons/constraints.go
#	routing/missioncontrol_state_test.go
#	rpcserver.go
#	tools.go
2022-10-12 15:13:06 -05:00
Olaoluwa Osuntokun
004e2a1066 docs/release-notes: fix release notes for zero conf safety fix 2022-10-10 19:13:22 -07:00
Olaoluwa Osuntokun
110d29438a Merge branch 'v0-15-3-branch-6957' into v0-15-3-branch 2022-10-10 19:12:45 -07:00
Olaoluwa Osuntokun
8c6bc4d9b2 lnwallet/chancloser: fix loop variable shadowing in TestMaxFeeBailOut 2022-10-10 19:12:34 -07:00
Olaoluwa Osuntokun
1b95bfe171 lnwallet/chancloser: properly compute initial fee of cop close txn
In this commit, we modify the way we compute the starting ideal fee for
the co-op close transaction. Before thsi commit, channel.CalcFee was
used, which'll compute the fee based on the commitment transaction
itself, rathern than the co-op close transaction. As the co-op close
transaction is potentailly bigger (two P2TR outputs) than the commitment
transaction, this can cause us to under estimate the fee, which can
result in the fee rate being too low to propagate.

To remedy this, we now compute a fee estimate from scratch, based on the
delivery fees of the two parties.

We also add a bug fix in the chancloser unit tests that wasn't caught
due to loop variable shadowing.

The wallet import itest has been updated as well, since we'll now pay
600 extra saothis to close the channel, since we're accounting for the
added weight of the P2TR outputs.

Fixes #6953
2022-10-10 19:12:32 -07:00
Olaoluwa Osuntokun
2fe1da8109 Merge branch 'v0-15-3-branch-6966' into v0-15-3-branch 2022-10-10 19:10:01 -07:00
Oliver Gugger
a18a559a4b docs: add release notes [skip ci] 2022-10-10 19:09:50 -07:00
Oliver Gugger
27b60143cb docs: describe remote signing upgrade process
This commit adds a short guide that explains how a remote signing node
setup should be migrated from lnd v0.14.x-beta to lnd v0.15.x-beta and
adds a note to all 0.15.x release notes.
2022-10-10 19:08:49 -07:00
Oliver Gugger
cfe30ed674 cmd/lncli: add p2tr address type to account import 2022-10-10 19:07:52 -07:00
Olaoluwa Osuntokun
2ec4e5bdbd Merge branch 'v0-15-3-branch-6914' into v0-15-3-branch 2022-10-10 19:07:15 -07:00
positiveblue
714210492e docs: add release notes for hop hint selection refactor 2022-10-10 19:06:24 -07:00
positiveblue
4d0cff73ea aliasmgr: cache peer alias in memory 2022-10-10 19:05:40 -07:00
positiveblue
102d4f8d48 invoicesrpc: unit tests for invoice hop hints 2022-10-10 19:05:40 -07:00
positiveblue
9b40f5dbfd invoicesrpc: refactor addinvocie hop hint selection
In order to reduce the number of calls to the db we try to process as
few channels as we can + try to not do extra work for each of them.

- First fetch all the channels. Then, filter all the public ones and
  sort the potential candidates by remote balance.

- Filter out each potential candidate as soon as possible.

- Only check the alias if the channel supports scid aliases.

- Because we sort the channels by remote balance, we will hit the
  target amount, if possible, as soon as we can.

We do not want to leak information about our remote balances, so we
shuffle the hop hints (the forced ones go always first) so the invoice
receiver does not know which channels have more balance than others.
2022-10-10 19:05:39 -07:00
positiveblue
55b7bc6a42 style: format invoicesrpc/addinvoice.go 2022-10-10 19:04:37 -07:00
Olaoluwa Osuntokun
dce4f282ac Merge branch 'v0-15-3-branch-6941' into v0-15-3-branch 2022-10-10 19:03:26 -07:00
Olaoluwa Osuntokun
48c167b860 build: update to latest version of btcwallet w/ taproot estimation fix
Fixes https://github.com/lightningnetwork/lnd/issues/6873
2022-10-10 19:02:02 -07:00
Olaoluwa Osuntokun
f10eff4495 Merge branch 'v0-15-3-branch-6892' into v0-15-3-branch 2022-10-10 18:59:00 -07:00
eugene
33ecc9d177 release-notes: update for 0.15.2 2022-10-10 18:58:45 -07:00
eugene
3897f595a5 server.go: add peerChan to peerConnectedListeners in NotifyWhenOnline
This fixes a bug where a caller would:
- call NotifyWhenOnline and pass in a channel
- the server's mutex is held and the pubStr is checked in peersByPub
- the peer object is in the peersByPub map
- the peer object has its quit channel closed
- QuitSignal is called in the select statement, and the function
  returns
- the caller is still waiting for the channel to be sent on forever
  since it was never sent on or added to the peerConnectedListeners
  slice.

This patch fixes the above bug by adding the channel to the
peerConnectedListeners slice if the QuitSignal select case is called.
2022-10-10 18:57:55 -07:00
Olaoluwa Osuntokun
80a7ff8963 Merge branch 'v0-15-3-branch-6926' into v0-15-3-branch 2022-10-10 18:56:19 -07:00
Oliver Gugger
7a859109d2 docs: add release notes 2022-10-10 18:56:07 -07:00
Oliver Gugger
b344d9fd69 lnrpc: add additional REST binding for QueryRoutes
Lists with non-primitive members aren't supported in the query string of
a GET request with the current version of the grpc-gateway library. To
allow route_hints to be set through REST, we also offer a POST endpoint
for that call where the encoding of the request parameter can be
specified as JSON.
2022-10-10 18:54:48 -07:00
Olaoluwa Osuntokun
dd7566dab5 Merge branch 'v0-15-3-branch-6899' into v0-15-3-branch 2022-10-10 18:53:49 -07:00
Evan Kaloudis
d71639220c lnrpc/gen_protos.sh: remove js build tag 2022-10-10 18:53:48 -07:00
rockstardev
a5d3f08cca
Removing experimental features, no longer needed 2022-10-10 16:36:09 +09:00
rockstardev
276ce611e6
Updating circleci image for multiarch task
Previous one got depricated
https://circleci.com/blog/ubuntu-14-16-image-deprecation/
2022-10-10 16:36:09 +09:00
rockstardev
09386f1433
Adding BtcPayServer related files and resources 2022-10-10 16:36:09 +09:00
Olaoluwa Osuntokun
08a957ff45
Merge pull request #7005 from Roasbeef/v0-15-2-branch
release: create v0.15.2 hot fix branch to fix wire parsing issue
2022-10-09 19:34:33 -07:00
Olaoluwa Osuntokun
aff2ed3a6a
build: bump version to v0.15.2
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2022-10-09 18:45:32 -07:00
Olaoluwa Osuntokun
d65d3dd0cd
docs/release-notes: shift prior 0.15.2 release to 0.15.3
We also add an entry for the _new_ 0.15.2 hot fix release.
2022-10-09 18:44:58 -07:00
Olaoluwa Osuntokun
a502c386cd
build: update to version of btcd with wire parsing bug fix
Fixes https://github.com/lightningnetwork/lnd/issues/7002
2022-10-09 18:43:48 -07:00
Olaoluwa Osuntokun
fd1a95bf32
build: bump version to v0.15.1-beta
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2022-08-30 13:17:47 -07:00
Olaoluwa Osuntokun
e5e20a71be Merge branch 'v0.15.1-beta-6847' into v0.15.1-branch-rc2
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2022-08-22 18:05:29 -05:00
Olaoluwa Osuntokun
29ac0e171c build: bump version to v0.15.1-beta.rc2 2022-08-22 18:05:11 -05:00
Elle Mouton
7324256f42 rpcserver+docs: add default case to addr type switch
This commit adds a default case to the address type switch statement in
the NewAddress rpc server function. This catches any invalid address
types and returns an error.
2022-08-22 18:03:42 -05:00
Olaoluwa Osuntokun
cabeef2128
Merge pull request #6827 from Roasbeef/v0.15.1-branch-rc1
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
multi: create v0.15.1 rc1 release branch
2022-08-15 14:19:58 -07:00
Olaoluwa Osuntokun
b9ae910d39 Merge branch 'v0.15.1-beta-6588' into v0.15.1-branch-rc1 2022-08-15 11:59:45 -07:00
Carsten Otto
b4177b5b9d peer: add pubkey to log messages 2022-08-15 11:59:27 -07:00
Olaoluwa Osuntokun
5e3c70600b Merge branch 'v0.15.1-beta-6510' into v0.15.1-branch-rc1 2022-08-15 11:58:24 -07:00
ErikEk
63012b84da doc: release notes 2022-08-15 11:57:38 -07:00
ErikEk
92c3769c2d neutrinorpc: add getblockhash command 2022-08-15 11:56:45 -07:00
ErikEk
1a72fa7be6 neutrinorpc: add getblockhash functionality 2022-08-15 11:56:45 -07:00
Olaoluwa Osuntokun
e682abcf8f
build: bump version to v0.15.1-beta.rc1 2022-08-12 17:12:56 -07:00
Olaoluwa Osuntokun
9ac8bd4097 Merge branch 'v0.15.1-beta-6826' into v0.15.1-branch-rc1 2022-08-12 17:12:20 -07:00
Olaoluwa Osuntokun
037636a702 chainreg: update tapoort node awareness to account for bitcoind 19+
Bitcoind 23 will use the new `getdeploymentinfo` while versions after 19
(but below 23) will use the `UnifiedSoftForks` field instead of the
`SoftForks UnifiedSoftForks` field.

With this PR the taproot gating logic has been tested on bitcoind
versions: 21, 22, and 23. 21 is when the taproot logic was first added.
2022-08-12 17:12:20 -07:00
Olaoluwa Osuntokun
92a657e7f0 Merge branch 'v0.15.1-beta-6664' into v0.15.1-branch-rc1 2022-08-12 17:12:03 -07:00
eugene
43b08b75e7 release-notes: update for 0.15.1 2022-08-12 17:12:03 -07:00
eugene
414edeb5bd funding: defer sending channel_update until received funding_locked
This is required by BOLT#07 as otherwise the counter-party will
discard the channel_update as they may not consider the channel
"ready" or reorg-safe. Most other implementations besides eclair
have work-arounds for this, but it is nice to be spec-compliant.
2022-08-12 17:12:03 -07:00
Olaoluwa Osuntokun
0d8bae8004 Merge branch 'v0.15.1-beta-6820' into v0.15.1-branch-rc1 2022-08-12 17:11:43 -07:00
Olaoluwa Osuntokun
259f104a48 build: update to latest versions of btec, btcutil, and btcutil/psbt
Fixes #6668
2022-08-12 17:11:43 -07:00
Olaoluwa Osuntokun
1294c3d03f Merge branch 'v0.15.1-beta-6716' into v0.15.1-branch-rc1 2022-08-12 17:11:19 -07:00
eugene
197e3b7c26 release-notes: update for 0.15.1 2022-08-12 17:11:19 -07:00
eugene
bf7c417216 lntest: update zero-conf tests to account for zeroconfacceptor 2022-08-12 17:11:19 -07:00
eugene
5003af9c59 chanacceptor+lnrpc: update the commitmentTypes, send zero-conf to client
This updates the RPCAcceptor to send the correct commitment type
even if the zero-conf or scid-alias channel types are set. This also
adds two bools to the ChannelAcceptRequest struct that denotes whether
the funder set the zero-conf and scid-alias channel types.
2022-08-12 17:11:19 -07:00
eugene
10d4953b31 multi: add zeroconfacceptor that default rejects if no rpc acceptors
This is a safety mechanism so that zero-conf channels are not accepted
by default if no rpc acceptor exists.
2022-08-12 17:11:19 -07:00
Olaoluwa Osuntokun
51fd540c36 Merge branch 'v0.15.1-beta-6810' into v0.15.1-branch-rc1 2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
973265483d docs/release-notes: add release notes entry 2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
2e2357449f lnwallet/chanfunding: assumes all change outputs are P2TR 2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
7bf83b13a8 lnwallet: use P2TR addresses for change outputs for funding coin select 2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
62a52cf56c rpc: use P2TR addresses when sending funds back to wallet (anchor reserve) 2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
090f30966e sweep: change outputs are now P2TR 2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
13f82ba388 watchtower: uses P2TR for sweep, delivery, and reward addresses
In this commit, we modify the watch tower to use P2TR addrs for just
about anything sweep related.

One eye sore in this diff are the changes to
`backup_task_internal_test.go`. All the values are hard coded, and now
either differ by a value of 48, or needed to be modified to account for
the new assumptions propagated to rewards values and fees.
2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
98c69a3988 contractcourt: the breach arb now uses P2TR outputs for sweep addrs 2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
bc18282e1f server: default sweep addrs to P2TR
This change covers sweep addresses for: the breach arbitrator, and watch
tower clients.
2022-08-12 17:10:53 -07:00
Olaoluwa Osuntokun
f44464e592 Merge branch 'v0.15.1-beta-6633' into v0.15.1-branch-rc1 2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
21668be1f6 docs/release-notes: add release notes entry 2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
637dd0f902 lntest/itest: add new itest to cover taproot co-op close 2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
a210475d11 feature+lncfg: add config option to turn of anysegwit 2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
a3951d4774 peer: send taproot addrs during co-op close based on new feature bit
If the ShutdownAnySegwitOptional option is active, then we can safely
send these newer addresses.
2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
41db3ea19b funding: send taproot addrs as upfront shutdown if ShutdownAnySegwitOptional is active 2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
436bf51411 lnwallet/chanclose: update ProcessCloseMsg to check co-op close addrs
We only want to allow p2wkh, p2tr, and p2wsh addresses, so we'll utilize
the newly public wallet function to restrict this.
2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
dc87d6016f lnwallet: export ValidateUpfrontShutdown and restrict allowed addrs
In this commit, we catch up our logic with the latest version of the
spec that removed support for normal p2kh and p2sh addresses for co-op
closes, in order to make dust calculations more uniform.
2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
6a00952dcc lnwire+feature: add awareness of option_shutdown_anysegwit
In this commit, we add awareness of the option_shutdown_anysegwit that
permits both sides to send newer segwit based addresses. This'll
eventually enable us to send taproot addresses for co-op close.
2022-08-12 17:10:21 -07:00
Olaoluwa Osuntokun
31b7baa4f3 Merge branch 'v0.15.1-beta-6734' into v0.15.1-branch-rc1 2022-08-12 17:09:53 -07:00
eugene
05f05e6e79 release-notes: update for 0.15.1 2022-08-12 17:09:53 -07:00
eugene
44ad0165e5 rpc+cli: add general ListAliases function to dump all aliases 2022-08-12 17:09:53 -07:00
eugene
1bee0bd1fc rpc: add zero-conf, alias information to {list,closed}channels 2022-08-12 17:09:53 -07:00
Olaoluwa Osuntokun
9c4209bb4b Merge branch 'v0.15.1-beta-6816' into v0.15.1-branch-rc1 2022-08-12 17:09:38 -07:00
eugene
3ada219762 docs: add documentation for zero-conf channels
This short doc goes into how to open zero-conf channels as either
the funder or fundee.
2022-08-12 17:09:38 -07:00
eugene
a91770553f funding: remove TODO 2022-08-12 17:09:38 -07:00
Olaoluwa Osuntokun
72754ba6b1 Merge branch 'v0.15.1-beta-6740' into v0.15.1-branch-rc1 2022-08-12 17:09:25 -07:00
eugene
f54dfe30aa release-notes: update for 0.15.1 2022-08-12 17:09:25 -07:00
eugene
ed1fdd264c sweep: account for all script types in craftSweepTx
With this change, transactions created via craftSweepTx will be
standard. Previously, p2wsh/p2pkh scripts passed in via SendCoins would
be weighted as p2wpkh scripts. With a feerate of 1 sat/vbyte,
transactions returned would be non-standard. Luckily, the critical
sweeper subsystem only used p2wpkh scripts so this only affected
callers from the rpcserver.

Also added is an integration test that fails if SendCoins manages
to generate a non-standard transaction. All script types are now
accounted for in getWeightEstimate, which now errors if an unknown
script type is passed in.
2022-08-12 17:09:25 -07:00
Olaoluwa Osuntokun
7357df9202 Merge branch 'v0.15.1-beta-6770' into v0.15.1-branch-rc1 2022-08-12 17:08:47 -07:00
Olaoluwa Osuntokun
f9ef5c6ffe docs/release-notes: add entry for 0.15.1 2022-08-12 17:08:47 -07:00
Olaoluwa Osuntokun
6201b2d7f0 multi: thread through the new max fee field for co-op close
In this commit, we parse the new max fee field, and pass it through the
switch, all the way to the peer where it's ultimately passed into the
chan closer state machine.
2022-08-12 17:08:47 -07:00
Olaoluwa Osuntokun
ab14e29757 lnrpc: add a new max_fee field to the CloseChannel RPC call
In this commit, we add a new max_fee field that we'll use to decide when
to bail out of a co-op close dance as the initiator.
2022-08-12 17:08:47 -07:00
Olaoluwa Osuntokun
b6ea634ba9 lnwallet/chancloser: add tests for the new max fee behavior 2022-08-12 17:08:47 -07:00
Olaoluwa Osuntokun
2fb304b6f4 lnwallet/chancloser: remove raw state machine pointer, add channel interface
In this commit, we remove the raw channel state machine pointer from the
chan closer and instead replace that with an interface that captures
*just* the methods we need in order to do the co-op close dance.

This is a preparatory refactoring for some upcoming unit tests.
2022-08-12 17:08:47 -07:00
Olaoluwa Osuntokun
e0d8f461a1 lnwallet: add new AbsoluteThawHeight method
This lets callers get the thaw height without needing to first obtain a
snapshot of the channel state.
2022-08-12 17:08:47 -07:00
Olaoluwa Osuntokun
9ae013ca46 lnwallet/chancloser: remove the commit fee clamp, introduce max fee
In this commit, we stop clamping the ideal fee rate to the commitment
fee of the channel. This catches us up to this PR of the spec:
https://github.com/lightning/bolts/pull/847.

We also do away with the old 3x ideal fee "max fee", and replace that
with an explicit max fee. This new max fee will either be the default
multiplier of the ideal fee, or a new user specified max fee value.
2022-08-12 17:08:47 -07:00
Olaoluwa Osuntokun
170c9fd8c3 Merge branch 'v0.15.1-beta-6798' into v0.15.1-branch-rc1 2022-08-12 17:07:51 -07:00
Olaoluwa Osuntokun
deeaa0c9c7 chainreg: shutdown if backend node doesn't support taproot
In this commit, we add a check during normal node construction to see if
the backend node supports Taproot. If it doesn't, then we want to
shutdown and force the user to take note.

To check if the node supports Taproot, we'll first try the normal
getblockchaininfo call. If this works, cool, then we can rely on the
value. If it doesn't, then we'll fall back to the getdeploymentinfo call
which was added in a recent version of bitcoind [1]. Newer versions of
bitcoind might also have this call, and the getblockchaininfo call, but
not actually populate the softforks field [2]. In this case, we'll fall
back, and we also account for the case when the getblockchaininfo RPC is
removed all together.

[1]: https://github.com/bitcoin/bitcoin/pull/23508
[2]: https://github.com/bitcoin/bitcoin/pull/25114

Fixes #6773
2022-08-12 17:07:51 -07:00
Olaoluwa Osuntokun
345e66153b Merge branch 'v0.15.1-beta-6809' into v0.15.1-branch-rc1 2022-08-12 17:07:39 -07:00
positiveblue
8ad95972af docs: Add release notes for feature bit fix (#6809) 2022-08-12 17:07:39 -07:00
positiveblue
f96866915b feature: remove ScidAliasOptional dependency on ExplicitChannelTypeOptional
The [spec](https://github.com/lightning/bolts/blob/master/09-features.md)
does not specify a dependency between `ScidAliasOptional` (47) and
`ExplicitChannelTypeOptional` (45).

This bug lead to some connectivity issues with peers not setting the
45 feature bit while setting the 47.

The issue [6802](https://github.com/lightningnetwork/lnd/issues/6802) is
an example of this.
2022-08-12 17:07:39 -07:00
Olaoluwa Osuntokun
d9d0e470ad Merge branch 'v0.15.1-beta-6736' into v0.15.1-branch-rc1 2022-08-12 17:07:20 -07:00
bitromortac
5c93c2c677 config: allow independent rpccookie config
The bitcoind .cookie contains an autogenerated user (__cookie__) and
password (random string), which can be used instead of the rpc user name
and password. This commit allows for running against bitcoind without
having to access bitcoin.conf like in the case for pure
user/password/zmq configuration.
2022-08-12 17:07:08 -07:00
Olaoluwa Osuntokun
91329e7970 Merge branch 'v0.15.1-beta-6469' into v0.15.1-branch-rc1 2022-08-12 17:06:11 -07:00
yyforyongyu
f2c767e79a docs: add release note for optional migration 2022-08-12 17:05:59 -07:00
yyforyongyu
c09f1875aa channeldb: skip dry run mode for optional migrations 2022-08-12 17:05:24 -07:00
yyforyongyu
2a6ac8a117 migration30: validate migration results before deleting old buckets
This commit adds a new method `validateMigration` to be used prior to
the deletion of the old buckets to be extraly cautious.
2022-08-12 17:05:24 -07:00
yyforyongyu
a5755d4568 migration30: cover the case where v0.15.0 is active
This commit changes how we locate the next migration height by including
the scenario where `lnd@v0.15.0` is active. In the new version, we will
see a mixed of new and old logs under the same open channel bucket.
Hence, we need to alter how we locate the next un-migrated height.
2022-08-12 17:05:24 -07:00
yyforyongyu
626a8b3504 multi: add the flag prune-revocation to perform the optional migration 2022-08-12 17:05:24 -07:00
yyforyongyu
65a2f3ac81 channeldb: add optional meta and migration30
This commit enables the db to run optional migrations that are specified
by config flags. To achieve this, an optional meta is introduced to
manage the optional migrations. We distinguish the two types of
migrations here so it's easier to manage them for the concern a future
migration can cause trouble for us to determine the db version if we
don't.
2022-08-12 17:05:24 -07:00
yyforyongyu
e84fa208ff migration30: add benchmark test 2022-08-12 17:05:24 -07:00
yyforyongyu
45903c2f5e migration30+migtest: add unit tests for migration 2022-08-12 17:05:24 -07:00
yyforyongyu
02879f08c0 migration30: add migration to convert old revocation logs
This commit adds the migration that's used to convert the old revocation
logs into the new format. The migration is fault-tolerant, meaning the
process can be interrupted and the migration will pick up what's left
when running again. We also cap how many records to be processed in each
db transaction to prevent OOM.
2022-08-12 17:05:24 -07:00
yyforyongyu
120dc4ae77 migration30: add unit tests for iterator 2022-08-12 17:05:24 -07:00
yyforyongyu
955ef2e10e migration30: add supporting functions to help with unit tests
This commit adds supporting functions that will be used in the unit
test. The testing data are also added as hard-coded. We choose to copy
the most of the testing data from our itest results such that a) they
are "real" data that can be used to calculate scripts and b) we preserve
the result generated by the current code so a future change won't affect
our test.
2022-08-12 17:05:24 -07:00
yyforyongyu
7b46d1dc1d migration30: add iterator to assist migration
This commit adds several utility functions to assist the migration. In
particular, an updateLocator is added to gives us the next un-migration
position in our buckets. This locator helps us to continue the job
in case of an interrupted migration. It also serves as an indicator on
whether the migration is finished or not.
2022-08-12 17:05:24 -07:00
yyforyongyu
658515c9ce migration30: add related revocation log and lnwallet code
This commit adds relevant code from the revocation_log.go and the
package lnwallet. The code is needed to migrate the data, and we choose
to copy the code instead of importing to preserve the version such that
a future change won't affect current migration. An alternative would be
tagging each of the packages imported.
2022-08-12 17:05:24 -07:00
Olaoluwa Osuntokun
c8935e61bc Merge branch 'v0.15.1-beta-6748' into v0.15.1-branch-rc1 2022-08-12 17:04:56 -07:00
Martin Habovštiak
c4dde72aa3 doc: Deprecation reason of settled on Invoice
This documents how to deal with `settled` being deprecated. It took me quite a bit of digging without such documentation.

[skip ci]
2022-08-12 17:04:56 -07:00
Olaoluwa Osuntokun
d6fd8d1ba1 Merge branch 'v0.15.1-beta-6754' into v0.15.1-branch-rc1 2022-08-12 17:04:09 -07:00
Elle Mouton
8a17009afa multi: registration complete MW interceptor msg
In this commit, we change the flow of the rpc middleware registration
a bit. In order to allow a client to add rpc middleware interceptors in
a deterministic order, we now make the server send a "registration
complete" message to the client after compeleting the registration
process so that the client knows when it can go ahead and register the
next client.
2022-08-12 17:04:09 -07:00
Olaoluwa Osuntokun
95a6425189 Merge branch 'v0.15.1-beta-6763' into v0.15.1-branch-rc1 2022-08-12 17:03:57 -07:00
Thebora Kompanioni
c327a35e4e fix: go version in ARMv6 section of INSTALL.md 2022-08-12 17:03:57 -07:00
Olaoluwa Osuntokun
510ca08e64 Merge branch 'v0.15.1-beta-6741' into v0.15.1-branch-rc1 2022-08-12 17:03:44 -07:00
Matt Morehouse
7881f0a510 doc: update release notes 2022-08-12 17:03:43 -07:00
Matt Morehouse
2c4cf9379f itest: fix sign_psbt failure
Ensure the wallet has synced the blockchain before attempting to spend
funds.

Prior to this fix, I get the following error:
  rpc error: code = Unknown desc = wallet couldn't fund PSBT: error
      creating funding TX: insufficient funds available to construct
      transaction
2022-08-12 17:03:43 -07:00
Olaoluwa Osuntokun
2275d75f07 Merge branch 'v0.15.1-beta-6742' into v0.15.1-branch-rc1 2022-08-12 17:03:01 -07:00
Symphonic3
ac7d8e5d13 Fix typo in abandonchannel description
i_know_what_im_doing --> i_know_what_i_am_doing
2022-08-12 17:03:01 -07:00
Olaoluwa Osuntokun
6e59bd811a Merge branch 'v0.15.1-beta-6739' into v0.15.1-branch-rc1 2022-08-12 17:02:47 -07:00
Elle Mouton
74a8cb09e5 rpcperms: re-init mw lookup map after removal of one
After removing a registered middlware from the slice, we need to update
the index lookup map with the updated index for each middleware.
2022-08-12 17:02:47 -07:00
Olaoluwa Osuntokun
62dcb3ca34 Merge branch 'v0.15.1-beta-6545' into v0.15.1-branch-rc1 2022-08-12 17:02:31 -07:00
yyforyongyu
c9461d3925 docs: add release note for skip_temp_err 2022-08-12 17:02:31 -07:00
yyforyongyu
31ba12d553 routerrpc+cmd: use skip_temp_err when sending to route 2022-08-12 17:02:31 -07:00
yyforyongyu
ec8506e923 routerrpc: add new field skip_temp_err in SendToRouteRequest 2022-08-12 17:02:31 -07:00
yyforyongyu
b4df816530 routing: fix unit test for SendToRoute
This commit removes the old multi shards test for `SendToRoute` as the
method doesn't support sending MPP. The original test passed due to a
flawed mocking method, where the mockers bypassed the public interfaces
to maintain their internal state, which caused a non-exsiting situation
that a temp error wouldn't fail the payment. A new unit test is added to
demonstrate the actual case.
2022-08-12 17:02:31 -07:00
yyforyongyu
350ddfb1c7 routing: add unit test for SendToRouteSkipTempErr 2022-08-12 17:02:31 -07:00
yyforyongyu
1ad08d1b44 routing: add SendToRouteSkipTempErr to skip temp error failure
This commit adds a new method `SendToRouteSkipTempErr` that skips
failing the payment unless a terminal error occurred. This is
accomplished by demoting the original `SendToRoute` to a private method
and creating two new methods on top of it to minimize code change.
2022-08-12 17:02:31 -07:00
Carsten Otto
eb95fc9579 router: fix typos 2022-08-12 17:02:31 -07:00
Olaoluwa Osuntokun
07a0a22531 Merge branch 'v0.15.1-beta-6722' into v0.15.1-branch-rc1 2022-08-12 17:00:50 -07:00
ErikEk
23f7923d2b doc: release notes 2022-08-12 17:00:50 -07:00
ErikEk
cacf83e0ec itest: cover sign and verify msg 2022-08-12 17:00:50 -07:00
ErikEk
d32427eb06 signrpc: add schnorr sig to sign and validate msg 2022-08-12 17:00:50 -07:00
Olaoluwa Osuntokun
bb5199936c Merge branch 'v0.15.1-beta-6718' into v0.15.1-branch-rc1 2022-08-12 17:00:38 -07:00
Slyghtning
a70fe7e41e lncli: chan_point option for abandonchannel [skip ci] 2022-08-12 17:00:38 -07:00
Olaoluwa Osuntokun
01be76c631 Merge branch 'v0.15.1-beta-6630' into v0.15.1-branch-rc1 2022-08-12 17:00:13 -07:00
Oliver Gugger
b9d15055a6 docs: update release notes 2022-08-12 17:00:13 -07:00
Oliver Gugger
94204f529a itest: add integration test for error interception 2022-08-12 17:00:13 -07:00
Oliver Gugger
0412784cb4 itest: add integration test for request replacement 2022-08-12 17:00:13 -07:00
Oliver Gugger
f0b762cbf8 rpcperms: intercept errors too 2022-08-12 17:00:13 -07:00
Oliver Gugger
bbb1781e1d lnrpc: add is_error to intercept message 2022-08-12 17:00:13 -07:00
Oliver Gugger
179d1b8db5 lnrpc: describe request replacement in API docs
This commit updates the comments in the proto file to mention the new
behavior of also being able to replace request messages.
2022-08-12 17:00:13 -07:00
Oliver Gugger
45c499a022 rpcperms: allow requests to be replaced as well
With this commit we allow a replacement message to be sent by the
middleware for a request type as well as the response type. This allows
an incoming RPC request to be modified before it is forwarded to lnd.
2022-08-12 17:00:13 -07:00
Oliver Gugger
83defb449a rpcperms: add replaceProtoMsg
Because of the way the gRPC Receive() method is designed, we need a way
to replace a proto message with the content of another one without
replacing the original instance itself (e.g. overwrite all values in the
existing struct instance).
2022-08-12 17:00:13 -07:00
Oliver Gugger
b08d1b2a4f lnrpc: enable RPC middleware in REST WebSockets
If we don't flag the /v1/middleware call as request streaming, it can't
be used properly with REST WebSockets because the proxy would close the
connection after the first request message.
2022-08-12 17:00:13 -07:00
Olaoluwa Osuntokun
cc8ccabec4 Merge branch 'v0.15.1-beta-6714' into v0.15.1-branch-rc1 2022-08-12 16:59:53 -07:00
Oliver Gugger
5e8a073203 docs: add release notes 2022-08-12 16:59:53 -07:00
Oliver Gugger
5a038a9de1 itest: fix timeout in sign_psbt test 2022-08-12 16:59:53 -07:00
Oliver Gugger
d7dcbbf9d8 lnwallet: don't create BIP044 key scope by default
With a change in #6379 we made sure that all default scopes are added to
the the wallet. Unfortunately this included the BIP044 key scope that
our wallet doesn't really use. This breaks the remote signing setup
because we don't export the account of the BIP044 scope and therefore
run into an issue on the watch-only side when attempting to create the
wallet.
2022-08-12 16:59:53 -07:00
Olaoluwa Osuntokun
db32955f54 Merge branch 'v0.15.1-beta-6724' into v0.15.1-branch-rc1 2022-08-12 16:59:15 -07:00
Elle Mouton
7778d987f4 lncli: add ignore_pair flag to queryroutes 2022-08-12 16:59:15 -07:00
Olaoluwa Osuntokun
a936eeee9a Merge branch 'v0.15.1-beta-6712' into v0.15.1-branch-rc1 2022-08-12 16:58:53 -07:00
Olaoluwa Osuntokun
bedebc5caa lntest: keep all failed payments by default for HarnessNode
In this commit, we fix a detected flake: we go to make a payment, and
then want to assert that 2 attempts we required. The existing logic
assumes that the success and the payment will still be on disk. With a
recent PR, we now delete failed payments by default, but after the fact,
in a non-atomic fashion.

We fix this issue simply by having all the nodes keep around failed
payments for the sake of all the old itests that assumed this
information would always be on disk.

Introduced in: https://github.com/lightningnetwork/lnd/pull/6438.

Fixes https://github.com/lightningnetwork/lnd/issues/6711.
2022-08-12 16:58:53 -07:00
Olaoluwa Osuntokun
907e1084fc Merge branch 'v0.15.1-beta-6709' into v0.15.1-branch-rc1 2022-08-12 16:58:27 -07:00
Elle Mouton
3968f2a50f rpcperms: enforce order of interceptors
In this commit, we let the registered middleware interceptors be stored
in a slice rather than a map so that the order in which the interceptors
are executed is guarenteed to be the same as the order in which they
were registered.
2022-08-12 16:58:27 -07:00
Olaoluwa Osuntokun
45751da711 Merge branch 'v0.15.1-beta-5955' into v0.15.1-branch-rc1 2022-08-12 16:58:16 -07:00
eugene
c8395475c8 funding: revert earlier change for LDK compatibility
This removes the requirement that the zero-conf channel acceptor
flow use anchors. Also adds a fail-early check for minimum depth
zero in the non zero conf case. It would fail later, but it makes
more sense to fail immediately when receiving AcceptChannel.
2022-08-12 16:58:16 -07:00
eugene
78d7545e4d release-notes: update for 0.15.0 2022-08-12 16:58:16 -07:00
eugene
a226894cda sample-lnd: showing how to enable scid-alias, zero-conf feature bits 2022-08-12 16:58:16 -07:00
eugene
3b66147164 itest: zero-conf, scid-alias channel-type integration tests 2022-08-12 16:58:16 -07:00
eugene
ffb7f1d017 multi: add zero-conf, scid-alias channel-types to rpc
This allows the open channel rpcs to use the zero-conf or scid-alias
channel types.
2022-08-12 16:58:16 -07:00
eugene
e0221e593f server+netann+peer: put peer's alias in Update, proper config for link
This commit modifies the netann subsystem to use the peer's alias
for ChannelUpdates where appropriate (i.e. in case we are sending
the alias to the peer). It also modifies the loadActiveChannels
function in the peer package to handle upgrading a channel when the
scid-alias feature bit is turned on.
2022-08-12 16:58:16 -07:00
eugene
fff6f6b07c chanbackup: handle Single creation for zero-conf channels
The SCB function NewSingle is now zero-conf aware. Since the confirmed
short channel id may be unknown, it may use the broadcast height.
2022-08-12 16:58:16 -07:00
eugene
ea4be6069b contractcourt: set proper height hint for zero-conf channels
The contractcourt's chain watcher is now zero-conf aware and will use
an appropriate heightHint when scanning the chain.
2022-08-12 16:58:16 -07:00
eugene
adea487638 rpcserver+invoicesrpc: alias-aware AddInvoice,AddHoldInvoice rpc
AddInvoice,AddHoldInvoice now issue invoices that include our
peer's aliases. Some extra sanity checks are included to ensure we
don't leak our confirmed SCID for a private channel.
2022-08-12 16:58:16 -07:00
eugene
7ec5d09ef1 server+funding: allow scid-alias, zero-conf chantypes, scid-alias
feature-bit channels

This allows opening zero-conf chan-type, scid-alias chan-type, and
scid-alias feature-bit channels. scid-alias chan-type channels are
required to be private. Two paths are available for opening a zero-conf
channel:

* explicit chan-type negotiation
* LDK carve-out where chan-types are not used, LND is on the
  receiving end, and a ChannelAcceptor is used to enable zero-conf

When a zero-conf channel is negotiated, the funding manager:
* sends a FundingLocked with an alias
* waits for a FundingLocked from the remote peer
* calls addToRouterGraph to persist the channel using our alias in
  the graph. The peer's alias is used to send them a ChannelUpdate.
* wait for six confirmations. If public, the alias edge in the
  graph is deleted and replaced (not atomically) with the confirmed
  edge. Our policy is also read-and-replaced, but the counterparty's
  policy won't exist until they send it to us.

When a scid-alias-feature channel is negotiated, the funding manager:
* sends a FundingLocked with an alias:
* calls addToRouterGraph, sends ChannelUpdate with the confirmed SCID
  since it exists.
* when six confirmations occurs, the edge is deleted and re-inserted
  since the peer may have sent us an alias ChannelUpdate that we are
  storing in the graph.

Since it is possible for a user to toggle the scid-alias-feature-bit
to on while channels exist in the funding manager, care has been taken
to ensure that an alias is ALWAYS sent in the funding_locked message
if this happens.
2022-08-12 16:58:16 -07:00
eugene
37c68c1f19 server+htlcswitch: prevent privacy leaks, allow alias routing
This intent of this change is to prevent privacy leaks when routing
with aliases and also to allow routing when using an alias. The
aliases are our aliases.

Introduces are two maps:

* aliasToReal:
  This is an N->1 mapping for a channel. The keys are the set of
  aliases and the value is the confirmed, on-chain SCID.

* baseIndex:
  This is also an N->1 mapping for a channel. The keys are the set
  of aliases and the value is the "base" SCID (whatever is in the
  OpenChannel.ShortChannelID field). There is also a base->base
  mapping, so not all keys are aliases.

The above maps are populated when a link is added to the switch and
when the channel has confirmed on-chain. The maps are not removed
from if the link is removed, but this is fine since forwarding won't
occur.

* getLinkByMapping
  This function is introduced to adhere to the spec requirements that
  using the confirmed SCID of a private, scid-alias-feature-bit
  channel does not work. Lnd implements a stricter version of the spec
  and disallows this behavior if the feature-bit was negotiated, rather
  than just the channel type. The old, privacy-leak behavior is
  preserved.

The spec also requires that if we must fail back an HTLC, the
ChannelUpdate must use the SCID of whatever was in the onion, to avoid
a privacy leak. This is also done by passing in the relevant SCID to
the mailbox and link. Lnd will also cancel back on the "incoming" side
if the InterceptableSwitch was used or if the link failed to decrypt
the onion. In this case, we are cautious and replace the SCID if an
alias exists.
2022-08-12 16:58:16 -07:00
eugene
d242b86232 server+routing: pass isAlias to router
This allows the router to determine what is and isn't an alias from
lnd's definition of an alias. Any ChannelAnnouncement that has an
alias ShortChannelID field is not verified on-chain. To prevent a
DoS vector from existing, the gossiper ensures that only the local
lnd node can send its ChannelAnnouncements to the router with an
alias ShortChannelID.
2022-08-12 16:58:16 -07:00
eugene
550f8f0d5a server+discovery: alias-handling in gossiper
An OptionalMsgField has been added that allows outside subsystems
to provide a short channel id we should insert into a ChannelUpdate
that we then sign and send to our peer.

When the gossiper receives a ChannelUpdate, it will query the
alias manager by the passed-in FindBaseByAlias function to determine
if the short channel id in the ChannelUpdate points to a known
channel. If this lookup returns an error, we'll fallback to using
the original id in the ChannelUpdate when querying the router.
The lookup and potential fallback must occur in order to properly
lock the multimutex, query the correct router channels, and rate
limit the correct short channel id. An unfortunate side effect of
receiving ChannelUpdates from our peer that reference on of our
aliases rather than the real SCID is that we must store this policy.
Yet it is not broadcast-able. Care has been taken to ensure the
gossiper does not broadcast *any* ChannelUpdate with an alias SCID.

The cachedNetworkMsg uses the new processedNetworkMsg struct. This
is necessary so that delete-and-reinsert in the funding manager
doesn't process a ChannelUpdate twice and end up in a deadlock since
the err chan is no longer being used.
2022-08-12 16:58:16 -07:00
eugene
d7d84a1f7e aliasmgr: new data store containing our, peer's aliases
This introduces the a store for managing all things alias-related.

There are two maps:

* baseToSet:
  This stores the "base" short channel id as the key. The value is
  the set of all aliases issued for this channel. The "base" SCID is
  whatever is stored in the OpenChannel's ShortChannelID member. For
  everything other than zero-conf channels, this is the confirmed SCID.
  For zero-conf channels, this is the very first alias assigned. This is
  used mostly by the Switch to retrieve a set of aliases and determine
  if it is safe to forward.

* aliasToBase:
  This stores the reverse mapping of baseToSet. Each key is an alias
  SCID and the value is the "base" SCID. This is exclusively used by
  the gossiper to determine if an alias in a ChannelUpdate our peer
  sends actually references a channel we know of.

The functions make use of the above two maps:

* AddLocalAlias:
  This persists the {alias, base} pair in the database. The baseToSet
  map is populated. The aliasToBase is optionally populated depending on
  where this function is called from. Upgrade cases, where the
  scid-alias feature bit is toggled and channels already exist, will
  not persist to the gossip map. This is mainly to simplify the tangle
  of logic that would otherwise occur.

* GetAliases:
  This fetches the set of aliases by using the passed-in base SCID. This
  is used in the Switch and other places where the alias set is needed.

* FindBaseSCID:
  This fetches the base given an alias. This is used in the gossiper to
  determine validity of a peer's ChannelUpdate that contains an alias.

* DeleteSixConfs:
  This removes the aliasToBase map entry for the given "base". This is
  used when the gossiper mappings are no longer needed, i.e. when the
  channel has six confirmations and is public.

* PutPeerAlias:
  Stores the peer's alias.

* GetPeerAlias:
  Fetches the peer's alias.

* RequestAlias:
  Generates an alias for us in the range 16000000:0:0 and
  16250000:16777215:65535
2022-08-12 16:58:16 -07:00
eugene
888fbc6be3 lnwallet: extend Reservation with alias chan-type, feature-bit flags
This extends the Reservation arguments to include whether a pending
channel open has negotiated the zero-conf channel type, the scid-alias
channel type, and/or the scid-alias feature bit. The result of those
negotiates are stored in the OpenChannel's ChanType. The arguments to
NewChannelReservation have also been simplified.
2022-08-12 16:58:16 -07:00
eugene
5d2b686f0b channeldb: BigSize migration, store zero-conf, scid-alias bits
This introduces a BigSize migration that is used to expand the width
of the ChannelStatus and ChannelType fields. Three channel "types"
are added - ZeroConfBit, ScidAliasChanBit, and ScidAliasFeatureBit.
ScidAliasChanBit denotes that the scid-alias channel type was
negotiated for the channel. ScidAliasFeatureBit denotes that the
scid-alias feature bit was negotiated during the *lifetime* of the
channel. Several helper functions on the OpenChannel struct are
exposed to aid callers from different packages.

The RefreshShortChanID has been renamed to Refresh.

A new function BroadcastHeight is used to guard access to the
mutable FundingBroadcastHeight member. This prevents data races.
2022-08-12 16:58:16 -07:00
eugene
23b6460201 lnwire: add alias to FundingLocked in TLV
This adds an optional short channel id field to the FundingLocked
message that is sent/received as a TLV segment inside the
ExtraOpaqueData field.
2022-08-12 16:58:16 -07:00
eugene
c815fb8de7 server+lncfg: protocol flag to enable scid-alias, zero-conf feature bits
This allows the zero-conf and scid-alias feature bits to be toggled
using the config. The feature bits are off by default to protect users
from accidentally incurring the risk of a zero-conf channel.
2022-08-12 16:58:16 -07:00
eugene
113de58d77 lnwire+feature: new zero-conf, scid-alias feature bit + chantypes
This defines the zero-conf feature bit, the scid-alias feature bit,
the zero-conf channel type, and the scid-alias channel type. It also
defines the dependency "tree" that exists for the feature bits.

The scid-alias feature bit signals that the node requires an alias
short channel id to be sent in funding_locked. The scid-alias channel
type requires that the channel is private, in addition to some other
forwarding-related privacy measures.
2022-08-12 16:58:16 -07:00
Olaoluwa Osuntokun
e5870319be Merge branch 'v0.15.1-beta-6705' into v0.15.1-branch-rc1 2022-08-12 16:57:56 -07:00
Slyghtning
270971c475 lncli: chan_point option for updatechanstatus 2022-08-12 16:57:56 -07:00
Olaoluwa Osuntokun
5c8e8ae7be Merge branch 'v0.15.1-beta-6698' into v0.15.1-branch-rc1 2022-08-12 16:57:44 -07:00
Slyghtning
c25641b624 lncli: Fix batchopenchannel help text [skip ci] 2022-08-12 16:57:44 -07:00
Olaoluwa Osuntokun
d4cf0f1bdc Merge branch 'v0.15.1-beta-6636' into v0.15.1-branch-rc1 2022-08-12 16:57:31 -07:00
Tommy Volk
43e6a20d37 gitrelease-notes: update release notes for 0.15.1 2022-08-12 16:57:31 -07:00
Tommy Volk
60017f87f4 multi: migrate assert.NoError to require.NoError 2022-08-12 16:57:31 -07:00
Olaoluwa Osuntokun
f14a02c356 Merge branch 'v0.15.1-beta-6438' into v0.15.1-branch-rc1 2022-08-12 16:57:03 -07:00
Tommy Volk
fc2c90275c gitrelease-notes: update release notes for 0.15.1 2022-08-12 16:57:03 -07:00
Tommy Volk
064e0c6273 channeldb+routing: htlcs are pruned on settle 2022-08-12 16:57:03 -07:00
Tommy Volk
0a1289d606 multi: add keep-failed-payment-attempts flag 2022-08-12 16:57:03 -07:00
Olaoluwa Osuntokun
0d98121f12 Merge branch 'v0.15.1-beta-6685' into v0.15.1-branch-rc1 2022-08-12 16:56:20 -07:00
Oliver Gugger
b8e5b9b5e5 docs: fix formatting and phrasing [skip ci] 2022-08-12 16:56:10 -07:00
Oliver Gugger
4d2c9928dd docs: remove duplicate headings 2022-08-12 16:56:09 -07:00
Oliver Gugger
d1b33e0fbf docs: move 0.15.1 release notes item 2022-08-12 16:54:57 -07:00
Olaoluwa Osuntokun
d4cdc01073 Merge branch 'v0.15.1-beta-6642' into v0.15.1-branch-rc1 2022-08-12 16:53:46 -07:00
eugene
d707b239f7 release-notes: update for 0.15.1 2022-08-12 16:53:32 -07:00
eugene
3171d17edf htlcswitch: add linkStopIndex to cleanly shutdown ChannelLink
With this, extra calls to RemoveLink will wait for the link to
fully stop. This is accomplished by a map that stores a single stop
channel that callers to RemoveLink will listen on. This map is not
consulted when the Switch is shutting down and calls Stop on each
individual link. Though that could be added in the future, it is
not necessary.
2022-08-12 16:51:55 -07:00
Olaoluwa Osuntokun
e28de57075 Merge branch 'v0.15.1-beta-6687' into v0.15.1-branch-rc1 2022-08-12 16:51:33 -07:00
Oliver Gugger
7279732c92 docs: add release notes 2022-08-12 16:51:22 -07:00
Oliver Gugger
f273d11a3b itest: add test for FundPsbt->SignPsbt|FinalizePsbt flow 2022-08-12 16:50:34 -07:00
Oliver Gugger
d88e58c34f lnwallet: fix bug in SignPsbt with np2wkh addresses
Fixes #6626.
If either of the two fields FinalScriptSig or FinalScriptWitness is set
on an input of a PSBT then that results in most of the fields of that
input not to be serialized in the packet anymore, since the input is
considered to be complete.
But because a signer isn't supposed to set any of the Final* fields,
this was wrong from the beginning. Only the finalizer will set those
fields.
2022-08-12 16:50:34 -07:00
Olaoluwa Osuntokun
492ed23d70 Merge branch 'v0.15.1-beta-6592' into v0.15.1-branch-rc1 2022-08-12 16:50:21 -07:00
priyanshiiit
4a0ae8cd61 docs: adds wallet reserve rpc & field in wallet balance 2022-08-12 16:49:19 -07:00
priyanshiiit
51a2fb5c33 lntest: adds check for reserve 2022-08-12 16:48:38 -07:00
priyanshiiit
de09d56369 lnrpc+lncli: adds required reserve rpc & cli 2022-08-12 16:48:38 -07:00
priyanshiiit
8f4dd85773 lnrpc+lnd: adds required reserve in walletbalance rpc 2022-08-12 16:48:38 -07:00
priyanshiiit
212832e8de lnwallet: adds RequiredReserve method 2022-08-12 16:48:38 -07:00
priyanshiiit
e07c6c2681 lnwallet: exports fields related to AnchorChans 2022-08-12 16:48:38 -07:00
Olaoluwa Osuntokun
3e889a5069 Merge branch 'v0.15.1-beta-6680' into v0.15.1-branch-rc1 2022-08-12 16:44:38 -07:00
Oliver Gugger
e1fb7dd4ca docs: add release notes 2022-08-12 16:44:38 -07:00
Oliver Gugger
2c5ac5554e itest: add itest for p2tr via ComputeInputScript 2022-08-12 16:44:38 -07:00
Oliver Gugger
e45a2b9f12 itest: fix incorrect naming 2022-08-12 16:44:38 -07:00
Oliver Gugger
d1ea22dde3 itest: rename too specific variables 2022-08-12 16:44:38 -07:00
Oliver Gugger
90a0df6d90 signer: fix comment about p2tr in ComputeInputScript 2022-08-12 16:44:38 -07:00
Oliver Gugger
e59c410282 signrpc: fix p2tr support in ComputeInputScript 2022-08-12 16:44:38 -07:00
Olaoluwa Osuntokun
ebe0fb155d Merge branch 'v0.15.1-beta-6655' into v0.15.1-branch-rc1 2022-08-12 16:44:10 -07:00
eugene
aaf2a0238e release-notes: update for 0.15.1 2022-08-12 16:44:10 -07:00
eugene
acf35c4e6c itest: update switch delivery tests with more robust reconnect logic 2022-08-12 16:44:10 -07:00
eugene
6f07a7e9e9 server.go: replace call to removePeer with Disconnect in DisconnectPeer
Without this, calls to DisconnectPeer would bypass the
peerTerminationWatcher and allow subsequent connect requests to
go through before the peer's links were fully shut down. This could
lead to force closes.
2022-08-12 16:44:10 -07:00
Olaoluwa Osuntokun
80cd2b1b7e Merge branch 'v0.15.1-beta-6577' into v0.15.1-branch-rc1 2022-08-12 16:43:42 -07:00
ziggie
d588c04997 docs: update release note 2022-08-12 16:43:12 -07:00
ziggie
1502ce73ea cmd/lncli: make hop hint inclusion opt-in for addholdinvoice 2022-08-12 16:42:23 -07:00
Olaoluwa Osuntokun
71d754890e Merge branch 'v0.15.1-beta-6676' into v0.15.1-branch-rc1 2022-08-12 16:41:47 -07:00
Oliver Gugger
231c4b86a1 doc: add release notes 2022-08-12 16:41:47 -07:00
Oliver Gugger
4383f20477 .gitignore: add release build directory to ignore list
Fixes #6672.
A new metadata tag called build.vcs.modified was added in Go 1.18.x that
indicates whether there were any untracked files present during the
build or not.
Because the `make release` command creates a directory in which the
output packages are created, and because that directory was not added
to git and also not ignored by it, the build.vcs.modified flag was
different to the docker build which resulted in a different digest of
the resulting binary.
2022-08-12 16:41:47 -07:00
Olaoluwa Osuntokun
49465b8e32 Merge branch 'v0.15.1-beta-6682' into v0.15.1-branch-rc1 2022-08-12 16:41:27 -07:00
ErikEk
b393e37e19 dep: urfave/cli update 2022-08-12 16:41:27 -07:00
Olaoluwa Osuntokun
8cbb3ab598 Merge branch 'v0.15.1-beta-6673' into v0.15.1-branch-rc1 2022-08-12 16:41:00 -07:00
yyforyongyu
f53522001b channeldb: fix data race in TestSerializeHTLCEntries 2022-08-12 16:41:00 -07:00
Olaoluwa Osuntokun
d532c60d99 Merge branch 'v0.15.1-beta-6321' into v0.15.1-branch-rc1 2022-08-12 16:40:40 -07:00
priyanshiiit
c7387534ea docs: add previous outpoints to listchaintxns 2022-08-12 16:40:40 -07:00
priyanshiiit
3b05e5607f lntest: adds test for previous outpoints 2022-08-12 16:40:40 -07:00
priyanshiiit
ddc54387ba lnrpc: add previous_outpoints to listchaintxns 2022-08-12 16:40:40 -07:00
priyanshiiit
bd32b648f4 lnwallet: add previous_outpoints to ListTransactionDetails 2022-08-12 16:40:40 -07:00
Olaoluwa Osuntokun
12afc2f447 Merge branch 'v0.15.1-beta-6559' into v0.15.1-branch-rc1 2022-08-12 16:39:00 -07:00
ErikEk
47ba871d82 doc: release note 2022-08-12 16:36:33 -07:00
ErikEk
3f3bc404c2 doc: subscribe/cancel/lookup invoices rest 2022-08-12 16:35:40 -07:00
Olaoluwa Osuntokun
ffd9226c82 Merge branch 'v0.15.1-beta-6576' into v0.15.1-branch-rc1 2022-08-12 16:35:02 -07:00
Elle Mouton
bdad44761e docs/release-notes: add note for 6576 2022-08-12 16:35:02 -07:00
Elle Mouton
8dd4571442 cmd/lncli: add payment_addr flag to buildroute 2022-08-12 16:35:02 -07:00
rockstardev
ca4d531435
Removing experimental features, no longer needed 2022-07-25 18:58:05 -05:00
rockstardev
acd72a7fe5
Updating circleci image for multiarch task
Previous one got depricated
https://circleci.com/blog/ubuntu-14-16-image-deprecation/
2022-07-25 18:49:44 -05:00
rockstardev
b0473a9034
Adding BtcPayServer related files and resources 2022-07-25 17:59:45 -05:00
sgiammy
713b79680f accept 'signet' as LND_ENVIRONMENT variable 2022-03-18 13:36:32 +00:00
rockstardev
48e3fa8eed
Cleaning up README, adding new versions 2022-02-07 01:11:40 -06:00
rockstardev
6a5c491ee6
Merge branch 'version/0.14.2-beta'
# Conflicts:
#	Makefile
2022-02-07 01:10:24 -06:00
rockstardev
722219aaf8
Adding BtcPayServer related files and resources 2022-02-07 00:36:59 -06:00
Olaoluwa Osuntokun
1e511be523
build: bump version to v0.14.2-beta
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2022-02-03 12:20:47 -08:00
Olaoluwa Osuntokun
8c0d61c7e2
build: bump version to v0.14.2-beta.rc2
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2022-02-03 12:19:40 -08:00
Olaoluwa Osuntokun
5446478ec0 lnwallet: increase legacy fee limit threshold to 1k sats
In this commit, we increase the legacy fee limit threshold (the amount
below which we'll allow 100% of funds to go to fees for the non-v2 RPC
calls) from 50 sats to 1k sats.
2022-02-03 12:19:01 -08:00
Olaoluwa Osuntokun
d4b621b0be Merge branch 'v0.14.2-beta-6226' into v0-14-2-branch-rc1 2022-02-02 12:55:37 -08:00
Oliver Gugger
11c57040aa lncli: use amount based default routing fee 2022-02-02 12:55:16 -08:00
Oliver Gugger
4754e87ce6 lnrpc: use amount based default routing fee 2022-02-02 12:54:15 -08:00
Oliver Gugger
2295ae34ee lnwallet: introduce default routing fee calculation 2022-02-02 12:54:15 -08:00
Olaoluwa Osuntokun
25081770b6
build: bump version to v0.14.2-beta.rc1
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2022-01-26 11:20:10 -08:00
Olaoluwa Osuntokun
824c2a70fc
Merge pull request #6201 from Roasbeef/v0.14.2-branch-rc1
multi: create v0.14.2-beta-rc1 branch
2022-01-26 11:13:46 -08:00
Olaoluwa Osuntokun
9448ca93ea
channeldb: fix unit test API usage after graph cache speedups 2022-01-25 18:18:37 -08:00
Olaoluwa Osuntokun
09b1ae99e6
Merge branch 'v0.14.2-beta-6200' into v0.14.2-branch-rc1 2022-01-25 17:56:22 -08:00
Olaoluwa Osuntokun
8f12fe3daa docs/release-notes: add entry for fee rate bug fix and rpc change 2022-01-25 17:52:24 -08:00
Andras Banki-Horvath
4be12bcd2c itest: add test for the channel policy fee rate round down bug 2022-01-25 17:52:24 -08:00
ErikEk
ed3defc412 lnrpc: fix the existing routing fee inaccuracy
When updating the channel routing policy, we encounter an inaccurate
precision error when calculating the routing fee. The issue stems from
the way the IEEE 754 standard works.

The solution here is to add a uint64 parameter (as mentioned in the
issue) and keep the float64 fee_rate parameter but rounding the product
of the base and fee rate.
2022-01-25 17:52:22 -08:00
Olaoluwa Osuntokun
4b9a23b251 Merge branch 'v0.14.2-beta-6158' into v0.14.2-branch-rc1 2022-01-25 17:49:22 -08:00
eugene
5dbff49d96 docs/release-notes: update notes for 0.14.2 2022-01-25 17:49:08 -08:00
eugene
de4332a6a9 server+contractcourt: hand-off BreachCloseInfo to channel arbitrator
This also changes the chain_watcher and breacharbiter handoff. The
new logic ensures that the channel is only marked as pending closed
when the channel arbitrator has persisted the resolutions and commit
set.
2022-01-25 17:48:41 -08:00
eugene
324c578f77 contractcourt: create breachResolver if BreachResolution present
Also transitions to the proper state based on if this is a legacy
breach in the channel arbitrator or a modern breach with a resolver.
2022-01-25 17:48:02 -08:00
eugene
9b4ab45c5a contractcourt: handle writing BreachResolution in arbitrator log 2022-01-25 17:48:02 -08:00
eugene
3e301785a4 server+contractcourt: add breachResolver that subscribes to breacharbiter
Introduces a breachResolver that subscribes to the breacharbiter to
determine if the final justice transaction has confirmed and can
clean itself up.
2022-01-25 17:48:02 -08:00
Olaoluwa Osuntokun
4f85ff8b69 Merge branch 'v0.14.2-beta-6185' into v0.14.2-branch-rc1 2022-01-25 17:46:56 -08:00
Daniel McNally
99b1347789 rpcperms: set CustomCaveatCondition on middleware req
This sets the `CustomCaveatCondition` value on rpc middleware requests
if one exists. Previously, this value was always blank even if the
macaroon had a value set for its custom caveat condition.
2022-01-25 17:46:56 -08:00
Daniel McNally
a619a9bb04 macaroons: add GetCustomCaveatCondition func
This adds a `GetCustomCaveatCondition` function that returns the custom
caveat condition for a given macaroon and caveat name. Previously there
was no function for getting the custom caveat condition from a macaroon,
only for setting one.
2022-01-25 17:46:56 -08:00
Olaoluwa Osuntokun
a7676e83f4 Merge branch 'v0.14.2-beta-6111' into v0.14.2-branch-rc1 2022-01-25 17:45:13 -08:00
Joost Jager
c6439b907b channeldb: speed up graph cache loading
Use the optimized ForEachChannel method to reduce the graph cache
loading time.
2022-01-25 17:44:43 -08:00
Joost Jager
07a9130734 channeldb: reallocate node in ForEachNodeCacheable
Allows cacheableNode to be used outside of the callback. This is a
preparation for optimization of the graph cache population.
2022-01-25 17:44:09 -08:00
Joost Jager
543eff9d24 channeldb: optimize ForEachChannel
In this commit, we modify the implementation of ForEachChannel to
utilize the new kvdb method ForAll. This greatly reduces the number of
round-trips to the database needed to iterate over all channels
in the graph.
2022-01-25 17:44:09 -08:00
Joost Jager
8a7afd17fb channeldb: extract deserializeChanEdgePolicyRaw
Allows for pure deserialization without depending on a database connection.
2022-01-25 17:44:09 -08:00
Joost Jager
a95acb393b channeldb: extract AddNodeFeatures
Preparation for efficient graph cache loading where we don't iterate
over the channels of each node in the network individually.
2022-01-25 17:44:09 -08:00
Joost Jager
ab79c7bcaa kvdb: add ForAll
A new method to allow efficient range queries for backends that support
it.
2022-01-25 17:44:09 -08:00
Joost Jager
d6c1b7129d routing: remove unused ForEachChannel 2022-01-25 17:44:09 -08:00
Joost Jager
2d2bb75d85 kvdb/postgres: use readonly db transaction if possible 2022-01-25 17:44:09 -08:00
Olaoluwa Osuntokun
592c5363c4 Merge branch 'v0.14.2-beta-6180' into v0.14.2-branch-rc1 2022-01-25 17:43:18 -08:00
Andras Banki-Horvath
695baa1b45 docs: update release notes 0.14.2 2022-01-25 17:43:18 -08:00
Andras Banki-Horvath
5dca6dce00 lncli: add force flag to 2022-01-25 17:43:18 -08:00
Andras Banki-Horvath
5915f546a3 routing: add option to force import MC pair history
This commit adds the `force` flag to the `XImportMissionControl` RPC
which allows skipping rules around the pair import except for what is
mandatory to make values meaningful. This can be useful for when clients
would like to forcibly override MC state in order to manipulate routing
results.
2022-01-25 17:43:18 -08:00
Olaoluwa Osuntokun
7d5841e95e Merge branch 'v0.14.2-beta-6159' into v0.14.2-branch-rc1 2022-01-25 17:42:51 -08:00
Olaoluwa Osuntokun
6476f1601c docs/release-notes: add entry for historical chan bucket check 2022-01-25 17:42:51 -08:00
Olaoluwa Osuntokun
1d16c44db9 contractcourt: catch error when no historical bucket exists
For older nodes, this bucket was never created, so we'll get an error if
we try and query it. In this commit, we catch this error like we do when
a given channel doesn't have the information (but the bucket actually
exists).

Fixes #6155
2022-01-25 17:42:51 -08:00
Olaoluwa Osuntokun
0a9153593c Merge branch 'v0.14.2-beta-6144' into v0.14.2-branch-rc1 2022-01-25 17:42:33 -08:00
Olaoluwa Osuntokun
8c284fd150 docs/release-notes: add entry for peer defer fix 2022-01-25 17:42:33 -08:00
Olaoluwa Osuntokun
785b4118f8 lnwire+peer: clamp pong bytes, make ping handler more effcieint
This was not properly enforced and would be a spec violation on the
peer's end. Also re-use a pong buffer to save on heap allocations if
there are a lot of peers. The pong buffer is only read from, so this
is concurrent safe.
2022-01-25 17:42:33 -08:00
Olaoluwa Osuntokun
f206992cfc peer: always defer clean up of the block epoch client used for ping headers
In this commit, we fix an inadvertent memory leak by ensuring we always
use `defer` to clean up the allocated objects/memory we use to be
notified of new blocks to update what we send within the set of ping
headers.

A further optimization here would be using a single global block epoch
housed within the server, that all peer `pingHandler` goroutines use
directly.

Fixes #6143.
2022-01-25 17:42:33 -08:00
Olaoluwa Osuntokun
b59470e351 Merge branch 'v0.14.2-beta-6146' into v0.14.2-branch-rc1 2022-01-25 17:42:18 -08:00
yyforyongyu
50bddcab38 docs: add release note for closing txid 2022-01-25 17:42:18 -08:00
yyforyongyu
981464846a rpcserver: add closing txid in WaitingCloseChannel 2022-01-25 17:42:18 -08:00
yyforyongyu
ea595cbee1 rpcserver: split PendingChannels into three sections
This commit refactors the method PendingChannels for maintenance
purpose.
2022-01-25 17:42:18 -08:00
Olaoluwa Osuntokun
ade8514afe Merge branch 'v0.14.2-beta-6140' into v0.14.2-branch-rc1 2022-01-25 17:41:56 -08:00
Joost Jager
384962c272 htlcswitch: fix duplicate close
The decayed log database opening and closing is managed at a higher
level in config_builder.go.
2022-01-25 17:41:56 -08:00
Olaoluwa Osuntokun
6b36326259 Merge branch 'v0.14.2-beta-6006' into v0.14.2-branch-rc1 2022-01-25 17:41:14 -08:00
Oliver Gugger
1052aabfeb docs: update remote signing doc and release notes 2022-01-25 17:41:02 -08:00
Oliver Gugger
b597690741 multi: add migrate-wallet-to-watch-only flag
To enable converting an existing wallet with private key material into a
watch-only wallet on first startup with remote signing enabled, we add a
new flag. Since the conversion is a destructive process, this shouldn't
happen automatically just because remote signing is enabled.
2022-01-25 17:40:15 -08:00
Oliver Gugger
52f313593e lnwallet: initialize first 255 accounts
This fixes lightninglabs/loop#437 by adding all accounts that are used
in liquidity products such as Loop or Pool. Since both of these products
use key families below 255, we can get by with that number.
The alternative to creating way too many accounts (which increases the
default wallet size by ~250kB) would be to hard code the exact accounts
used by Loop (99) and Pool (210). But that sounds like a bad idea given
that there could always be more accounts being added to those (or other)
products. By making sure the first 255 accounts exist, we have a lot
more flexibility in those products for choosing key families.
2022-01-25 17:40:15 -08:00
Oliver Gugger
cc7d5e57eb multi: add nochainbackend option 2022-01-25 17:40:15 -08:00
Oliver Gugger
c538d3d307 multi: add health check for remote signer 2022-01-25 17:40:15 -08:00
Oliver Gugger
cd2012719b multi: make remote signer RPC timeout configurable 2022-01-25 17:40:15 -08:00
Oliver Gugger
a34ac85c50 rpcwallet: add critical log to remote signer errors 2022-01-25 17:40:15 -08:00
Oliver Gugger
0a2e56245f config_builder+rpcwallet: simplify RPC signing
With the remote signing instance now not needing to know anything about
addresses or current derivation indices, we don't need to forward any
such calls to that instance and can simplify the RPCKeyRing
considerably.
2022-01-25 17:40:15 -08:00
Oliver Gugger
248c6fc723 walletrpc+itest: add SignPsbt RPC 2022-01-25 17:40:15 -08:00
Oliver Gugger
d868ca3e34 btcwallet: add SignPsbt 2022-01-25 17:40:15 -08:00
Oliver Gugger
286e3742f6 lnd+lnwallet: add logger for btcwallet+rpcwallet 2022-01-25 17:40:15 -08:00
Oliver Gugger
6602efde63 lnwallet: add derivation and prev TX to UTXO 2022-01-25 17:40:15 -08:00
Oliver Gugger
9a54f273c2 btcwallet: add method for deriving key from BIP32 path 2022-01-25 17:40:15 -08:00
Oliver Gugger
5b331cfe27 btcwallet: move PSBT related methods to own file
This is a pure code move commit to extract the FundPsbt and FinalizePsbt
methods into their own file.
2022-01-25 17:40:15 -08:00
Oliver Gugger
5176a2c8d0 lnwallet+lntest+mod: bump btcwallet to export ScriptForOutput 2022-01-25 17:40:15 -08:00
Oliver Gugger
e3e21745d3 signrpc: remove incomplete sentence and TODO
We use SignOutputRaw which expects a witness script being set, even for
P2WKH. There is a special case in SignOutputRaw for the case where the
script is a p2wkh script, then the input script is reconstructed
correctly for the sighash.
2022-01-25 17:40:15 -08:00
Oliver Gugger
a6e931ed5b multi: fix formatting 2022-01-25 17:40:15 -08:00
Olaoluwa Osuntokun
d3714376d2 Merge branch 'v0.14.2-beta-6139' into v0.14.2-branch-rc1 2022-01-25 17:39:05 -08:00
Oliver Gugger
c505c5f946 docs: add release notes 2022-01-25 17:39:05 -08:00
Oliver Gugger
e5f62a0349 lntest: export base node config for re-use 2022-01-25 17:39:05 -08:00
Oliver Gugger
5f5f8573e1 lntest: export ListenerFormat constant 2022-01-25 17:39:05 -08:00
Oliver Gugger
3e99fea7bc lntest: fix colliding variable name
The variable name "bytes" collides with an imported package name, so we
rename it to avoid shadowing.
2022-01-25 17:39:05 -08:00
Olaoluwa Osuntokun
777d2f2f22 Merge branch 'v0.14.2-beta-6052' into v0.14.2-branch-rc1 2022-01-25 17:38:35 -08:00
Oliver Gugger
170684a170 itest: fix RPC middleware itest 2022-01-25 17:38:35 -08:00
yyforyongyu
beb1f06d9f itest: start using harness miner in harness net
This commit replaces the old miner with the new HarnessMiner and cleans
harness_node.go by moving methods into the test_common.go.
2022-01-25 17:38:35 -08:00
yyforyongyu
bc1d70a184 itest: introduce harness miner
This commit adds a new component, harness miner, to the itest. This
newly added component is responsible for checking the mempool and blocks
for the itest.
2022-01-25 17:38:35 -08:00
yyforyongyu
5a17ec3b65 itest: refactor initClientWhenReady to clean up init node 2022-01-25 17:38:35 -08:00
yyforyongyu
880d977346 itest: add method waitTillServerState in harness node 2022-01-25 17:38:35 -08:00
yyforyongyu
5b69e2c626 itest: use node.rpc namespace inside harness net
This commit adds a new struct RPCClients to better handle rpc clients.
A private field, rpc, is added to HarnessNode to prevent direct access
to its clients. Inside RPCClients, all clients are exported in case a
test case need access to a specific client.
2022-01-25 17:38:35 -08:00
yyforyongyu
e6df1522a7 itest: shorten functions inside harness node
This commit refactors the long function start() into smaller pieces and
moves commonly used functions into test_common.go.
2022-01-25 17:38:35 -08:00
Olaoluwa Osuntokun
0ae6c5dcf6 Merge branch 'v0.14.2-beta-5756' into v0.14.2-branch-rc1 2022-01-25 17:33:59 -08:00
yyforyongyu
0db1b7ec11 docs: update release note for itest ctxt fix 2022-01-25 17:33:45 -08:00
yyforyongyu
ea1fec84be makefile: add itest-clean to kill uncleaned processes 2022-01-25 17:32:36 -08:00
yyforyongyu
837569875e itest: replace fakeLogger with v2 logger with Discard 2022-01-25 17:32:36 -08:00
yyforyongyu
1fe306e21c itest: use run context when making rpc requests 2022-01-25 17:32:36 -08:00
yyforyongyu
360638879b itest: rename harness net file and add run context
This commit renames harness.go to harness_net.go. It also adds a run
context which is served as the parent context when creating new
contexts.
2022-01-25 17:32:36 -08:00
yyforyongyu
3000a691e5 itest: manage context within HarnessNode
This commit removes the context as a param needed when calling methods
of HarnessNode. This change moves the context management inside
HarnessNode, aside from saving us a few lines, it makes the context
creation/timeout less error-prone.
2022-01-25 17:32:36 -08:00
yyforyongyu
16526e40a8 itest: use ProcessState and runCtx to control process quit 2022-01-25 17:32:36 -08:00
yyforyongyu
4275e74cd3 itest: add run context to harness node
This commit adds a running context to HarnessNode which replaces all the
background context used and also serves as a way to signal quit when the
test is shutting down.
2022-01-25 17:32:36 -08:00
yyforyongyu
fd92c738e9 itest: add test_common to hold commonly used methods
A new file, test_common.go, is added to hold commonly used functions
across lntest.
2022-01-25 17:32:36 -08:00
Olaoluwa Osuntokun
c2fa9ff229 Merge branch 'v0.14.2-beta-6054' into v0.14.2-branch-rc1 2022-01-25 17:30:17 -08:00
yyforyongyu
8c92e029eb docs: add release note for premature msg fix 2022-01-25 17:28:10 -08:00
eugene
137fe297a6 discovery: use source instead of peer for accurate rejectCache 2022-01-25 17:26:45 -08:00
yyforyongyu
e07ab7aea6 discovery: resend premature messages when new blocks arrive
This commit adds a method to resend premature when new blocks arrive.
Previously when a message has specified a block+delta in the future, we
would ignore the message and never process it again, causing an open
channel never being broadcast under fast blocks generation. This commit
fixes it by saving the future messages and resending them once the
required block height is reached.
2022-01-25 17:26:45 -08:00
yyforyongyu
4f1905cea1 discovery: sync blocks in a dedicated goroutine
This commit moves syncing blocks into a dedicated goroutine to avoid the
race condition where several go channels are ready and the block height
update is pushed after a network message is processed.
2022-01-25 17:26:45 -08:00
yyforyongyu
bbc16ae30f routing+discovery: uniform error codes in routing 2022-01-25 17:26:45 -08:00
yyforyongyu
c808d27fef discovery: transit all inactive syncers when needed 2022-01-25 17:26:45 -08:00
yyforyongyu
c48db1ebeb discovery: shorten mutex locking closure 2022-01-25 17:26:45 -08:00
yyforyongyu
9b51237607 funding: add explicit log to avoid confusion 2022-01-25 17:26:45 -08:00
yyforyongyu
bad0db11b8 funding: add String method for channelOpeningState
The newly added String method can be helpful in reading logs.
2022-01-25 17:26:45 -08:00
yyforyongyu
3d0bd75947 chainntnfs: add more verbose logs for txnotifier 2022-01-25 17:26:45 -08:00
yyforyongyu
92cda1a358 discovery: add verbose network messages related logs 2022-01-25 17:26:45 -08:00
Olaoluwa Osuntokun
eb5f6d5d92 Merge branch 'v0.14.2-beta-6116' into v0.14.2-branch-rc1 2022-01-25 17:25:27 -08:00
Joost Jager
7845fe0bba itest: increase pg database connection limit 2022-01-25 17:25:14 -08:00
yyforyongyu
e39fbcef11 docs: add release note for peer conn fix 2022-01-25 17:23:18 -08:00
yyforyongyu
fc7b5f8b5f server: fix peers not ignored during bootstrapping
This commit fixes the issue where duplicate peers are used both in
making persistent connections and bootstrap connections. When we init
bootstrapping, we need to ignore peers that have connections already
made so far plus peers which we are attempting to make connections with,
hence the persistent peers.
2022-01-25 17:21:40 -08:00
yyforyongyu
a4e87fd2de multi: enhance logging for debugging peer connection 2022-01-25 17:21:40 -08:00
Olaoluwa Osuntokun
c8ba5e2ca3 Merge branch 'v0.14.2-beta-6108' into 0-14-2-branch-rc1 2022-01-25 17:17:48 -08:00
Joost Jager
dc0b0e9b38 kvdb/postgres: fix context cancellation 2022-01-25 17:17:48 -08:00
Joost Jager
94def4508e kvdb/postgres: fix tests 2022-01-25 17:17:48 -08:00
Olaoluwa Osuntokun
9f53786bdb docs/release-notes: add entry for chan type fix 2022-01-25 17:16:12 -08:00
Olaoluwa Osuntokun
ba46b98c3c funding: always send a channel type in explicit mode
In this commit, we switch to always sending a channel type when we're in
explicit mode. This is compatible with prior versions of lnd as they
won't send a channel type, and we'll just arrive at the same type via
the existing implicit funding.

Fixes https://github.com/lightningnetwork/lnd/issues/6067
2022-01-25 17:16:12 -08:00
Matthew Bajorek
9d399d412a docs: update release note for #6073 [skip ci] 2022-01-25 17:14:13 -08:00
Matthew Bajorek
3e3de70a7a netann: clarify invalid config timeout constraints [skip ci] 2022-01-25 17:13:52 -08:00
Elle Mouton
e8002dd536 lnwallet+docs: minrelayfee always above fee floor
The minimum relay fee is always ensured to be above our fee floor except
in the very first min relay fee query to bitcoind. This commit ensures
that the fee floor is respected in this first query.
2022-01-25 17:11:56 -08:00
Bjarne Magnussen
c8173b60b3 add to release notes 0.14.2 2022-01-25 17:08:34 -08:00
Bjarne Magnussen
f06aecc5da lnrpc: refactor populating lnrpc.Transaction inside SubscribeTransaction 2022-01-25 17:07:48 -08:00
Martin Habovstiak
a5471576ea docs: added release notes regarding #5539 2022-01-25 17:06:32 -08:00
Martin Habovstiak
6678f25ca0 test: don't enforce reserved value in PSBT midstep
This adds an integration test that makes sure channel can be funded from
empty wallet using PSBT if the funding transaction contains an output
belonging to the wallet, satisfying the reserve.
2022-01-25 17:06:32 -08:00
Martin Habovstiak
1b9a126809 lnwallet: don't enforce new reserved value in PSBT midstep
This change avoids enforcing new reserved value when PSBT funding is not
finished yet as new inputs and outputs may still be added that could
change the outcome of the check.

This originally failed in the scenario when funding a channel from
external wallet *and depositing to on-chain wallet* was done
simultaneously in a single transaction. If such transaction confirms
then reserved UTXO is guaranteed to be available but the check didn't
take it into account.

The enforcement still occurs in the final step of PSBT funding flow, so
it is safe. It also occurs in case of non-PSBT funding.
2022-01-25 17:06:32 -08:00
Matthew Bajorek
ad8fc3ceb7 lncli: Add json flag to trackpayment [skip ci] 2022-01-25 17:03:39 -08:00
Olaoluwa Osuntokun
2bdb8e3b62 Merge branch 'v0.14.2-beta-5971' into 0-14-2-branch-rc1 2022-01-25 17:02:16 -08:00
yyforyongyu
acbc11fd40 docs: add release note for ChanStatusFlags 2022-01-25 17:02:16 -08:00
yyforyongyu
b227d72067 rpcserver: expose ChanStatusFlags in pending close
This commit exposes the ChanStatusFlags inside waitingCloseResp such
that the channel close type is exposed.
2022-01-25 17:02:16 -08:00
Andras Banki-Horvath
9c0d2cf208 docs: update release notes 2022-01-25 17:01:13 -08:00
Andras Banki-Horvath
36d98a9b3d routing: fix memory corruption in MC store
Since bbolt returns references to internally stored data when storing
locally it's best to copy the byte slices returned or alternatively
convert them to string (which also makes a copy) to avoid crashes casued
by memory corruption.
2022-01-25 16:59:22 -08:00
Olaoluwa Osuntokun
24a033900a Merge branch 'v0.14.2-beta-6062' into 0-14-2-branch-rc1 2022-01-25 16:59:00 -08:00
yyforyongyu
9c81108de2 docs: update release note for fee rate fix 2022-01-25 16:59:00 -08:00
yyforyongyu
361b8a9691 chainfee: update test TestWebAPIFeeEstimator 2022-01-25 16:59:00 -08:00
yyforyongyu
a9bb51a788 chainfee: handle conf target not found in cache 2022-01-25 16:59:00 -08:00
Olaoluwa Osuntokun
3fb9cbc032 Merge branch 'v0.14.2-beta-6071' into 0-14-2-branch-rc1 2022-01-25 16:57:57 -08:00
kon
e179d3f0e4 routerrpc: fix wrong error messages
when payment_hash or final_cltv_delta and payment_request was set, the error message showed that the parameters shouldn't be set with dest instead of payment_request

[skip ci]
2022-01-25 16:57:57 -08:00
Olaoluwa Osuntokun
f02f230ba9 Merge branch 'v0.14.2-beta-6049' into 0-14-2-branch-rc1 2022-01-25 16:57:18 -08:00
Andras Banki-Horvath
508a3714aa docs: update release notes 2022-01-25 16:57:18 -08:00
Andras Banki-Horvath
2a4b3fe354 etcd: make max message size configurable 2022-01-25 16:57:18 -08:00
Olaoluwa Osuntokun
4062003c91 Merge branch 'v0.14.2-beta-6035' into 0-14-2-branch-rc1 2022-01-25 16:56:54 -08:00
naveen
f99cf4f7cb multi: Remove GO111MODULE env variable in Makefile
The `GO111MODULE` variable is not required from go 1.16
https://go.dev/blog/go116-module-changes
2022-01-25 16:56:54 -08:00
Oliver Gugger
f12f40dfcb mod+tools+Makefile: use go install to fetch dependencies
Instead of hard coding a commit to use for a binary tool that we use
during the build process, we now only use "go install" to install the
binaries and the golang builtin versioning system to pin the exact
version/commit we want to use in go.mod.
2022-01-25 16:56:54 -08:00
Oliver Gugger
e9e580ee1a GitHub+Makefile: remove travis goals 2022-01-25 16:56:54 -08:00
Oliver Gugger
43507e969c docs+Makefile: remove goveralls
We use a GitHub Action for sending the coverage to coveralls.io and
don't need the goveralls binary anymore.
2022-01-25 16:56:54 -08:00
rockstardev
b767e1c7ae
Reverting changes picked up from feature branches
These changes haven't made it into master on lightning/lnd
2021-12-22 20:58:31 -06:00
rockstardev
e2ddfde44e
Cleaning up README, adding new versions 2021-12-22 19:51:11 -06:00
rockstardev
a08ce6fdb7
Merge branch 'version/0.14.1-beta' 2021-12-22 19:40:35 -06:00
rockstardev
177d04ecaa
Merge branch 'version/0.14.0-beta'
# Conflicts:
#	.github/pull_request_template.md
#	README.md
#	build/version.go
#	chainreg/chainregistry.go
#	cmd/lncli/cmd_payments.go
#	docs/release-notes/release-notes-0.13.3.md
#	docs/release-notes/release-notes-0.14.0.md
#	go.mod
#	go.sum
#	htlcswitch/interfaces.go
#	htlcswitch/switch.go
#	htlcswitch/switch_test.go
#	lntest/itest/lnd_test.go
#	lnwallet/test_utils.go
2021-12-22 19:40:23 -06:00
rockstardev
bfda9ea312
Merge branch 'version/0.13.3-beta'
# Conflicts:
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
2021-12-22 19:38:40 -06:00
rockstardev
94693c31b7
Adding BtcPayServer related files and resources
(cherry picked from commit 14517a97ea)
(cherry picked from commit a185998bcf)
2021-11-25 14:10:40 +09:00
rockstardev
b9f43ac43e
Adding BtcPayServer related files and resources
(cherry picked from commit 14517a97ea)
(cherry picked from commit a185998bcf)
2021-11-20 21:39:49 +09:00
rockstardev
67907c415e
Bumping loop to v0.15.0-beta 2021-10-09 12:34:34 -05:00
rockstardev
820c830ae1
Updating docker images to compile for new version of GoLang 2021-10-09 12:33:26 -05:00
rockstardev
83b7c64b76
Merge branch 'version/0.13.1-beta'
# Conflicts:
#	.github/workflows/main.yml
#	.github/workflows/release.yaml
#	.travis.yml
#	Makefile
#	channeldb/channel.go
#	channeldb/channel_test.go
#	cmd/lncli/cmd_pay.go
#	config.go
#	contractcourt/briefcase_test.go
#	discovery/gossiper.go
#	discovery/gossiper_test.go
#	docker-initunlocklnd.sh
#	docs/release.md
#	invoices/invoice_expiry_watcher_test.go
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
#	lncfg/gossip.go
#	lnrpc/Dockerfile
#	lnrpc/gen_protos.sh
#	lnrpc/gen_protos_docker.sh
#	lnrpc/invoicesrpc/invoices_server.go
#	lnrpc/routerrpc/router.pb.go
#	lnrpc/routerrpc/router.proto
#	lnrpc/routerrpc/router.swagger.json
#	lnrpc/routerrpc/router_backend.go
#	lnrpc/rpc.pb.go
#	lntest/itest/lnd_test.go
#	lntest/itest/log_error_whitelist.txt
#	routing/integrated_routing_context_test.go
#	routing/payment_session.go
#	routing/router.go
#	routing/router_test.go
#	rpcserver.go
#	sample-lnd.conf
#	scripts/verify-install.sh
#	server.go
2021-10-09 12:22:29 -05:00
rockstardev
25c56c4974
Commenting script to preserve information about tricky unlocking mechanism 2021-10-09 11:33:26 -05:00
rockstardev
22937c97f1
Improving unlock script to wait for proper state when it comes to wallet unlocking 2021-10-09 11:33:20 -05:00
rockstardev
9f60321b89
Installing xxd on arm32 and arm64 2021-10-09 11:33:13 -05:00
rockstardev
787ab54072
Updating init http error code condition with lnd-0.13.1-beta 2021-10-09 11:32:48 -05:00
rockstardev
9a8f64c512
Adding loop binary in lnd container 2021-10-09 11:32:41 -05:00
rockstardev
2fa461271b
Adding environment variable to influence LND's rest host
(cherry picked from commit 39d25171ce)
(cherry picked from commit 7b6c31d223)
2021-10-09 11:31:03 -05:00
rockstardev
e32d15659b
Adding BtcPayServer related files and resources
(cherry picked from commit 14517a97ea)
(cherry picked from commit a185998bcf)
2021-10-09 11:30:47 -05:00
Oliver Gugger
4f567577db
build: bump version to v0.13.3-beta
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2021-10-04 16:07:22 +02:00
Olaoluwa Osuntokun
186b6cce2b
build: bump version to v0.13.3-beta.rc2
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2021-10-03 12:22:04 -07:00
Olaoluwa Osuntokun
ab8d342cad multi: fix cherry-pick compilation issues 2021-10-03 12:21:16 -07:00
Oliver Gugger
6e519ca910 scripts: verify version in manifest
To make a downgrade attack harder, we also check that the version string
is contained in the manifest, on the same line as the hash.
2021-10-03 12:18:27 -07:00
Oliver Gugger
4569ed424d scripts: allow packaged release archive to be verified
Instead of only allowing to verify installed/unpacked binaries, we also
allow a single binary or packaged release archive to be verified.
2021-10-03 12:16:40 -07:00
Oliver Gugger
c97040b77e docker: add keys to docker image
Because the PGP keys are no longer downloaded from Keybase but are used
from the repo directly, we also have to copy them to the Docker image so
we can run the script without needing to supply them through a volume.
2021-10-03 12:16:40 -07:00
Oliver Gugger
53899b3fd4 scripts: pin signatures to keys
With this commit we add a new restriction that checks that the
username in the signature file (manifest-<username>-<version>.sig) actually
does have a signing key and that the signature was created with that key.
The signature is only counted towards the minimum of 5 signatures if
that check is successful.
The changes in this commit were inspired by @kixunil in #5048.
2021-10-03 12:16:40 -07:00
Oliver Gugger
50b7748f2c scripts: make sure signature files have unique names
To fix a simple attack where the same file would be uploaded multiple
times under the same name, we make sure we only count unique file names.
2021-10-03 12:16:40 -07:00
positiveblue
6d1fa7d84a scripts: add positiveblue key to verify script 2021-10-03 12:16:40 -07:00
Oliver Gugger
fca4058f2e scripts: add signing keys to repo
Instead of importing the keys from Keybase, we add all the signing keys
to the repository. In addition to having the key file present each key's
ID must also be added to the verification script. This acts as a double
check that the correct key is added and makes a key change more
explicit.
2021-10-03 12:16:40 -07:00
Conner Fromknecht
13bc2eee66 docs: update release verification scripts for v0.12.1-beta 2021-10-03 12:16:40 -07:00
Conner Fromknecht
cda414c84d docs: remove unnecessary docker pull from release verification
Docker will automatically pull the image if it isn't found locally.
2021-10-03 12:16:40 -07:00
Conner Fromknecht
a8bb570a19 scripts/verify-install.sh: pass expected version as argument
This removes a vulnerability brought up by @Kixunil where both the lnd
and lncli binaries are executed to obtain their version before they have
been verified against the release. A malicious binary could have already
compromised the user's system before any of the checks had been
performed.

This commit it split out from the doc changes so that it can easily be
cherry-picked to master/0.13.0.
2021-10-03 12:16:40 -07:00
Oliver Gugger
fb8a841d3e scripts: extract functions
As a preparation to make the script easier to understand, we extract
some of the sub tasks into functions.
2021-10-03 12:16:40 -07:00
Harsha Goli
29a6b101fd scripts: add arshbot key to verify script 2021-10-03 12:16:40 -07:00
Olaoluwa Osuntokun
0342c8b33c
build: bump version to v0.13.3-beta.rc1 2021-10-03 11:52:39 -07:00
eugene
2f68e95013 docs: update release notes for 0.13.3 2021-10-03 11:30:53 -07:00
eugene
0e3d06a562 multi: introduce config-level DustThreshold for defining threshold 2021-10-03 11:30:53 -07:00
eugene
072bde093c htlcswitch: call evaluateDustThreshold in SendHTLC, handlePacketForward
This commit makes SendHTLC (we are the source) evaluate the dust
threshold of the outgoing channel against the default threshold of
500K satoshis. If the threshold is exceeded by adding this HTLC, we
fail backwards. It also makes handlePacketForward (we are forwarding)
evaluate the dust threshold of the incoming channel and the outgoing
channel and fails backwards if either channel's dust sum exceeds the
default threshold.
2021-10-03 11:30:52 -07:00
eugene
16d59544ea htlcswitch: extend ChannelLink iface with dustHandler iface
This allows the Switch to determine the dust exposure of a certain
channel and allows the link to set the feerate of the mailbox given
a fee update.
2021-10-03 11:29:44 -07:00
eugene
4558381ffa htlcswitch: extend Mailbox iface with dust, fee methods
This commit extends the Mailbox interface with the SetDustClosure,
SetFeeRate, and DustPackets methods. This enables the mailbox to
report the dust exposure to the Switch when the Switch decides whether
to forward a dust packet. The dust is counted from the time an Add is
introduced via AddPacket until it is removed via AckPacket. This can
lead to some packets being counted twice before they are signed for,
but this is a trade-off between accuracy and simplicity.
2021-10-03 11:28:39 -07:00
eugene
1fc413e2f6 lnwallet: introduce GetDustSum method to calculate worst-case dust sum
It over-estimates the local or remote commitment's dust sum by
counting all updates in both updateLogs that are dust using the
trimmed-to-dust mechanism if applicable. The over-estimation is done
because ensuring an accurate counting is a trade-off between code
simplicity and accuracy.
2021-10-03 11:28:38 -07:00
eugene
c6fe623061 docs: update release notes for 0.13.3 2021-10-03 11:25:05 -07:00
eugene
655778d80d funding+lnwallet: validate ChannelReserve is above DustLimit
This is necessary and is implied by BOLT#02. Both ChannelReserve
parameters should be above both DustLimit parameters. Otherwise,
it is possible for one side to have nothing at stake.
2021-10-03 11:25:05 -07:00
eugene
ddbd0b672a multi: replace DefaultDustLimit with script-specific DustLimitForSize
This commit updates call-sites to use the proper dust limits for
various script types. This also updates the default dust limit used
in the funding flow to be 354 satoshis instead of 573 satoshis.
2021-10-03 11:25:02 -07:00
Olaoluwa Osuntokun
86d3dec7b9
build: bump version to v0.13.2-beta
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2021-08-18 17:42:48 -07:00
Olaoluwa Osuntokun
ef70a92e49 Merge branch 'v0.13.2-beta-5554' into 0-13-2-branch 2021-08-18 17:37:07 -07:00
Olaoluwa Osuntokun
fed9c1cd8d docs/release-notes: add item for easy AMP CLI re-use 2021-08-18 17:37:07 -07:00
Olaoluwa Osuntokun
eac3f8ea1f docs/release-notes: add item for sendpayment pay_addr bug fix 2021-08-18 17:37:07 -07:00
Olaoluwa Osuntokun
6057200c72 cmd/lncli: add new option for easy AMP invoice re-use
In this commit, we add a new option (`--amp-reuse`) that allows for easy
AMP invoice re-use when using either the `sendpayment` command.
2021-08-18 17:37:07 -07:00
Olaoluwa Osuntokun
683f6f3b2e cmd/lncli: always parse the pay_addr field for sendpayment
In this commit, we fix a bug that would cause attempts to re-use an AMP
invoice to fail. Without this commit, we would only attempt to parse the
payment addr if no invoice was specified, so a user manually specifying the
pubkey of the detonation. The fix is straight forward: always parse the
`pay_addr` field as the user may be attempting to re-use an AMP invoice w/o
open coding each of the sections.
2021-08-18 17:37:07 -07:00
rockstardev
dec49aa15b
Commenting script to preserve information about tricky unlocking mechanism 2021-08-12 22:28:28 -05:00
rockstardev
824a998274
Improving unlock script to wait for proper state when it comes to wallet unlocking 2021-08-12 21:38:32 -05:00
rockstardev
570bc0824f
Installing xxd on arm32 and arm64 2021-08-12 20:54:51 -05:00
rockstardev
6baa0ee593
Updating init http error code condition with lnd-0.13.1-beta 2021-08-01 01:27:12 +02:00
rockstardev
025f953f6f
Adding loop binary in lnd container 2021-08-01 01:26:42 +02:00
rockstardev
f0714bf36e
Adding environment variable to influence LND's rest host
(cherry picked from commit 39d25171ce)
(cherry picked from commit 7b6c31d223)
2021-08-01 00:36:40 +02:00
rockstardev
ae1b824e4b
Adding BtcPayServer related files and resources
(cherry picked from commit 14517a97ea)
(cherry picked from commit a185998bcf)
2021-08-01 00:36:27 +02:00
rockstardev
c49af2288c
Merge branch 'version/0.12.1-beta'
# Conflicts:
#	.github/workflows/docker.yml
#	.github/workflows/main.yml
#	.github/workflows/release.yaml
#	docker-entrypoint.sh
#	docker-initunlocklnd.sh
#	linuxamd64.Dockerfile
#	linuxarm32v7.Dockerfile
#	linuxarm64v8.Dockerfile
#	lncfg/address.go
2021-07-31 23:29:04 +02:00
Olaoluwa Osuntokun
596fd90ef3
build: bump version to v0.13.1-beta
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2021-07-19 11:02:54 -07:00
Olaoluwa Osuntokun
db577b23b4 Merge branch 'v0.13.1-beta-5472' into 0-13-1-branch 2021-07-19 11:01:07 -07:00
Joost Jager
2b49c4d344 build: bump btcwallet 2021-07-19 11:01:07 -07:00
Olaoluwa Osuntokun
17b0461583
build: bump version to v0.13.1-beta.rc2
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
2021-07-07 16:12:41 -07:00
rockstardev
7d676848cb
Extracting running Loop to separate script 2021-05-23 12:45:54 -05:00
rockstardev
a1c04622d3
Letting old condition continue in order for Loop to be started 2021-05-19 08:44:39 -05:00
rockstardev
8187303ada
Updating loop to 0.12.2-beta 2021-05-12 23:04:12 -05:00
rockstardev
78d5af59ee
Loop listener has problems if immidatelly starter, increasing wait time 2021-04-22 23:26:56 -05:00
rockstardev
3b3c52f1e7 Lnd doesn't listen on localhost, so we need to pass in host 2021-03-21 19:17:47 -05:00
rockstardev
b4ac312d2e Updating path to MACAROON_FILE 2021-03-21 13:23:08 -05:00
rockstardev
7e82d9a451 Adding loop to arm32v7 and arm64v8 images 2021-03-21 11:54:22 -05:00
rockstardev
e0089475f7 Consolidating string in logger to match sh name 2021-03-21 11:40:52 -05:00
rockstardev
ae99043041 Adding loop binary in lnd container 2021-03-21 11:36:45 -05:00
rockstardev
c7f4e0c306 Adding environment variable to influence LND's rest host
(cherry picked from commit 39d25171ce)
(cherry picked from commit 7b6c31d223)
2021-03-14 10:31:08 -05:00
rockstardev
5b63dc1f67 Adding BtcPayServer related files and resources
(cherry picked from commit 14517a97ea)
(cherry picked from commit a185998bcf)
2021-03-14 10:30:59 -05:00
Conner Fromknecht
d233f61383
Merge pull request #5052 from cfromknecht/v0.12.1-beta.rc7-branch-commits
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
v0.12.1-beta.rc7
2021-02-22 16:55:05 -08:00
Conner Fromknecht
51aaf2bb13
build/version: bump to v0.12.1-beta.rc7 2021-02-22 12:23:16 -08:00
Conner Fromknecht
923134e52c
docs: update release verification scripts for v0.12.1-beta 2021-02-22 12:22:03 -08:00
Conner Fromknecht
a38c82d8c7
docs: remove unnecessary docker pull from release verification
Docker will automatically pull the image if it isn't found locally.
2021-02-22 12:19:43 -08:00
Conner Fromknecht
3ae60cd63f
scripts/verify-install.sh: pass expected version as argument
This removes a vulnerability brought up by @Kixunil where both the lnd
and lncli binaries are executed to obtain their version before they have
been verified against the release. A malicious binary could have already
compromised the user's system before any of the checks had been
performed.

This commit it split out from the doc changes so that it can easily be
cherry-picked to master/0.13.0.
2021-02-22 12:18:43 -08:00
Conner Fromknecht
953e3cc50d
Merge pull request #5045 from cfromknecht/v0.12.1-beta.rc6-branch-commits
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
v0.12.1-beta.rc6
2021-02-18 17:03:01 -08:00
Conner Fromknecht
7bfec3f8c2
build/version: bump to v0.12.1-beta.rc6 2021-02-18 11:47:56 -08:00
Conner Fromknecht
5fd74659bc
routing: avoid modifying AssumeChannelValid in unit tests
This produces a race condition when reading AssumeChannelValid from a
different goroutine. Instead we isolate the test cases and initial
AssumeChannelValid properly.
2021-02-18 08:52:35 -08:00
Conner Fromknecht
f1786f9454
routing: dial back max concurrent block fetches
This commit reduces the number of concurrent validation operations the
router will perform when fully validating the channel graph. Reports
from several users indicate that GetInfo would hang for several minutes,
which is believed to be caused by attempting to validate massive amounts
of channels in parallel. This commit returns the limit back to its
original state before adding the batched gossip improvements.

We keep the 1000 concurrent validation request limit for
AssumeChannelValid, since we don't fetch blocks in that case. This
allows us to still keep the performance benefits on mobile/low-resource
devices.
2021-02-18 08:52:34 -08:00
Conner Fromknecht
5cddeb7449
Merge pull request #5039 from cfromknecht/v0.12.1-beta.rc5-branch-commits
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
v0.12.1-beta.rc5
2021-02-17 12:58:23 -08:00
Conner Fromknecht
1f012c461e
build/version: bump to v0.12.1-beta.rc5 2021-02-17 12:15:59 -08:00
Conner Fromknecht
64660a2574
Revert "lnrpc/routerrpc: use new default value of 16 for maxparts"
This reverts commit 25b90832e3d74e62176a9c71b0b724d6fb49a39d, as
well as reverting some changes in other commits in the PR that weren't
fully attomic with the primary commit.
2021-02-17 12:15:58 -08:00
Conner Fromknecht
5643fe8dbe
github: check-each-commit from v0.12.0-beta 2021-02-17 12:15:58 -08:00
Oliver Gugger
1ed3c340e8
scripts: detect whether sha256sum or shasum is available
The shasum command isn't available in Alpine linux while the sha256sum
command isn't available on MacOS. We add a simple switch that tries to
detect which one is available.
2021-02-17 12:01:21 -08:00
Oliver Gugger
877fd96e8c
make: use make for docker-release
To fix an issue where the golang version would be picked up from the
host system if the docker-release command was used, we switch over to
using make inside of the container as well instead of feeding the
parameters into the release script manually.
We only pass in the flags that we might actually want to overwrite.
2021-02-17 12:01:18 -08:00
Conner Fromknecht
d6c697d509
Merge pull request #5027 from cfromknecht/v0.12.1-beta.rc4-branch-commits
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
v0.12.1-beta.rc4
2021-02-16 16:34:09 -08:00
Conner Fromknecht
d51f61af25
build/version: bump to v0.12.1-beta.rc4 2021-02-16 13:58:33 -08:00
Olaoluwa Osuntokun
2f4de5dc5f
cmd/lncli: add max shard size parsing for payment commands 2021-02-16 10:12:27 -08:00
Olaoluwa Osuntokun
be54ac78a6
routing: if MaxShardAmt is set, then use that as a ceiling for our splits
In this commit, we thread through the necessary state to allow users to
set a max shard amount. If this value is set, then this'll effectively
serve as a ceiling for all our split attempts. If we need to split,
we'll first try to use `paymentAmt/2`, if that's bigger than
`MaxShardAmt, then we'll use the latter instead.

Ideally in the future we have a dynamic way to automatically set both
the `MaxShardAmt` as well as `MaxParts` for users. Until then exposing
these two new fields will allow us to experiment with setting them
automatically using the RPC interface, and also give users a bit more
control over how we attempt to route payments, akin to coin control for
on-chain payments.

Fixes #4730
2021-02-16 10:12:26 -08:00
Olaoluwa Osuntokun
3a4b44a480
lnrpc/routerrpc+routing: add new MaxShardAmt field to LightningPayment 2021-02-16 10:12:26 -08:00
Olaoluwa Osuntokun
59764d7b04
lnrpc/routerrpc: add new max_shard_size_msat field to SendPaymentRequest 2021-02-16 10:12:25 -08:00
Olaoluwa Osuntokun
d29528bb69
lnrpc/routerrpc: use new default value of 16 for maxparts
In this commit, we raise the default value for the `MaxParts` field from
1 to 16. This change was motivated by the fact that many users either
forget, or don't even know this field is there in the first place. A
value of 16 was chosen rather arbitraliy (other than power of 2). In
the future, we should tune this value based on the expected number of
payment attempts for a given payment amount.
2021-02-16 10:12:01 -08:00
Conner Fromknecht
87a3aad001
htlcswitch: init mockFeeEstimator in other LinkChannelConfigs
If the tests don't execute quick enough, the link will try to sample the
network fee and cause a panic. This happens semi-regularly on travis.
2021-02-15 13:17:34 -08:00
Conner Fromknecht
6236c5b620
lntest: add Block height out of range to whitelist 2021-02-15 13:17:04 -08:00
Conner Fromknecht
5fe7d19e6a
lntest: add unable to extract ChannelUpdate to whitelist 2021-02-15 13:17:04 -08:00
Conner Fromknecht
48caa962cb
scripts/verify-install.sh: combine final SUCCESS logs 2021-02-15 13:16:51 -08:00
Conner Fromknecht
87dfb04f1e
scripts/verify-install: bump min required signatures to 5 2021-02-15 13:16:51 -08:00
Oliver Gugger
7027e940ef
scripts: add more verbose error messages to verification
We want to be more precise in what exactly went wrong and what the cause
could be.
2021-02-15 13:16:51 -08:00
Oliver Gugger
34c2d77ec5
docs+scripts: switch to detached signatures
Due to a misunderstanding of how the gpg command line options work, we
didn't actually create detached signatures because the --clear-sign
flag would overwrite that. We update our verification script to now only
download the detached signatures and verify them against the main
manifest file.
We also update the signing instructions.
2021-02-15 13:16:51 -08:00
Oliver Gugger
cdea598a30
scripts: verify hash length
To make sure we've actually calculated the hash correctly, we make sure
it's 64 characters long.
2021-02-15 13:16:51 -08:00
Oliver Gugger
00dc248baa
scripts: use shasum instead of sha256sum
Because the sha256sum binary isn't available on MacOS we instead use the
shasum -a 256 command that was used before.
2021-02-15 13:16:51 -08:00
Oliver Gugger
547181d36f
config: clean and expand backup file path
Because the CleanAndExpandPath function wasn't applied to the backup
file path, any path that contained a tilde for the home directory didn't
work.
2021-02-15 13:16:10 -08:00
Oliver Gugger
7627c619a1
scripts: allow verification of custom binary
Instead of only allowing the installed versions of lnd and lncli to be
verified, we now also support specifying explicit paths to binaries that
we want to verify.
2021-02-15 13:15:56 -08:00
Conner Fromknecht
de8dbe2c74
Merge pull request #5014 from cfromknecht/v0.12.1-beta.rc3-branch-commits
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
v0.12.1-beta.rc3
2021-02-11 18:01:09 -08:00
Conner Fromknecht
4ca83c3bc1
build/version: bump to v0.12.1-beta.rc3 2021-02-11 16:35:18 -08:00
Conner Fromknecht
cb6e677400
github/workflows: pin exact docker release 2021-02-11 16:32:50 -08:00
Conner Fromknecht
ea2b0150c6
Merge pull request #5009 from cfromknecht/v0.12.1-beta.rc2-branch-commits
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
v0.12.1-beta.rc2
2021-02-11 12:57:02 -08:00
Conner Fromknecht
1e2190e86d
build/version: bump to v0.12.1-beta.rc2 2021-02-11 00:46:32 -08:00
Olaoluwa Osuntokun
b57ea5c1cd
lncfg: detect tor resolution error case and fallback to system resolver
In this commit, we fix a bug that would cause resolution of items in
/etc/hosts (or the like) to fail as Tor wouldn't recognize them as
proper host names. With this commit, we'll catch this error and fall
back to the system's resolver.
2021-02-11 00:36:58 -08:00
Olaoluwa Osuntokun
6bca1fbc30
lncfg: use net.ParseIP to detect IPv6 addresses 2021-02-11 00:36:58 -08:00
eugene
71ab07763d
lncfg: add isIPv6Host helper to force v6 addrs through system resolver
With this commit, if --tor.active is specified, then IPv6 addresses
will no longer go through the connmgr.TorLookupIP function from btcd.
This function does not have proper IPv6 support and would fail with
the error "tor general error". Instead, use the system resolver.
2021-02-11 00:36:57 -08:00
Wilmer Paulino
b38d8d84d9
discovery: use token bucket based rate limiting to throttle gossip
The recently added gossip throttling was shown to be too aggressive,
especially with our auto channel enable/disable signaling. We switch to
a token bucket based system instead as it's based on time, rather than a
block height which isn't constantly updated at a given rate.
2021-02-11 00:36:19 -08:00
Wilmer Paulino
4d0a8ed435
Revert "lncfg: add new legacy protocol option to turn off gossip throttling"
This reverts commit b1fbbcf562.
2021-02-11 00:36:18 -08:00
Wilmer Paulino
083a62a3b2
Revert "discovery: add new option to toggle gossip rate limiting"
This reverts commit 13a2598ded.
2021-02-11 00:36:18 -08:00
Wilmer Paulino
423082a4a4
Revert "lntest: always turn off gossip throttling for nodes created in itests"
This reverts commit 447c9f2c0b.
2021-02-11 00:36:18 -08:00
Johan T. Halseth
673cbc6d91
discovery/gossiper: add local updates to graph immediately
Since the batch interval can potentially be long, adding local updates
to the graph could be slow. This would slow down operations like adding
our own channel update and announcements during the funding process, and
updating edge policies for local channels.

Now we instead check whether the update is remote or not, and only for
remote updates use the SchedulerOption to lazily add them to the graph.
2021-02-11 00:35:52 -08:00
Johan T. Halseth
e35c97c214
routing: let graph methods take scheduler option 2021-02-11 00:35:52 -08:00
Johan T. Halseth
6dde42eee6
channeldb: add SchedulerOp arg to graph update methods 2021-02-11 00:35:52 -08:00
Johan T. Halseth
3a1e34b100
batch: add option for executing requests immediately
We make the default non-lazy, and will make the incoming gossip requests
lazy.
2021-02-11 00:35:52 -08:00
Conner Fromknecht
7b98483ebe
discovery: don't historical sync when NumActiveSyncers == 0
Currently when numgraphsyncpeers=0, lnd will still attempt to perform
an initial historical sync. We change this behavior here to forgoe
historical sync entirely when numgraphsyncpeers is zero, since the
routing table isn't being updated anyway while the node is active.

This permits a no-graph lnd mode where no syncing occurs at all.
2021-02-11 00:35:32 -08:00
carla
d75756b1d1
itest: add coverage for hold invoices with hop hints
This PR updates the hold invoice itest to create a private
channel, and sets the private option on the invoices created
to add coverage for the addition of hop hints.
2021-02-11 00:35:19 -08:00
Wilmer Paulino
1378b83f7a
discovery: use source of ann upon confirmed channel ann batch
We do this instead of using the source of the AnnounceSignatures
message, as we filter out the source when broadcasting any
announcements, leading to the remote node not receiving our channel
update. Note that this is done more for the sake of correctness and to
address a flake within the integration tests, as channel updates are
sent directly and reliably to channel counterparts.
2021-02-11 00:35:02 -08:00
Olaoluwa Osuntokun
1c5ff35260
Revert "Merge pull request #4895 from wpaulino/disallow-premature-chan-updates"
This reverts commit 6e6384114c, reversing
changes made to 98ea433271.
2021-02-11 00:35:02 -08:00
rockstardev
3de4af2348
fix: correct no-rest-tls parameter in error message 2021-02-11 00:33:48 -08:00
Oliver Gugger
b67c840b4c
make: clean mobile stubs before building release
To fix an issue where the vendor.tar.gz in a release build had a
different hash if the mobile RPC stubs were in the mobile/ folder, we
clean those out first.

The culprit was the `google.golang.org/grpc/test/bufconn` package which
is currently only used in the mobile RPC stubs and nowhere else.
Therefore the vendor/module.txt was different when vendoring with the
generated mobile RPC stubs being around.
2021-02-11 00:33:48 -08:00
Johan T. Halseth
d61ec5c2f7
docs: correct sign command 2021-02-11 00:26:53 -08:00
rockstardev
a3b83494ee Update README to add link to our repository with C# Lightning clients 2021-02-07 13:37:55 -06:00
rockstardev
ed9e64e810 Update README to fix link to LND 0.12.0 image on Docker Hub 2021-02-07 13:36:12 -06:00
rockstardev
d73673492f Disabling TLS check so that we can listen on all interfaces for btcpayserver-docker deployments 2021-02-06 19:27:21 -06:00
rockstardev
bb5edcd3c6 Removing .github folder from origin repo 2021-02-06 17:21:13 -06:00
rockstardev
de4509adc1 Update README for 0.12.0-beta 2021-02-06 17:15:02 -06:00
Conner Fromknecht
79c8ecc9d7
Merge pull request #4980 from cfromknecht/v0.12.1-beta.rc1-branch-commits
Some checks failed
Docker image build / main (push) Has been cancelled
Release build / Release build (push) Has been cancelled
v0.12.1-beta.rc1
2021-02-03 22:06:50 -08:00
Conner Fromknecht
964f2e7781
bulid: bump version to v0.12.1-beta.rc1 2021-02-03 20:33:59 -08:00
eugene
ad052ad7f0
htlcswitch: reestablish unit tests 2021-02-03 20:32:45 -08:00
eugene
1d3985d3af
channeldb+lnwallet: lastWasRevokeKey to store last sent rev/sig 2021-02-03 20:32:15 -08:00
Olaoluwa Osuntokun
e06f817b47
routing: add new TestPaymentAddrOnlyNoSplit test case
This test case ensures that we won't try to split payment if the dest
has the payment addr bit, but NOT the mpp optional/require bit.
2021-02-03 20:32:03 -08:00
Olaoluwa Osuntokun
732eabc8df
routing: allow custom dest feature bits in integratedRoutingContext.testPayment
This is a preparatory commit for a new test to ensure that if a node
only has the TLV and payment addr feature bits, we don't try to split a
payment.
2021-02-03 20:31:49 -08:00
Conner Fromknecht
bb1f738d1d
gen_protos_docker: make image build non-quiet
This allows users to see progress whenever the docker image is
[re]built, and (esp on non-linux hosts) track the size of the build
context being uploaded. Currently no output is displayed, so it's hard
to attribute the source of latency, e.g. network latency, building
layers, a large work directory, etc.
2021-02-03 20:31:37 -08:00
Olaoluwa Osuntokun
2cc8b16339
build: update CI builds to use go 1.15.7 2021-02-03 20:31:26 -08:00
Juan Pablo Civile
d6d6f5b1a3
routing: limit max parts if the invoice doesn't declare MPP support 2021-02-03 20:31:12 -08:00
Juan Pablo Civile
905e1cb009
routerrpc: limit max parts if the invoice doesn't declare MPP support 2021-02-03 20:30:59 -08:00
Conner Fromknecht
aeaf5c0ed2
lntest: fix linter errors 2021-02-03 20:30:49 -08:00
Conner Fromknecht
775b6e5f68
discovery/sync_manager: remove unneeded markGraphSyncing
AFAICT it's not possible to flip back from bein synced_to_chain, so we
remove the underlying call that could reflect this. The method is moved
into the test file since it's still used to test correctness of other
portions of the flow.
2021-02-03 20:30:36 -08:00
Conner Fromknecht
bbe090a538
lntest: call markGraphSynced from gossipSyncer
Rather than performing this call in the SyncManager, we give each
gossipSyncer the ability to mark the first sync completed. This permits
pinned syncers to contribute towards the rpc-level synced_to_graph
value, allowing the value to be true after the first pinned syncer or
regular syncer complets. Unlinke regular syncers, pinned syncers can
proceed in parallel possibly decreasing the waiting time if consumers
rely on this field before proceeding to load their application.
2021-02-03 20:30:25 -08:00
Conner Fromknecht
e6af248ed8
lntest/graph_top: test pinned syncers 2021-02-03 20:30:17 -08:00
Conner Fromknecht
f04074835d
lntest/graph_top: remove dependence on net.Alice/Bob 2021-02-03 20:30:09 -08:00
Conner Fromknecht
275055d4a0
config: expose gossip.pinned-syncers for conf
The pinned syncer set is exposed as a comma-separated list of pubkeys.
2021-02-03 20:29:56 -08:00
Conner Fromknecht
c8ce80a3f4
lnrpc: expose PINNED_SYNC for listpeers 2021-02-03 20:29:40 -08:00
Conner Fromknecht
505133310d
discovery: perform initial historical sync for pinned peers 2021-02-03 20:29:24 -08:00
Conner Fromknecht
4db594425b
discovery: add support for PinnedSyncers
A pinned syncer is an ActiveSyncer that is configured to always remain
active for the lifetime of the connection. Pinned syncers do not count
towards the total NumActiveSyncer count, which are rotated periodically.

This features allows nodes to more tightly synchronize their routing
tables by ensuring they are always receiving gossip from distinguished
subset of peers.
2021-02-03 20:29:11 -08:00
Conner Fromknecht
631e6b99f9
discovery/sync_manager: Pause/Resume HistoricalSyncTicker
This gives each initial historical syncer an equal amount of time before
being rotated, even if some fail.
2021-02-03 20:29:00 -08:00
Conner Fromknecht
816c3dd2a8
discovery/sync_manager: make setHistoricalSyncer closure 2021-02-03 20:28:46 -08:00
Conner Fromknecht
8259dac5fb
discovery/sync_manager: break out IsGraphSynced check 2021-02-03 20:28:35 -08:00
Conner Fromknecht
d67d02bde5
discovery: handle err for linter 2021-02-03 20:28:28 -08:00
Andras Banki-Horvath
14653865b2
invoices+rpc: add missing channel graph to the AddInvoiceConfig
The Graph which is referenced later in the AddInvoice call graph is
unset when adding a hodl invoice. This resulted in a crash.
2021-02-03 20:28:19 -08:00
eugene
ab6ad25a92
lntest/channels: introduce subpackage to deduplicate static structs 2021-02-03 20:28:01 -08:00
Umar Bolatov
f92ec41e74
Fix typo in restorechanbackup command description 2021-02-03 20:27:54 -08:00
Oliver Gugger
a4168b2e07
ci: check mobile compilation in same step as RPC
Because we now build a docker image for the RPC compilation, we can save
some execution minutes if we run the mobile RPC and code compilation check in the
same step of the CI workflow.
2021-02-03 20:27:48 -08:00
Oliver Gugger
f15f0f8126
make+lnrpc: compile mobile RPC with docker too
Now that we have a base docker image that has all our RPC compilation
dependencies installed, we can also run the mobile RPC compilation
there. This removes the need to install falafel and goimports on the
local machine.
2021-02-03 20:27:42 -08:00
Oliver Gugger
3ad5a90800
mobile: remove grpc-gateway import
Because we compile the REST code from the rest-annotations.yaml and no
longer import the annotations in the proto files, we don't need to
specify the custom import path anymore.
2021-02-03 20:27:35 -08:00
Oliver Gugger
0fb4e7c60c
multi: remove proto install script 2021-02-03 20:27:28 -08:00
Oliver Gugger
9048a92016
make+lnrpc: use docker to compile protos
This commit aims to make it easier for developers to compile our
protobuf definitions. They now only need to have docker installed
instead of a whole set of binaries and libraries all pinned to very
specific versions.
2021-02-03 20:27:21 -08:00
Johan T. Halseth
b23dce1bc8
monitoring: run go fmt 2021-02-03 20:27:15 -08:00
Johan T. Halseth
1108c63218
make: run goimports during make fmt 2021-02-03 20:27:09 -08:00
Johan T. Halseth
cfb2343121
make: exclude autogenerated files from go fmt 2021-02-03 20:27:03 -08:00
Joost Jager
dbddc0e841
lnrpc: add htlc attempt id 2021-02-03 20:26:45 -08:00
Oliver Gugger
22f35f40be
scripts: don't fail on missing public key
When verifying the release signatures, we don't want to fail if a
signer's signature is not available in the gpg key ring. Instead we just
don't want to count the signature for now and still succeed if there's
at least one other good sig with a known key.
2021-02-03 20:26:38 -08:00
Oliver Gugger
6c1abd4de9
GitHub: use vendored actions for steps with sensitive info
To avoid leaking any sensitive information like Docker Hub credentials
because of compromised actions repositories, we use our own, vendored
actions for all steps that potentially touch sensitive information.
2021-02-03 20:26:33 -08:00
Jake Sylvestre
be692522d7
docs: add mac clang-format instructions 2021-02-03 20:26:27 -08:00
Vlad Stan
6c661b65b6
docker: add an extra listener for localhost
Make sure the lncli command can be used inside of the container without
needing to specify the --rpcserver flag all the time. Issue: #4937
2021-02-03 20:26:20 -08:00
Johan T. Halseth
49ac6a15be
scripts: add halseth key to verify script 2021-02-03 20:26:13 -08:00
Johan T. Halseth
236c839ee7
netann: ignore unknown channel updat on startup
Since the funding manager might be in process of adding the edge to the
graph, we ignore the error.
2021-02-03 20:05:24 -08:00
rockstardev
dfc8b00332 Merge branch 'version/0.12.0-beta' 2021-01-31 23:58:00 -06:00
rockstardev
f40c6ec9dd Update readme for 0.12.0-beta.rc5 2021-01-31 16:38:56 -06:00
rockstardev
29b40b7c2e Merge branch 'version/0.12.0-beta.rc5'
# Conflicts:
#	README.md
#	config.go
#	docker-entrypoint.sh
#	docker-initunlocklnd.sh
#	go.mod
#	rpcserver.go
2021-01-31 16:36:59 -06:00
rockstardev
38376fce72 Adding environment variable to influence LND's rest host
(cherry picked from commit 39d25171ce)
(cherry picked from commit 7b6c31d223)
2021-01-31 16:32:19 -06:00
rockstardev
6ab9e9a778 Adding BtcPayServer related files and resources
(cherry picked from commit 14517a97ea)
(cherry picked from commit a185998bcf)
2021-01-31 16:32:14 -06:00
rockstardev
7b6c31d223 Adding environment variable to influence LND's rest host
(cherry picked from commit 39d25171ce)
2021-01-10 13:16:16 -06:00
rockstardev
a185998bcf Adding BtcPayServer related files and resources
(cherry picked from commit 14517a97ea)
2021-01-10 13:16:06 -06:00
rockstardev
0795375787 Updating readme for 0.11.0 2020-09-28 16:13:16 -05:00
rockstardev
72f916e5d7 Merge branch 'version/0.11.0-beta'
# Conflicts:
#	Makefile
#	channeldb/invoice_test.go
#	channeldb/meta_test.go
#	channeldb/payments.go
#	config.go
#	docker-entrypoint.sh
#	go.mod
#	go.sum
#	invoices/invoiceregistry_test.go
#	lnd.go
#	lnrpc/chainrpc/chainnotifier_server.go
#	lnrpc/routerrpc/router.pb.go
#	lnrpc/wtclientrpc/wtclient.go
#	lntest/itest/lnd_multi-hop-error-propagation.go
#	lntest/itest/lnd_multi-hop-payments.go
#	lntest/itest/lnd_test.go
#	lnwallet/btcwallet/btcwallet.go
#	log.go
#	rpcserver.go
#	watchtower/wtclient/client.go
2020-09-28 16:12:05 -05:00
Nicolas Dorier
59b57ebdc0
Update docker-entrypoint.sh 2020-09-14 12:56:54 +09:00
rockstardev
4a4374005b Adding BtcPayServer related files and resources 2020-08-30 01:54:38 -05:00
rockstardev
160aaf40d0 Adding net import that got removed 2020-08-30 01:20:06 -05:00
nicolas.dorier
df5e4eed8d Allow unsafe authentication on regtest 2020-08-30 01:20:05 -05:00
nicolas.dorier
67fabc30bb Do not assume setting options partially are unintentional 2020-08-30 01:20:04 -05:00
nicolas.dorier
477983cf64 Add --notls to disable TLS for REST endpoint 2020-08-30 01:19:46 -05:00
rockstardev
903a5ae4c5 Updating Readme to clarify purpose of repository 2020-06-09 00:01:20 -05:00
rockstardev
6574ea15ef Merge branch 'version/0.10.1-beta' 2020-06-08 23:48:34 -05:00
rockstardev
4a7514fba7 Merge branch 'version/0.9.2-beta' 2020-06-08 23:47:19 -05:00
rockstardev
9c0e948662 Merge branch 'version/0.8.2-beta' 2020-06-08 23:46:50 -05:00
rockstardev
ee7b9cefc1 Merge branch 'version/0.8.1-beta' 2020-06-08 23:46:35 -05:00
rockstardev
30efca1a0e Adding default LND tags to our docker container release 2020-06-08 23:16:33 -05:00
rockstardev
43f266655a Updating docker builder images 2020-06-08 23:16:19 -05:00
rockstardev
0a7bedc21e Adding net import that got removed 2020-06-08 23:16:14 -05:00
rockstardev
adc4b8e425 Fix typos in docker-entrypoint.sh
Thanks: https://github.com/btcpayserver/lnd/pull/2
2020-06-08 23:16:07 -05:00
rockstardev
da572ca2af Setting execute permission on .sh files 2020-06-08 23:16:01 -05:00
rockstardev
109da44f48 Adjusting Makefile for fresh version string 2020-06-08 23:15:53 -05:00
rockstardev
8ebc7f4c06 Adding BtcPayServer related files and resources 2020-06-08 23:15:15 -05:00
nicolas.dorier
0cf1a3f6b6 Allow unsafe authentication on regtest 2020-06-08 23:15:10 -05:00
nicolas.dorier
dcd6e32a05 Do not assume setting options partially are unintentional 2020-06-08 23:13:44 -05:00
nicolas.dorier
98ec34c523 Add --notls to disable TLS for REST endpoint 2020-06-08 23:13:37 -05:00
Olaoluwa Osuntokun
52bb3f3370
build: bump version to 0.10.1-beta 2020-06-03 11:18:49 -07:00
Olaoluwa Osuntokun
4f2221d56c
build: bump version to v0.10.1-beta.rc3 2020-05-28 15:56:19 -07:00
Olaoluwa Osuntokun
df2c832aa8 Merge branch 'v0.10.1-beta-4327' into v0.10.1-beta-rc3-branch 2020-05-28 15:50:46 -07:00
Joost Jager
bca3bb4d33 routing: don't treat bad features as an unexpected error
Previous behavior led to the payment loop being abandoned immediately,
resulting in a payment stuck in state in_flight.
2020-05-28 15:50:46 -07:00
Olaoluwa Osuntokun
018b55881e Merge branch 'v0.10.1-beta-4332' into v0.10.1-beta-rc3-branch 2020-05-28 15:50:26 -07:00
Conner Fromknecht
564217213c lnd: use Infof to format errors on channeldb open 2020-05-28 15:50:26 -07:00
Conner Fromknecht
745bf0a6c9 channeldb/db: lower-case ErrDryRunMigrationOk message 2020-05-28 15:50:26 -07:00
Olaoluwa Osuntokun
cb36cd9357 Merge branch 'v0.10.1-beta-4335' into v0.10.1-beta-rc3-branch 2020-05-28 15:50:01 -07:00
Joost Jager
6cd4cc47c1 rpcserver+routerrpc: remove payment limit 2020-05-28 15:48:09 -07:00
Olaoluwa Osuntokun
ac7bb1dec2 Merge branch 'v0.10.1-beta-4298' into v0.10.1-beta-rc3-branch 2020-05-27 16:04:16 -07:00
Conner Fromknecht
5cb7ca6bf4 invoices/invoiceregistry: properly synchronize backlog
This commit moves the db calls for retrieving add and settle backlogs
outide of the main event loop. All other db operations are performed
outside of the event loop and synchronized via the invoice registry's
mutex, which also synchronizes the order in which events submitted to be
processed.

This resolves various concurrency issues where notifications can be
missed of inconsistent reads against the databse. This is especially
important in this case because we are actually making two separate
database calls.
2020-05-27 16:04:16 -07:00
Conner Fromknecht
544e606e2c invoices: return error from SubscribeNotifications on shutdown 2020-05-27 16:04:16 -07:00
Conner Fromknecht
2edda573a5 channeldb/invoices: ignore error when no settles exist
This fixes a bug that would cause no backlog to be delivered at all.
2020-05-27 16:04:16 -07:00
Olaoluwa Osuntokun
ae6e84ddfd
build: bump version to v0.10.1-beta.rc2 2020-05-21 17:26:15 -07:00
Olaoluwa Osuntokun
d764cc8fbf Merge branch 'v0.10.1-beta-4302' into v0.10.1-beta-rc2-branch 2020-05-21 17:24:08 -07:00
Wilmer Paulino
c45b2387c2 btcwallet: add transaction outputs bounds check to FetchInputInfo
This prevents a panic when providing an incompatible output index for
the transaction.
2020-05-21 17:23:23 -07:00
Olaoluwa Osuntokun
e883304279
build: bump version to v0.10.1-beta.rc1 2020-05-18 19:28:34 -07:00
Olaoluwa Osuntokun
2c789d92d3 Merge branch 'v0.10.1-beta-4291' into v0.10.1-beta-rc1-branch 2020-05-18 19:26:35 -07:00
Wilmer Paulino
adbbde6f31 build: update to latest btcd and btcwallet versions
This update introduces backwards compatibility for btcd nodes running
versions prior to v0.20.1-beta.
2020-05-18 19:26:08 -07:00
Olaoluwa Osuntokun
580d478cd3 Merge branch 'v0.10.1-beta-4226' into v0.10.1-beta-rc1-branch 2020-05-18 19:25:27 -07:00
Roei Erez
e52982fd0b Ensure chain notifier is started before accessed.
The use case comes from the RPC layer that is ready before the
chain notifier which is used in the sub server.
2020-05-18 19:25:27 -07:00
Roei Erez
470537ec3a chainntnfs: use sync.Once to start notifiers. 2020-05-18 19:25:27 -07:00
Olaoluwa Osuntokun
d63198a792 Merge branch 'v0.10.1-beta-4277' into v0.10.1-beta-rc1-branch 2020-05-18 19:25:15 -07:00
Joost Jager
d914f55e2c lnwallet: return signer error 2020-05-18 19:25:15 -07:00
Olaoluwa Osuntokun
35c23a9d85 Merge branch 'v0.10.1-beta-4274' into v0.10.1-beta-rc1-branch 2020-05-18 19:24:53 -07:00
Wilmer Paulino
0c13b29a0e wtmock: prevent race conditions by not using ClientSession pointers
These race conditions originate from the mock database storing and
returning pointers, rather than returning a copy.

Observed on Travis:

WARNING: DATA RACE
Read at 0x00c0003222b8 by goroutine 149:
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*sessionQueue).drainBackups()
      /home/runner/work/lnd/lnd/watchtower/wtclient/session_queue.go:288 +0xed
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*sessionQueue).sessionManager()
      /home/runner/work/lnd/lnd/watchtower/wtclient/session_queue.go:281 +0x450

Previous write at 0x00c0003222b8 by goroutine 93:
  github.com/lightningnetwork/lnd/watchtower/wtclient.getClientSessions()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:365 +0x24f
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*TowerClient).handleNewTower()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:1063 +0x23e
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*TowerClient).backupDispatcher()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:784 +0x10b9
2020-05-18 19:24:52 -07:00
Wilmer Paulino
3afa4178ba wtclient: test case re-add removed tower 2020-05-18 19:24:52 -07:00
Wilmer Paulino
badbc5a491 rpc: use existing rpc logger for wtclientrpc
The logger string used to identify the wtclient and wtclientrpc loggers
was the same, leading to being unable to modify the log level of the
wtclient logger as it would be overwritten with the wtclientrpc's one.
To simplify things, we decide to use the existing RPC logger for
wtclientrpc.
2020-05-18 19:24:52 -07:00
Wilmer Paulino
1cbb574333 wtclient: filter out inactive sessions upon adding existing/new tower 2020-05-18 19:24:52 -07:00
Wilmer Paulino
2de2f28d23 wtclient: load missing info into client sessions upon new tower
This addresses a potential panic in where we relied on this missing info
being populated.
2020-05-18 19:24:52 -07:00
Wilmer Paulino
4a91472469 wtclient: refactor existing candidate session filtering into method 2020-05-18 19:24:52 -07:00
Olaoluwa Osuntokun
7daead6d85 Merge branch 'v0.10.1-beta-4257' into v0.10.1-beta-rc1-branch 2020-05-18 19:24:17 -07:00
Joost Jager
5e83ed9d89 routing+routerrpc: add multiple outgoing channel restriction 2020-05-18 19:23:12 -07:00
Joost Jager
389b715f15 routing/test: add channel id constants 2020-05-18 19:20:15 -07:00
Olaoluwa Osuntokun
eb445d5789 Merge branch 'v0.10.1-beta-2668' into v0.10.1-beta-rc1-branch 2020-05-18 19:19:34 -07:00
Conner Fromknecht
412d7f5c38 config: adds cli configurable --migration-dry-run 2020-05-18 19:18:25 -07:00
Conner Fromknecht
4b7e8669ac channeldb/db: adds optional dry-run abort for migrations 2020-05-18 19:17:08 -07:00
Olaoluwa Osuntokun
935c2f2c10 Merge branch 'v0.10.1-beta-4253' into v0.10.1-beta-rc1-branch 2020-05-18 19:16:41 -07:00
Olaoluwa Osuntokun
3c0b438f16 cmd/lncli: remove usage of Millisecond() for Go 1.12
The new table format for the pay command started to use the
`Millisecond()` method on `time.Duration`. However, this method was only
added in Go 1.13, so this breaks the build for Go 1.12. We replace this
by manual division. `time.Duration` "natively" is in nanoseconds, so we
covert to milli seconds by dividing my `time.Millisecond`, which is
1,000,000.
2020-05-18 19:16:41 -07:00
Olaoluwa Osuntokun
b38c529ba8 Merge branch 'v0.10.1-beta-4234' into v0.10.1-beta-rc1-branch 2020-05-18 19:16:13 -07:00
carla
3289b31b09 lntest/test: add htlc events test to multi-hop error propagation 2020-05-18 19:16:13 -07:00
carla
a80c69982d lntest/test: move multi-hop error propagation into its own file 2020-05-18 19:16:13 -07:00
carla
926892c906 lntest/test: test htlcnotifier stream for successful multi-hop payments 2020-05-18 19:16:13 -07:00
carla
d70f77efaf lntest/test: move multi-hop payments test into own file 2020-05-18 19:16:13 -07:00
carla
08da737316 lnrpc: add failure detail none to link event rpc 2020-05-18 19:16:13 -07:00
Olaoluwa Osuntokun
913c787082 Merge branch 'v0.10.1-beta-4241' into v0.10.1-beta-rc1-branch 2020-05-18 19:15:32 -07:00
Olaoluwa Osuntokun
f8b85eaf12 channeldb: eliminate extra copy in QueryPayments
In this commit, we eliminate an extraneous copy in the `QueryPayments`
method. Before this commit, we would copy each payment from the initial
FetchPayments call into a new slice. However, pointers to payments are
return from `FetchPayments`, so we can just maintain that same reference
rather than copying again when we want to limit our response.
2020-05-18 19:15:32 -07:00
Olaoluwa Osuntokun
4384978728 Merge branch 'v0.10.1-beta-4176' into v0.10.1-beta-rc1-branch 2020-05-18 19:14:56 -07:00
Wilmer Paulino
97e5763601 rpcserver: omit uptime in ListChannels response if server not started
If the server hasn't fully started yet, it's possible that the channel
event store hasn't either, so it won't be able to consume any requests
until then. To prevent blocking, we'll just omit the uptime related
fields for now.
2020-05-18 19:14:56 -07:00
Wilmer Paulino
08f25bb5bf rpcserver: include upfront shutdown script in ListChannels response
This field could be omitted from the response if we were unable to
calculate the channel's uptime.
2020-05-18 19:14:56 -07:00
rockstardev
5cfd1603da Adding default LND tags to our docker container release 2020-05-13 17:45:38 -05:00
rockstardev
b4c54919e9 Updating docker builder images 2020-04-24 17:46:16 -05:00
rockstardev
62e49ec081 Adding net import that got removed 2020-04-24 17:45:46 -05:00
rockstardev
840abbbdd2 Fix typos in docker-entrypoint.sh
Thanks: https://github.com/btcpayserver/lnd/pull/2
2020-04-24 17:08:08 -05:00
rockstardev
967b0662ce Setting execute permission on .sh files 2020-04-24 17:08:02 -05:00
rockstardev
afb350e553 Adjusting Makefile for fresh version string 2020-04-24 17:07:55 -05:00
rockstardev
83994bef9c Adding BtcPayServer related files and resources 2020-04-24 17:07:49 -05:00
nicolas.dorier
7324f343b9 Allow unsafe authentication on regtest 2020-04-24 17:07:42 -05:00
nicolas.dorier
7c275b2b25 Do not assume setting options partially are unintentional 2020-04-24 17:07:36 -05:00
nicolas.dorier
f05de358c7 Add --notls to disable TLS for REST endpoint 2020-04-24 17:07:29 -05:00
Olaoluwa Osuntokun
ab87dc5fe2
build: bump version to v0.9.2-beta 2020-03-12 17:02:03 -07:00
Olaoluwa Osuntokun
9f47bbc552
build: update to x/crypto version w/o broken poly1305 arm assembly
In this commit, we update to a new version of `x/crypto` that drops
broken ARM assembly that can cause a segfault in systems like raspis.
The broken assembly was removed in this commit to the runtime:
8b774103d3.

Fixes #4052.
2020-03-12 17:01:57 -07:00
Olaoluwa Osuntokun
8aead58288
build: update to version v0.9.1-beta 2020-02-28 18:06:29 -03:00
Olaoluwa Osuntokun
a7cf1b4ff5 build: bump version to v0.9.1-beta.rc1
We also add '.' to the semantic versioning alphabet to ensure it isn't
stripped out.
2020-02-20 19:24:25 -08:00
Olaoluwa Osuntokun
e78d2a061b Merge branch 'v0.9.1-beta-3932' into v0.9.1-beta-rc1-branch 2020-02-20 18:59:05 -08:00
Johan T. Halseth
1fa21e6bcd lnd: reload cert data after renewal
After renewing the certificate, the new certificate wasn't actually
loaded and used, causing the old one to be used until lnd was restarted.
This fixes that by reloading it after it has been written.
2020-02-20 18:59:04 -08:00
Johan T. Halseth
d7f6a39704 lnd+cert: recreate TLS files if IPs or DNS changed
This commit makes lnd recreate its TLS certificate if the config's
tlsextradomains or tlsextraips changed. This is useful, since earlier
user would have to manually delete the files to trigger lnd to recreate
them.

To ensure users don't accidentally have their TLS certificate recreated,
we gate it behind a flag --tlsautorefresh that defaults to false.
2020-02-20 18:59:04 -08:00
Johan T. Halseth
2c8a18fe6f cert+test: IsOutdated check for TLS files if IPs or DNS changed
This commit creates a new utility method IsOutdated that can be used to
check whether a TLS certificate mathces the extra IPs and domains given
in the lnd config.
2020-02-20 18:59:04 -08:00
Johan T. Halseth
51aba35512 cert: extract IP and DNS parsing into methods 2020-02-20 18:59:04 -08:00
Olaoluwa Osuntokun
362d53e5bb Merge branch 'v0.9.1-beta-3691' into v0.9.1-beta-rc1-branch 2020-02-20 18:58:45 -08:00
Johan T. Halseth
15099045fc lnwallet/channel: add TODO 2020-02-20 18:58:45 -08:00
Johan T. Halseth
8db2465638 lnwallet/channel: take remote commitment view into availableBalance calculation
Since our HTLC must also be added to the remote commitment, we do the
balance caluclation also from the remote chain perspective and report
our minimum balance from the two commit views as our available balance.
2020-02-20 18:58:45 -08:00
Johan T. Halseth
c30831dd0d lnwallet: take remote initiator's balance into account
When we send non-dust HTLCs as the non-initiator, the remote party will
have to pay the extra commitment fee. To account for this we figure out
if they can afford paying this fee, if not we report that we only have
balance available for dust HTLCs, since these HTLCs won't increase the
commitment fee.
2020-02-20 18:58:45 -08:00
Johan T. Halseth
e3da653f33 lnwallet/channel: account for HTLC fee when reporting available balance 2020-02-20 18:58:45 -08:00
Johan T. Halseth
7628eb2b76 link+lnwallet: move bandwidth channel reserve validation into channel
Since we want to handle the edge case where paying the HTLC fee would
take the initiator below the reserve, we move the subtraction of the
reserve into availableBalance where this calculation will be performed.
2020-02-20 18:58:45 -08:00
Johan T. Halseth
2f0c01c992 lnwallet/channel: break up availableBalance 2020-02-20 18:58:45 -08:00
Johan T. Halseth
60d843f32d lnwallet: check local commitment sanity when adding HTLC
This commit adds an extra validation step when adding HTLCs. Previously
we would only validate the remote commitment resulting from adding an
HTLC, which in most cases is enough. However, there are situations where
the dustlimits are different, which could lead to the resulting remote
commitment from adding the HTLC being valid, but not the local
commitment.

Now we also validate the local commitment. A test to trigger the case is
added.
2020-02-20 18:58:45 -08:00
Johan T. Halseth
9373f92940 lnwallet tests: add test for dipping remote below chan reserve
This commit adds a test that was previously not performed, namely that
adding a HTLC would dip the remote initiator below its channel reserve.
2020-02-20 18:58:44 -08:00
Johan T. Halseth
e5c39a6569 lnwallet/channel: make validateCommitmentSanity take our/their predict
add

To ba able to validate the commitment sanity both for remote and local
commitments, and at the same time predict both our and their add, we let
validateCommitmentSanity take an extra payment descriptor to make this
possible.
2020-02-20 18:58:44 -08:00
Olaoluwa Osuntokun
74eeff5370 Merge branch 'v0.9.1-beta-3910' into v0.9.1-beta-rc1-branch 2020-02-20 18:58:15 -08:00
nsa
28aece1220 lnwallet: adding TestMaxAsynchronousHtlcs unit test
Adds a new test which asserts that the new ReceiveHTLC logic can
handle proper commitment overflow calculation in the face of
asynchronous updates.
2020-02-20 18:58:15 -08:00
nsa
46c5293ff4 lnwallet: fixing unit tests to properly handle new receive validation
This commit fixes the TestMaxAcceptedHTLCs, TestMaxPendingAmount,
TestMinHTLC, & TestChanReserve unit tests to pass with the new
ReceiveHTLC logic. Instead of asserting specific failures upon
receiving a new commitment signature, the various assertions were
moved to assert on the error returned from ReceiveHTLC.
2020-02-20 18:58:15 -08:00
nsa
22b8402322 lnwallet: call valdiateCommitmentSanity in ReceiveHTLC
This commit checks the commitment sanity when receiving an HTLC so
that if a commitment transaction will overflow from an ADD, it is
caught earlier rather than in ReceiveNewCommitment.
2020-02-20 18:58:15 -08:00
Olaoluwa Osuntokun
ab2324c652 Merge branch 'v0.9.1-beta-3998' into v0.9.1-beta-rc1-branch 2020-02-20 18:57:38 -08:00
Johan T. Halseth
2908984b16 lnwallet: state transition from correct node during test, remove panic
The unit test TestNewBreachRetributionSkipsDustHtlcs triggered a state
transition from Bob, even though it was Alice that had added the HTLCs.
This is wrong since it will lead to Bob still owing Alice a commitment,
which is not accounted for in the unit tests.

We add a sanity check that the add heights has been set for all entries
found in the logs, and return an error otherwise. This won't happen
during normal operation, but it does reveal the mistake in the unit
test, which is fixed by making Alice trigger the transition.

In addition we resolve a long standing TODO by removing a (purposeful)
panic in the channel state machine. Old version of lnd had a bug that
could lead to the parent entries being lost during channel restore. A
panic was added to get to the bottom of if.

This is now fixed, so new nodes shouldn't encounter it. However, to be
on the safe side, instead of panicking we return an error back to
gracefully exit the channel state machine.
2020-02-20 18:57:37 -08:00
Johan T. Halseth
857d26eb71 lnwallet: unify remote and local update log fetch 2020-02-20 18:57:37 -08:00
Olaoluwa Osuntokun
e3e93ab0e6 Merge branch 'v0.9.1-beta-3876' into v0.9.1-beta-rc1-branch 2020-02-20 18:56:01 -08:00
Roei Erez
6152625c53 contractcourt+switch: keep channels with timed-out initiated htlcs.
This commit enables the user to specify he is not interested in
automatically close channels with pending payments that their
corresponding htlcs have timed-out.
By requiring a configurable grace period uptime of our node
before closing such channels, we give a chance to the other node to
properly cancel the htlc and avoid unnecessary on-chain transaction.
In mobile it is very important for the user experience as otherwise
channels will be force closed more frequently.
2020-02-20 18:56:01 -08:00
Roei Erez
f24db730e4 contractcourt: change shouldGoOnChain signature.
This commit changes the shouldGoOnChain signature to get the htlc
as parameter. I will allow the function to take decisions based on
whether the htlc is Incoming or Outgoing.
2020-02-20 18:56:01 -08:00
Olaoluwa Osuntokun
66210aa722 Merge branch 'v0.9.1-beta-3965' into v0.9.1-beta-rc1-branch 2020-02-20 18:54:43 -08:00
Oliver Gugger
8fb33dc5bf rpcserver: instruct REST marshaler to emit default values
This change instructs the REST proxy server to overwrite its default
JSON marshaler settings. That allows us to set EmitDefaults to true
which will result in all JSON fields returned in REST responses to
be fully populated, even if their values are falsey.
2020-02-20 18:54:43 -08:00
Olaoluwa Osuntokun
fbcf388a56 Merge branch 'v0.9.1-beta-3980' into v0.9.1-beta-rc1-branch 2020-02-20 18:54:04 -08:00
Joost Jager
b0c6c1c39c invoices: fix htlc timer deadlock 2020-02-20 18:54:04 -08:00
Joost Jager
44495fdefb invoices: move log into update context 2020-02-20 18:54:04 -08:00
Joost Jager
eea67b00cb invoices: add hash to update context 2020-02-20 18:54:04 -08:00
Olaoluwa Osuntokun
b269185cf0 Merge branch 'v0.9.1-beta-3950' into v0.9.1-beta-rc1-branch 2020-02-20 18:53:34 -08:00
Andras Banki-Horvath
8437f127f0 invoices: fix slow startup with many expired invoices
This commit intends to fix slow first startup time when there are many
invoices that need to be canceled. The slowdown is caused by a combination
of adding invoices to the expiry watcher one-by-one and slow
cancellation. Due to slow cancellation and the unbuffered channel which
we use to pass invoices to the expiry watcher blocks the registry.
With this fix we'll instead batch add invoices to the expiry watcher and
thereby won't block the registry startup.
2020-02-20 18:53:33 -08:00
Olaoluwa Osuntokun
f102a00a04 Merge branch 'v0.9.1-beta-3925' into v0.9.1-beta-rc1-branch 2020-02-20 18:52:54 -08:00
Wilmer Paulino
1d8da3123e discovery: check ChainHash in QueryChannelRange messages
If the provided ChainHash in a QueryChannelRange message does not match
that of our current chain, then we should send a blank response, rather
than reply with channels for the wrong chain.
2020-02-20 18:52:54 -08:00
Olaoluwa Osuntokun
4ac37c9f34 Merge branch 'v0.9.1-beta-3992' into v0.9.1-beta-rc1-branch 2020-02-20 18:52:36 -08:00
Joost Jager
156f683e87 lnwallet: fix invalid value use in restoreUpdate
Updates were always restored with the same log index. This could cause a
crash when the logs were compacted and possibly other problems
elsewhere.

Extended unit test to cover the crash scenario.
2020-02-20 18:52:36 -08:00
Olaoluwa Osuntokun
ba822bb7cc Merge branch 'v0.9.1-beta-3872' into v0.9.1-beta-rc1-branch 2020-02-20 18:51:53 -08:00
Joost Jager
666da0d10c lnwallet: restore unsigned acked remote updates
This commit updates the channel state machine to
persistently store remote updates that we have received a
signature for, but that we haven't yet included in a commit
signature of our own.

Previously those updates were only stored in memory and
dropped across restarts. This lead to the production of
an invalid signature and channel force closure. The remote
party expects us to include those updates.
2020-02-20 18:51:52 -08:00
Joost Jager
38445efce7 lnwallet: extract pending local updates restore method
Extract method in preparation for restoring dangling remote updates. We
need to get rid of the early return.
2020-02-20 18:51:52 -08:00
Joost Jager
9da8ad6aa7 channeldb: extract log update serialization
Extract functionality to methods as a preparation for serializing remote
log updates.
2020-02-20 18:51:52 -08:00
Joost Jager
a1b6edef87 channeldb: update UpdateCommitment description
This method is only used to update the local commitment transaction.
Updated comment accordingly.
2020-02-20 18:51:52 -08:00
Joost Jager
716c87fc4e lnwallet/test: test remote update after restart
This test asserts that remote updates that are locked-in on the local
commitment, but haven't been signed for on the remote commitment, are
properly restored after a restart.
2020-02-20 18:51:52 -08:00
Joost Jager
f8b1c8162c lnwallet/test: describe existing bug after restart with dangling remote updates 2020-02-20 18:51:52 -08:00
Joost Jager
1f477f443b lnwallet: restore missing field in local log update
When restoring an htlc fulfill update from disk, the payment hash wasn't
restored previously.
2020-02-20 18:51:52 -08:00
Olaoluwa Osuntokun
25b3d78cb5 Merge branch 'v0.9.1-beta-4017' into v0.9.1-beta-rc1-branch 2020-02-20 18:49:12 -08:00
Olaoluwa Osuntokun
d0d542c477 build: update to latest btcwallet version with rescan addr fix
In this commit, we update to the latest `btcwallet` version that
includes a fix for how we perform rescans. Before this commit, the
wallet would load ALL the created keys into the wallet to perform a
rescan. This is unnecessary, as many of the keys we create are actually
used in contracts, so the wallet can't spend them directly anyway.

For neutrino nodes, this would've caused them to attempt o match more
items in the filter than necessary, possibly resulting in an increased
number of false positive block fetches.
2020-02-20 18:48:36 -08:00
rockstardev
84c25f83bd Setting execute permission on .sh files 2020-01-14 15:25:38 -06:00
rockstardev
2fbbcd2e1d Adjusting Makefile for fresh version string 2020-01-14 15:25:32 -06:00
rockstardev
2e98e45a6e Adding BtcPayServer related files and resources 2020-01-14 15:25:26 -06:00
nicolas.dorier
84200f9299 Allow unsafe authentication on regtest 2020-01-14 15:25:21 -06:00
nicolas.dorier
dc2ef53b82 Do not assume setting options partially are unintentional 2020-01-14 15:25:14 -06:00
nicolas.dorier
4ba6cd647d Add --notls to disable TLS for REST endpoint 2020-01-14 15:25:07 -06:00
Olaoluwa Osuntokun
9cd40c5950
build: bump version to v0.8.2 2019-12-11 16:55:34 -08:00
Olaoluwa Osuntokun
0bc44ec5aa Merge branch 'v0.8.2-beta-3804' into v0.8.2-beta-rc2-branch 2019-12-06 16:10:35 -08:00
Olaoluwa Osuntokun
7ab4667114 Revert "funding: ensure the chan policy max htlc size is below max pay size"
This reverts commit 9b3385e87d.
2019-12-06 16:10:35 -08:00
Olaoluwa Osuntokun
dbb1f3b873 Revert "peer: clamp a link's max HTLC forwarding policy to current max HTLC pay size"
This reverts commit c943d85019.
2019-12-06 16:10:35 -08:00
Olaoluwa Osuntokun
87851c2cdf Merge branch 'v0.8.2-beta-3752' into v0.8.2-beta-rc1-branch 2019-12-04 19:40:58 -08:00
Johan T. Halseth
da737764d0 chainntnfs/txnotifier: promote historical spend log to info
And add some more details.
2019-12-04 19:40:57 -08:00
Johan T. Halseth
8d54778c16 chainntnfs/txnotifier: add more debug logs aroung spend dispatch
To track down missing spends.
2019-12-04 19:40:57 -08:00
Johan T. Halseth
ab9ac096ea chainntnfs/bitcoind: log finished hitsorical spend dispatch 2019-12-04 19:40:57 -08:00
Johan T. Halseth
0bcc2bb52f chainntnfs/interface: add String method for SpendDetaill 2019-12-04 19:40:57 -08:00
Johan T. Halseth
afeb6eea65 chainntnfs/txnotifier: include script in SpendRequest string representation 2019-12-04 19:40:57 -08:00
Olaoluwa Osuntokun
594c832180 Merge branch 'v0.8.2-beta-3790' into v0.8.2-beta-rc1-branch 2019-12-04 19:40:10 -08:00
Olaoluwa Osuntokun
d7fd142d1f funding: ensure the chan policy max htlc size is below max pay size 2019-12-04 19:40:09 -08:00
Olaoluwa Osuntokun
0df8cf866d peer: clamp a link's max HTLC forwarding policy to current max HTLC pay size
In this commit, we start to clamp the max HTLC forwarding policy to the
current register max HTLC payment size. By doing this, we ensure that
any links that have a advertised max HTLC transit size above the max
payment size will reject any incoming or outgoing attempts for such
large payments.
2019-12-04 19:40:09 -08:00
Olaoluwa Osuntokun
1fab42a7e2 lnrpc/routerrpc: make SendToRoute consistent with other payment RPCs
In this commitment, we make the `SendToRoute` RPC call consistent with
all the other payment RPCs which will properly adhere to the current max
payment sat limit. This is a prep commit for the future wumbo soft cap
that will eventually land in lnd.
2019-12-04 19:40:09 -08:00
Olaoluwa Osuntokun
6a6ba4efd7 htlcswitch: fix inconsistency between attribute name and godoc comment 2019-12-04 19:40:09 -08:00
Olaoluwa Osuntokun
bb6e3d92e9 cmd/lncli: exit if user opts to not recover SCB files 2019-12-04 19:39:31 -08:00
Olaoluwa Osuntokun
6893931fbf Merge branch 'v0.8.2-beta-3719' into v0.8.2-beta-rc1-branch 2019-12-04 19:38:45 -08:00
Oliver Gugger
6530b499fc lntest: add unconfirmed channel SCB test 2019-12-04 19:38:45 -08:00
Oliver Gugger
9b65a90f3f chanbackup: set funding broadcast height on restore 2019-12-04 19:38:45 -08:00
Oliver Gugger
b3599b0354 chanbackup: encode broadcast height in chan ID for unconfirmed channels 2019-12-04 19:38:45 -08:00
Olaoluwa Osuntokun
f345297009 Merge branch 'v0.8.2-beta-3737' into v0.8.2-beta-rc1-branch 2019-12-04 19:36:37 -08:00
Oliver Gugger
8ebf765924 lntest: add SCB repeated restore test 2019-12-04 19:36:37 -08:00
Oliver Gugger
b8bda0d934 chanbackup: continue recovery if channel already exists 2019-12-04 19:36:37 -08:00
Olaoluwa Osuntokun
f5aae3c06c Merge branch 'v0.8.2-beta-3698' into v0.8.2-beta-rc1-branch 2019-12-04 19:34:18 -08:00
Andreas M. Antonopoulos
dae5f614fc Warn user before doing SCB restore
SCB restore closes all open channels. We need to warn users that this is what will happen if they try to do an SCB restore.
2019-12-04 19:34:18 -08:00
rockstardev
052358f9c8 Setting execute permission on .sh files 2019-11-21 23:48:53 -06:00
rockstardev
08ad05bca0 Adjusting Makefile for fresh version string 2019-11-21 23:28:39 -06:00
rockstardev
a6b5798acd Adding BtcPayServer related files and resources 2019-11-21 23:28:29 -06:00
nicolas.dorier
8aedb15382 Allow unsafe authentication on regtest 2019-11-21 23:27:43 -06:00
nicolas.dorier
127dabcc02 Do not assume setting options partially are unintentional 2019-11-21 23:24:15 -06:00
nicolas.dorier
f0d13cbb8e Add --notls to disable TLS for REST endpoint 2019-11-21 23:23:52 -06:00
Wilmer Paulino
0bff2ed554 lnwallet: fix test inconsistencies to support bitcoind 0.19.0
bitcoind's sendrawtransaction API in v0.19.0 now enforces a maximum fee
rate of 0.1 BTC/kb and valid output scripts.
2019-11-14 16:32:14 -08:00
Wilmer Paulino
2b1effdf99 build: bump btcsuite and neutrino dependencies to latest tagged versions
The btcwallet update includes some edge-case wallet bug fixes and an
optimization on ZMQ connections for bitcoind backends.

The btcd update allows for compatibility with bitcoind v0.19.0 backends.
2019-11-14 16:31:56 -08:00
1056 changed files with 164550 additions and 51925 deletions

View File

@ -57,7 +57,7 @@ jobs:
multiarch:
machine:
enabled: true
image: ubuntu-2204:2022.04.1
image: default
steps:
- run:
command: |

195
.github/CODEOWNERS-HINT vendored Normal file
View File

@ -0,0 +1,195 @@
# This file lists the owners of code in different areas of the lnd codebase
# Codeowners will own the review for the changes being merged into their
# respective areas
# aezeed
/aezeed/ @guggero @yyforyongyu @roasbeef
# alias manager
/aliasmgr/ @Crypt-iQ
# amp
/amp/ @yyforyongyu @roasbeef
# auto pilot
/autopilot/ @bitromortac
# batch
/batch/ @bhandras
# block cache
/blockcache/ @yyforyongyu @ellemouton
# brontide
/brontide/ @Roasbeef @yyforyongyu @morehouse
# buffer
/buffer/ @yyforyongyu
# build
/build/ @Roasbeef @guggero
# certificates
/cert/ @guggero
# chain notifications
/chainntnfs/ @Roasbeef @yyforyongyu
# chain registry
/chainreg/ @ellemouton
# channel acceptor
/chanacceptor/ @Crypt-iQ
# channel backup
/chanbackup/ @guggero @ellemouton
# channel fitness
/chanfitness/ @yyforyongyu
# channel db
/channeldb/ @Roasbeef @yyforyongyu
# channel notifier
/channelnotifier/ @yyforyongyu
# clock
/clock/ @bhandras
# cluster
/cluster/ @bhandras
# command line
/cmd/ @ellemouton
# contract court
/contractcourt/ @yyforyongyu @Roasbeef @Crypt-iQ
# contrib
/contrib/ @guggero
# discovery
/discovery/ @ellemouton @yyforyongyu
# docker
/docker/ @guggero
# feature
/feature/ @ProofOfKeags
# functions/methods
/fn/ @Roasbeef @ProofOfKeags
# funding
/funding/ @Crypt-iQ @morehouse
# health check
/healthcheck/ @guggero
# htlc switch
/htlcswitch/ @Roasbeef @yyforyongyu
# musig2
/internal/musig2v040/ @guggero
# invoices
/invoices/ @yyforyongyu @bhandras
# key chain
/keychain/ @guggero @roasbeef
# kvdb
/kvdb/ @bhandras
# lncfg
/lncfg/ @Roasbeef
# lnencrypt
/lnencrypt/ @guggero
# lnpeer
/lnpeer/ @Roasbeef
#lntest
/lntest/ @yyforyongyu
# lntypes
/lntypes/ @bitromortac
# lnutils
/lnutils/ @yyforyongyu
# lnwallet
/lnwallet/ @Roasbeef @yyforyongyu @Crypt-iQ
# lnwire
/lnwire/ @ellemouton @morehouse
# macaroons
/macaroons/ @guggero
# mobile
/mobile/ @guggero
# monitoring
/monitoring/ @guggero
# multimutex
/multimutex/ @Roasbeef
# nat
/nat/ @Roasbeef
# network announcements
/netann/ @ellemouton @yyforyongyu
# peer
/peer/ @ProofOfKeags @Crypt-iQ @morehouse
# peernotifier
/peernotifier/ @yyforyongyu
# pool
/pool/ @yyforyongyu
# queue
/queue/ @bhandras
# record
/record/ @guggero
# routing
/routing/ @bitromortac @ellemouton @yyforyongyu
# rpcperms
/rpcperms/ @guggero
# shachain
/shachain/ @Roasbeef
# signal
/signal/ @Roasbeef
# sqldb
/sqldb/ @bhandras
# sweep
/sweep/ @yyforyongyu @ziggie1984
# ticker
/ticker/ @guggero
# tlv
/tlv/ @Roasbeef
# tor
/tor/ @yyforyongyu
# walletunlocker
/walletunlocker/ @guggero
# watchtower
/watchtower/ @ellemouton
# zpay32
/zpay32/ @Roasbeef @morehouse

15
.github/actions/rebase/action.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: "Rebase on to the PR target base branch"
description: "A reusable workflow that's used to rebase the PR code on to the target base branch."
runs:
using: "composite"
steps:
- name: fetch and rebase on ${{ github.base_ref }}
shell: bash
run: |
git remote add upstream https://github.com/${{ github.repository }}
git fetch upstream ${{ github.base_ref }}:refs/remotes/upstream/${{ github.base_ref }}
export GIT_COMMITTER_EMAIL="lnd-ci@example.com"
export GIT_COMMITTER_NAME="LND CI"
git rebase upstream/${{ github.base_ref }}

View File

@ -4,6 +4,9 @@ inputs:
go-version:
description: "The version of Golang to set up"
required: true
key-prefix:
description: "A prefix to use for the cache key, to separate cache entries from other workflows"
required: false
runs:
using: "composite"
@ -27,10 +30,10 @@ runs:
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-
${{ runner.os }}-go-${{ inputs.go-version }}-
${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-
${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-
- name: set GOPATH
shell: bash

View File

@ -14,6 +14,7 @@ Steps for reviewers to follow to test the change.
- [ ] The change obeys the [Code Documentation and Commenting](https://github.com/lightningnetwork/lnd/blob/master/docs/code_contribution_guidelines.md#CodeDocumentation) guidelines, and lines wrap at 80.
- [ ] Commits follow the [Ideal Git Commit Structure](https://github.com/lightningnetwork/lnd/blob/master/docs/code_contribution_guidelines.md#IdealGitCommitStructure).
- [ ] Any new logging statements use an appropriate subsystem and logging level.
- [ ] [There is a change description in the release notes](https://github.com/lightningnetwork/lnd/tree/master/docs/release-notes), or `[skip ci]` in the commit message for small changes.
- [ ] Any new lncli commands have appropriate tags in the comments for the rpc in the proto file.
- [ ] [There is a change description in the release notes](https://github.com/lightningnetwork/lnd/tree/master/docs/release-notes), or `[skip ci]` in the commit message for small changes.
📝 Please see our [Contribution Guidelines](https://github.com/lightningnetwork/lnd/blob/master/docs/code_contribution_guidelines.md) for further guidance.
📝 Please see our [Contribution Guidelines](https://github.com/lightningnetwork/lnd/blob/master/docs/code_contribution_guidelines.md) for further guidance.

View File

@ -21,7 +21,9 @@ defaults:
shell: bash
env:
BITCOIN_VERSION: "23.0"
BITCOIN_VERSION: "28"
TRANCHES: 8
# If you change this value, please change it in the following files as well:
# /.travis.yml
@ -29,9 +31,32 @@ env:
# /dev.Dockerfile
# /make/builder.Dockerfile
# /.github/workflows/release.yml
GO_VERSION: 1.20.3
GO_VERSION: 1.22.6
jobs:
########################
# SQLC code gen check
########################
sqlc-check:
name: Sqlc check
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v3
- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'
- name: docker image cache
uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
- name: Generate sql models
run: make sqlc-check
########################
# RPC and mobile compilation check
########################
@ -78,12 +103,7 @@ jobs:
go-version: '${{ env.GO_VERSION }}'
- name: fetch and rebase on ${{ github.base_ref }}
run: |
git remote add upstream https://github.com/${{ github.repository }}
git fetch upstream
export GIT_COMMITTER_EMAIL="lnd-ci@example.com"
export GIT_COMMITTER_NAME="LND CI"
git rebase upstream/${{ github.base_ref }}
uses: ./.github/actions/rebase
- name: check commits
run: scripts/check-each-commit.sh upstream/${{ github.base_ref }}
@ -108,6 +128,12 @@ jobs:
- name: check code format
run: make fmt-check
- name: check go modules tidiness
run: make tidy-module-check
- name: lint proto files
run: make protolint
- name: lint
run: GOGC=50 make lint
@ -125,6 +151,7 @@ jobs:
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'
key-prefix: cross-compile
- name: build release for all architectures
run: make release
@ -144,7 +171,7 @@ jobs:
with:
go-version: '${{ env.GO_VERSION }}'
- name: check all command line flags exist in sample-lnd.conf file
- name: check default values in sample-lnd.conf file
run: make sample-conf-check
########################
@ -163,17 +190,35 @@ jobs:
- unit tags="kvdb_postgres"
- unit tags="kvdb_sqlite"
- btcd unit-race
- unit-module
steps:
- name: git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: fetch and rebase on ${{ github.base_ref }}
if: github.event_name == 'pull_request'
uses: ./.github/actions/rebase
- name: git checkout fuzzing seeds
uses: actions/checkout@v3
with:
repository: lightninglabs/lnd-fuzz
path: lnd-fuzz
- name: rsync fuzzing seeds
run: rsync -a --ignore-existing lnd-fuzz/ ./
- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'
key-prefix: unit-test
- name: install bitcoind
run: ./scripts/install_bitcoind.sh
run: ./scripts/install_bitcoind.sh $BITCOIN_VERSION
- name: run ${{ matrix.unit_type }}
run: make ${{ matrix.unit_type }}
@ -183,8 +228,10 @@ jobs:
if: matrix.unit_type == 'btcd unit-cover'
with:
path-to-profile: coverage.txt
flag-name: 'unit'
parallel: true
########################
# run ubuntu integration tests
########################
@ -198,35 +245,54 @@ jobs:
matrix:
include:
- name: btcd
args: backend=btcd
args: backend=btcd cover=1
- name: bitcoind
args: backend=bitcoind
args: backend=bitcoind cover=1
- name: bitcoind-notxindex
args: backend="bitcoind notxindex"
- name: bitcoind-rpcpolling
args: backend="bitcoind rpcpolling"
args: backend="bitcoind rpcpolling" cover=1
- name: bitcoind-etcd
args: backend=bitcoind dbbackend=etcd
- name: bitcoind-postgres
args: backend=bitcoind dbbackend=postgres
- name: bitcoind-sqlite
args: backend=bitcoind dbbackend=sqlite
- name: bitcoind-postgres-nativesql
args: backend=bitcoind dbbackend=postgres nativesql=true
- name: bitcoind-sqlite-nativesql
args: backend=bitcoind dbbackend=sqlite nativesql=true
- name: neutrino
args: backend=neutrino
args: backend=neutrino cover=1
steps:
- name: git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: fetch and rebase on ${{ github.base_ref }}
if: github.event_name == 'pull_request'
uses: ./.github/actions/rebase
- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'
key-prefix: integration-test
- name: install bitcoind
run: ./scripts/install_bitcoind.sh
run: ./scripts/install_bitcoind.sh $BITCOIN_VERSION
- name: run ${{ matrix.name }}
run: make itest-parallel ${{ matrix.args }}
run: make itest-parallel tranches=${{ env.TRANCHES }} ${{ matrix.args }}
- name: Send coverage
if: ${{ contains(matrix.args, 'cover=1') }}
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.txt
flag-name: 'itest-${{ matrix.name }}'
parallel: true
- name: Zip log files on failure
if: ${{ failure() }}
@ -252,14 +318,26 @@ jobs:
steps:
- name: git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: fetch and rebase on ${{ github.base_ref }}
if: github.event_name == 'pull_request'
uses: ./.github/actions/rebase
- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'
key-prefix: integration-test
- name: run itest
run: make itest-parallel windows=1
run: make itest-parallel tranches=${{ env.TRANCHES }} windows=1
- name: kill any remaining lnd processes
if: ${{ failure() }}
shell: powershell
run: taskkill /IM lnd-itest.exe /T /F
- name: Zip log files on failure
if: ${{ failure() }}
@ -274,6 +352,50 @@ jobs:
path: logs-itest-windows.zip
retention-days: 5
########################
# run macOS integration test
########################
macos-integration-test:
name: run macOS itest
runs-on: macos-14
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
steps:
- name: git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: fetch and rebase on ${{ github.base_ref }}
if: github.event_name == 'pull_request'
uses: ./.github/actions/rebase
- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'
key-prefix: integration-test
- name: install bitcoind
run: |
wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}.0/bitcoin-${BITCOIN_VERSION}.0-arm64-apple-darwin.tar.gz
tar zxvf bitcoin-${BITCOIN_VERSION}.0-arm64-apple-darwin.tar.gz
mv bitcoin-${BITCOIN_VERSION}.0 /tmp/bitcoin
- name: run itest
run: PATH=$PATH:/tmp/bitcoin/bin make itest-parallel tranches=${{ env.TRANCHES }} backend=bitcoind
- name: Zip log files on failure
if: ${{ failure() }}
timeout-minutes: 5 # timeout after 5 minute
run: 7z a logs-itest-macos.zip itest/**/*.log
- name: Upload log files on failure
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: logs-itest-macos
path: logs-itest-macos.zip
retention-days: 5
########################
# check pinned dependencies
@ -286,14 +408,14 @@ jobs:
fail-fast: false
matrix:
pinned_dep:
- google.golang.org/grpc v1.41.0
- github.com/golang/protobuf v1.5.2
- google.golang.org/grpc v1.59.0
- github.com/golang/protobuf v1.5.3
steps:
- name: git checkout
uses: actions/checkout@v3
- name: ensure dependences at correct version
- name: ensure dependencies at correct version
run: if ! grep -q "${{ matrix.pinned_dep }}" go.mod; then echo dependency ${{ matrix.pinned_dep }} should not be altered ; exit 1 ; fi
########################
@ -309,3 +431,13 @@ jobs:
- name: release notes check
run: scripts/check-release-notes.sh
# Notify about the completion of all coverage collecting jobs.
finish:
if: ${{ always() }}
needs: [unit-test, ubuntu-integration-test]
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true

View File

@ -11,12 +11,11 @@ defaults:
env:
# If you change this value, please change it in the following files as well:
# /.travis.yml
# /Dockerfile
# /dev.Dockerfile
# /make/builder.Dockerfile
# /.github/workflows/main.yml
GO_VERSION: 1.20.3
GO_VERSION: 1.22.6
jobs:
main:
@ -40,11 +39,10 @@ jobs:
run: SKIP_VERSION_CHECK=1 make release tag=${{ env.RELEASE_VERSION }}
- name: Create Release
uses: lightninglabs/gh-actions/action-gh-release@2021.01.25.00
uses: lightninglabs/gh-actions/action-gh-release@c7149b6a7818d1c39b36b69e727569897b6f2c5a
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
name: lnd ${{ env.RELEASE_VERSION }}
draft: true
prerelease: false
@ -79,20 +77,20 @@ jobs:
## Verifying the Release Timestamp
From this new version onwards, in addition time-stamping the _git tag_ with [OpenTimeStamps](https://opentimestamps.org/), we'll also now timestamp the manifest file along with its signature. Two new files are now included along with the rest of our release artifacts: ` manifest-roasbeef-${{ env.RELEASE_VERSION }}.txt.asc.ots`.
From this new version onwards, in addition time-stamping the _git tag_ with [OpenTimestamps](https://opentimestamps.org/), we'll also now timestamp the manifest file along with its signature. Two new files are now included along with the rest of our release artifacts: ` manifest-roasbeef-${{ env.RELEASE_VERSION }}.txt.asc.ots`.
Assuming you have the opentimestamps client installed locally, the timestamps can be verified with the following commands:
```
ots verify manifest-roasbeef-${{ env.RELEASE_VERSION }}.sig.ots -f manifest-roasbeef-${{ env.RELEASE_VERSION }}.sig
```
Alternatively, [the open timestamps website](https://opentimestamps.org/) can be used to verify timestamps if one doesn't have a `bitcoind` instance accessible locally.
Alternatively, [the OpenTimestamps website](https://opentimestamps.org/) can be used to verify timestamps if one doesn't have a `bitcoind` instance accessible locally.
These timestamps should give users confidence in the integrity of this release even after the key that signed the release expires.
## Verifying the Release Binaries
Our release binaries are fully reproducible. Third parties are able to verify that the release binaries were produced properly without having to trust the release manager(s). See our [reproducible builds guide](https://github.com/lightningnetwork/lnd/tree/master/build/release) for how this can be achieved.
Our release binaries are fully reproducible. Third parties are able to verify that the release binaries were produced properly without having to trust the release manager(s). See our [reproducible builds guide](https://github.com/lightningnetwork/lnd/blob/master/docs/release.md) for how this can be achieved.
The release binaries are compiled with `go${{ env.GO_VERSION }}`, which is required by verifiers to arrive at the same ones.
They include the following build tags: `autopilotrpc`, `signrpc`, `walletrpc`, `chainrpc`, `invoicesrpc`, `neutrinorpc`, `routerrpc`, `watchtowerrpc`, `monitoring`, `peersrpc`, `kvdb_postrgres`, `kvdb_etcd` and `kvdb_sqlite`. Note that these are already included in the release script, so they do not need to be provided.

View File

@ -8,10 +8,11 @@ jobs:
stats:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@v2.5.0
uses: flowwer-dev/pull-request-stats@v2.11.0
with:
period: 30 # 30 days of review stats
charts: true

2
.gitignore vendored
View File

@ -38,6 +38,7 @@ itest/.minerlogs
itest/lnd-itest
itest/btcd-itest
itest/.logs-*
itest/cover
cmd/cmd
*.key
@ -65,6 +66,7 @@ profile.tmp
.DS_Store
.vscode
*.code-workspace
# Coverage test
coverage.txt

View File

@ -1,18 +1,8 @@
run:
# timeout for analysis
deadline: 10m
go: "1.22.6"
# Skip autogenerated files for mobile and gRPC as well as copied code for
# internal use.
skip-files:
- "mobile\\/.*generated\\.go"
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
- "internal\\/musig2v040"
skip-dirs:
- channeldb/migration_01_to_11
- channeldb/migration/lnwire21
# Abort after 10 minutes.
timeout: 10m
build-tags:
- autopilotrpc
@ -30,6 +20,10 @@ run:
- integration
linters-settings:
errorlint:
# Check for incorrect fmt.Errorf error wrapping.
errorf: true
govet:
# Don't report about shadowed variables
check-shadowing: false
@ -53,7 +47,6 @@ linters-settings:
- G306 # Poor file permissions used when writing to a new file.
staticcheck:
go: "1.18"
checks: ["-SA1019"]
lll:
@ -98,6 +91,15 @@ linters-settings:
- 'math.*'
- 'strconv.ParseInt'
- 'errors.Wrap'
gomoddirectives:
replace-local: true
replace-allow-list:
# See go.mod for the explanation why these are needed.
- github.com/ulikunitz/xz
- github.com/gogo/protobuf
- google.golang.org/protobuf
- github.com/lightningnetwork/lnd/sqldb
linters:
@ -120,25 +122,16 @@ linters:
- gochecknoinits
# Deprecated linters. See https://golangci-lint.run/usage/linters/.
- interfacer
- golint
- maligned
- scopelint
- exhaustivestruct
- bodyclose
- contextcheck
- nilerr
- noctx
- rowserrcheck
- sqlclosecheck
- structcheck
- tparallel
- unparam
- wastedassign
- ifshort
- varcheck
- deadcode
- nosnakecase
# Disable gofumpt as it has weird behavior regarding formatting multiple
# lines for a function which is in conflict with our contribution
@ -177,7 +170,7 @@ linters:
- wrapcheck
# Allow dynamic errors.
- goerr113
- err113
# We use ErrXXX instead.
- errname
@ -193,11 +186,41 @@ linters:
# The linter is too aggressive and doesn't add much value since reviewers
# will also catch magic numbers that make sense to extract.
- gomnd
- mnd
# Some of the tests cannot be parallelized. On the other hand, we don't
# gain much performance with this check so we disable it for now until
# unit tests become our CI bottleneck.
- paralleltest
# New linters that we haven't had time to address yet.
- testifylint
- perfsprint
- inamedparam
- copyloopvar
- tagalign
- protogetter
- revive
- depguard
- gosmopolitan
- intrange
issues:
# Only show newly introduced problems.
new-from-rev: 8c66353e4c02329abdacb5a8df29998035ec2e24
new-from-rev: 77c7f776d5cbf9e147edc81d65ae5ba177a684e5
# Skip autogenerated files for mobile and gRPC as well as copied code for
# internal use.
skip-files:
- "mobile\\/.*generated\\.go"
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
- "internal\\/musig2v040"
skip-dirs:
- channeldb/migration_01_to_11
- channeldb/migration/lnwire21
exclude-rules:
# Exclude gosec from running for tests so that tests with weak randomness
@ -206,6 +229,18 @@ issues:
linters:
- gosec
- funlen
- revive
# Allow duplications in tests so it's easier to follow a single unit
# test.
- dupl
- path: mock*
linters:
- revive
# forcetypeassert is skipped for the mock because the test would fail
# if the returned value doesn't match the type, so there's no need to
# check the convert.
- forcetypeassert
- path: test*
linters:
@ -226,8 +261,8 @@ issues:
- forbidigo
- godot
# Allow fmt.Printf() in lncli.
- path: cmd/lncli/*
# Allow fmt.Printf() in commands.
- path: cmd/commands/*
linters:
- forbidigo
@ -239,13 +274,16 @@ issues:
linters:
- forbidigo
- path: itest/.*
linters:
- paralleltest
- path: lnmock/*
linters:
# forcetypeassert is skipped for the mock because the test would fail
# if the returned value doesn't match the type, so there's no need to
# check the convert.
- forcetypeassert
- path: mock*
linters:
# forcetypeassert is skipped for the mock because the test would fail
# if the returned value doesn't match the type, so there's no need to
# check the convert.
- forcetypeassert

70
.protolint.yaml Normal file
View File

@ -0,0 +1,70 @@
# The example configuration file for the protolint is located here:
# https://github.com/yoheimuta/protolint/blob/master/_example/config/.protolint.yaml
---
# Lint directives.
lint:
# Linter rules.
# Run `protolint list` to see all available rules.
rules:
# Determines whether or not to include the default set of linters.
no_default: true
# Set the default to all linters. This option works the other way around as no_default does.
# If you want to enable this option, delete the comment out below and no_default.
# all_default: true.
# The specific linters to add.
add:
- MESSAGE_NAMES_UPPER_CAMEL_CASE
- MAX_LINE_LENGTH
- INDENT
- FILE_NAMES_LOWER_SNAKE_CASE
- IMPORTS_SORTED
- PACKAGE_NAME_LOWER_CASE
- ORDER
- SERVICES_HAVE_COMMENT
- RPCS_HAVE_COMMENT
- PROTO3_FIELDS_AVOID_REQUIRED
- PROTO3_GROUPS_AVOID
- SYNTAX_CONSISTENT
- RPC_NAMES_CASE
- QUOTE_CONSISTENT
# Linter rules option.
rules_option:
# MAX_LINE_LENGTH rule option.
max_line_length:
# Enforces a maximum line length.
max_chars: 80
# Specifies the character count for tab characters.
tab_chars: 2
# INDENT rule option.
indent:
# Available styles are 4(4-spaces), 2(2-spaces) or tab.
style: 4
# Specifies if it should stop considering and inserting new lines at the appropriate positions.
# when the inner elements are on the same line. Default is false.
not_insert_newline: true
# QUOTE_CONSISTENT rule option.
quote_consistent:
# Available quote are "double" or "single".
quote: double
# ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH rule option.
enum_field_names_zero_value_end_with:
suffix: INVALID
# SERVICE_NAMES_END_WITH rule option.
service_names_end_with:
text: Service
# REPEATED_FIELD_NAMES_PLURALIZED rule option.
## The spec for each rules follows the implementation of https://github.com/gertd/go-pluralize.
## Plus, you can refer to this rule's test code.
repeated_field_names_pluralized:
uncountable_rules:
- paper
irregular_rules:
Irregular: Regular

View File

@ -1,46 +0,0 @@
language: go
cache:
directories:
- $GOCACHE
- $GOPATH/pkg/mod
- $GOPATH/src/github.com/btcsuite
- $GOPATH/src/github.com/golang
- $GOPATH/src/github.com/grpc-ecosystem
- $GOPATH/src/gopkg.in/alecthomas
- $GOPATH/src/google.golang.org
# Remove Travis' default flag --depth=50 from the git clone command to make sure
# we have the whole git history, including the commit we lint against.
git:
depth: false
go:
# If you change this value, please change it in the following files as well:
# /Dockerfile
# /dev.Dockerfile
# /make/builder.Dockerfile
# /.github/workflows/main.yml
# /.github/workflows/release.yml
- "1.20.3"
env:
global:
- GOCACHE=$HOME/.go-build
- BITCOIN_VERSION="22.0"
sudo: required
jobs:
include:
- stage: Integration Test
name: Bitcoind Integration ARM
script:
- bash ./scripts/install_bitcoind.sh
- GOMEMLIMIT=1024MiB GOARM=7 GOARCH=arm GOOS=linux travis_wait 120 make itest-parallel backend=bitcoind tranches=8
arch: arm64
after_failure:
- |-
LOG_FILES=$(find ./itest -name '*.log')
echo "Uploading to termbin.com..." && for f in $LOG_FILES; do echo -n $f; cat $f | nc termbin.com 9999 | xargs -r0 printf ' uploaded to %s'; done
echo "Uploading to file.io..." && tar -zcvO $LOG_FILES | curl -s -F 'file=@-;filename=logs.tar.gz' https://file.io | xargs -r0 printf 'logs.tar.gz uploaded to %s\n'

View File

@ -1,4 +1,7 @@
{
"editor.tabSize": 8,
"editor.rulers": [80]
"editor.rulers": [
80
],
"go.buildTags": "autopilotrpc chainrpc dev invoicesrpc neutrinorpc peersrpc signrpc walletrpc watchtowerrpc"
}

View File

@ -1,10 +1,9 @@
# If you change this value, please change it in the following files as well:
# /.travis.yml
# /dev.Dockerfile
# /make/builder.Dockerfile
# /.github/workflows/main.yml
# /.github/workflows/release.yml
FROM golang:1.20.3-alpine as builder
FROM golang:1.22.6-alpine as builder
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
# queries required to connect to linked containers succeed.

158
Makefile
View File

@ -3,6 +3,8 @@ ESCPKG := github.com\/lightningnetwork\/lnd
MOBILE_PKG := $(PKG)/mobile
TOOLS_DIR := tools
PREFIX ?= /usr/local
BTCD_PKG := github.com/btcsuite/btcd
GOACC_PKG := github.com/ory/go-acc
GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports
@ -24,9 +26,28 @@ COMMIT := $(shell git describe --tags --dirty)
COMMIT := $(subst -dirty,-fresh-btcpay,$(COMMIT))
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)"
GOBUILD := go build -v
GOINSTALL := go install -v
GOTEST := go test
# Determine the minor version of the active Go installation.
ACTIVE_GO_VERSION := $(shell go version | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p')
ACTIVE_GO_VERSION_MINOR := $(shell echo $(ACTIVE_GO_VERSION) | cut -d. -f2)
LOOPVARFIX :=
ifeq ($(shell expr $(ACTIVE_GO_VERSION_MINOR) \>= 21), 1)
LOOPVARFIX := GOEXPERIMENT=loopvar
endif
LOOPVARFIX :=
ifeq ($(shell expr $(GO_VERSION_MINOR) \>= 21), 1)
LOOPVARFIX := GOEXPERIMENT=loopvar
endif
# GO_VERSION is the Go version used for the release build, docker files, and
# GitHub Actions. This is the reference version for the project. All other Go
# versions are checked against this version.
GO_VERSION = 1.22.6
GOBUILD := $(LOOPVARFIX) go build -v
GOINSTALL := $(LOOPVARFIX) go install -v
GOTEST := $(LOOPVARFIX) go test
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name "*pb.go" -not -name "*pb.gw.go" -not -name "*.pb.json.go")
@ -58,7 +79,12 @@ ifneq ($(workers),)
LINT_WORKERS = --concurrency=$(workers)
endif
DOCKER_TOOLS = docker run -v $$(pwd):/build lnd-tools
DOCKER_TOOLS = docker run \
--rm \
-v $(shell bash -c "go env GOCACHE || (mkdir -p /tmp/go-cache; echo /tmp/go-cache)"):/tmp/build/.cache \
-v $(shell bash -c "go env GOMODCACHE || (mkdir -p /tmp/go-modcache; echo /tmp/go-modcache)"):/tmp/build/.modcache \
-v $(shell bash -c "mkdir -p /tmp/go-lint-cache; echo /tmp/go-lint-cache"):/root/.cache/golangci-lint \
-v $$(pwd):/build lnd-tools
GREEN := "\\033[0;32m"
NC := "\\033[0m"
@ -89,19 +115,22 @@ $(GOIMPORTS_BIN):
# INSTALLATION
# ============
#? build: Build lnd and lncli binaries, place them in project directory
build:
@$(call print, "Building debug lnd and lncli.")
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(DEV_GCFLAGS) $(DEV_LDFLAGS) $(PKG)/cmd/lnd
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(DEV_GCFLAGS) $(DEV_LDFLAGS) $(PKG)/cmd/lncli
#? build-itest: Build integration test binaries, place them in itest directory
build-itest:
@$(call print, "Building itest btcd and lnd.")
CGO_ENABLED=0 $(GOBUILD) -tags="integration" -o itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG)
CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/lnd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(PKG)/cmd/lnd
CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" $(ITEST_COVERAGE) -o itest/lnd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(PKG)/cmd/lnd
@$(call print, "Building itest binary for ${backend} backend.")
CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(RPC_TAGS) integration $(backend)" -c -o itest/itest.test$(EXEC_SUFFIX)
#? build-itest-race: Build integration test binaries in race detector mode, place them in itest directory
build-itest-race:
@$(call print, "Building itest btcd and lnd with race detector.")
CGO_ENABLED=0 $(GOBUILD) -tags="integration" -o itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG)
@ -110,16 +139,32 @@ build-itest-race:
@$(call print, "Building itest binary for ${backend} backend.")
CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(RPC_TAGS) integration $(backend)" -c -o itest/itest.test$(EXEC_SUFFIX)
install:
#? install-binaries: Build and install lnd and lncli binaries, place them in $GOPATH/bin
install-binaries:
@$(call print, "Installing lnd and lncli.")
$(GOINSTALL) -tags="${tags}" -ldflags="$(RELEASE_LDFLAGS)" $(PKG)/cmd/lnd
$(GOINSTALL) -tags="${tags}" -ldflags="$(RELEASE_LDFLAGS)" $(PKG)/cmd/lncli
#? manpages: generate and install man pages
manpages:
@$(call print, "Generating man pages lncli.1 and lnd.1.")
./scripts/gen_man_pages.sh $(DESTDIR) $(PREFIX)
#? install: Build and install lnd and lncli binaries and place them in $GOPATH/bin.
install: install-binaries
#? install-all: Performs all the same tasks as the install command along with generating and
# installing the man pages for the lnd and lncli binaries. This command is useful in an
# environment where a user has root access and so has write access to the man page directory.
install-all: install manpages
#? release-install: Build and install lnd and lncli release binaries, place them in $GOPATH/bin
release-install:
@$(call print, "Installing release lnd and lncli.")
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lnd
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lncli
#? release: Build the full set of reproducible release binaries for all supported platforms
# Make sure the generated mobile RPC stubs don't influence our vendor package
# by removing them first in the clean-mobile target.
release: clean-mobile
@ -127,6 +172,7 @@ release: clean-mobile
$(VERSION_CHECK)
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)"
#? docker-release: Same as release but within a docker container to support reproducible builds on BSD/MacOS platforms
docker-release:
@$(call print, "Building release helper docker image.")
if [ "$(tag)" = "" ]; then echo "Must specify tag=<commit_or_tag>!"; exit 1; fi
@ -148,6 +194,7 @@ scratch: build
# TESTING
# =======
#? check: Run unit and integration tests
check: unit itest
db-instance:
@ -165,52 +212,76 @@ ifeq ($(dbbackend),postgres)
sleep $(POSTGRES_START_DELAY)
endif
#? itest-only: Only run integration tests without re-building binaries
itest-only: db-instance
@$(call print, "Running integration tests with ${backend} backend.")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS)
$(COLLECT_ITEST_COVERAGE)
#? itest: Build and run integration tests
itest: build-itest itest-only
#? itest-race: Build and run integration tests in race detector mode
itest-race: build-itest-race itest-only
#? itest-parallel: Build and run integration tests in parallel mode, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
itest-parallel: build-itest db-instance
@$(call print, "Running tests")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) echo "$$(seq 0 $$(expr $(ITEST_PARALLELISM) - 1))" | xargs -P $(ITEST_PARALLELISM) -n 1 -I {} scripts/itest_part.sh {} $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
$(COLLECT_ITEST_COVERAGE)
#? itest-clean: Kill all running itest processes
itest-clean:
@$(call print, "Cleaning old itest processes")
killall lnd-itest || echo "no running lnd-itest process found";
#? unit: Run unit tests
unit: $(BTCD_BIN)
@$(call print, "Running unit tests.")
$(UNIT)
#? unit-module: Run unit tests of all submodules
unit-module:
@$(call print, "Running submodule unit tests.")
scripts/unit_test_modules.sh
#? unit-debug: Run unit tests with debug log output enabled
unit-debug: $(BTCD_BIN)
@$(call print, "Running debug unit tests.")
$(UNIT_DEBUG)
#? unit-cover: Run unit tests in coverage mode
unit-cover: $(GOACC_BIN)
@$(call print, "Running unit coverage tests.")
$(GOACC)
#? unit-race: Run unit tests in race detector mode
unit-race:
@$(call print, "Running unit race tests.")
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
#? unit-bench: Run benchmark tests
unit-bench: $(BTCD_BIN)
@$(call print, "Running benchmark tests.")
$(UNIT_BENCH)
# =============
# FLAKE HUNTING
# =============
#? flakehunter: Run the integration tests continuously until one fails
flakehunter: build-itest
@$(call print, "Flake hunting ${backend} integration tests.")
while [ $$? -eq 0 ]; do make itest-only icase='${icase}' backend='${backend}'; done
#? flake-unit: Run the unit tests continuously until one fails
flake-unit:
@$(call print, "Flake hunting unit tests.")
while [ $$? -eq 0 ]; do GOTRACEBACK=all $(UNIT) -count=1; done
#? flakehunter-parallel: Run the integration tests continuously until one fails, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
flakehunter-parallel:
@$(call print, "Flake hunting ${backend} integration tests in parallel.")
while [ $$? -eq 0 ]; do make itest-parallel tranches=1 parallel=${ITEST_PARALLELISM} icase='${icase}' backend='${backend}'; done
@ -219,6 +290,7 @@ flakehunter-parallel:
# FUZZING
# =============
#? fuzz: Run the fuzzing tests
fuzz:
@$(call print, "Fuzzing packages '$(FUZZPKG)'.")
scripts/fuzz.sh run "$(FUZZPKG)" "$(FUZZ_TEST_RUN_TIME)" "$(FUZZ_NUM_PROCESSES)"
@ -227,84 +299,147 @@ fuzz:
# UTILITIES
# =========
#? fmt: Format source code and fix imports
fmt: $(GOIMPORTS_BIN)
@$(call print, "Fixing imports.")
gosimports -w $(GOFILES_NOVENDOR)
@$(call print, "Formatting source.")
gofmt -l -w -s $(GOFILES_NOVENDOR)
#? fmt-check: Make sure source code is formatted and imports are correct
fmt-check: fmt
@$(call print, "Checking fmt results.")
if test -n "$$(git status --porcelain)"; then echo "code not formatted correctly, please run `make fmt` again!"; git status; git diff; exit 1; fi
lint: docker-tools
#? check-go-version-yaml: Verify that the Go version is correct in all YAML files
check-go-version-yaml:
@$(call print, "Checking for target Go version (v$(GO_VERSION)) in YAML files (*.yaml, *.yml)")
./scripts/check-go-version-yaml.sh $(GO_VERSION)
#? check-go-version-dockerfile: Verify that the Go version is correct in all Dockerfile files
check-go-version-dockerfile:
@$(call print, "Checking for target Go version (v$(GO_VERSION)) in Dockerfile files (*Dockerfile)")
./scripts/check-go-version-dockerfile.sh $(GO_VERSION)
#? check-go-version: Verify that the Go version is correct in all project files
check-go-version: check-go-version-dockerfile check-go-version-yaml
#? lint-source: Run static code analysis
lint-source: docker-tools
@$(call print, "Linting source.")
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
#? lint: Run static code analysis
lint: check-go-version lint-source
#? protolint: Lint proto files using protolint
protolint:
@$(call print, "Linting proto files.")
docker run --rm --volume "$$(pwd):/workspace" --workdir /workspace yoheimuta/protolint lint lnrpc/
#? tidy-module: Run `go mod` tidy for all modules
tidy-module:
echo "Running 'go mod tidy' for all modules"
scripts/tidy_modules.sh
#? tidy-module-check: Make sure all modules are up to date
tidy-module-check: tidy-module
if test -n "$$(git status --porcelain)"; then echo "modules not updated, please run `make tidy-module` again!"; git status; exit 1; fi
#? list: List all available make targets
list:
@$(call print, "Listing commands.")
@$(call print, "Listing commands:")
@$(MAKE) -qp | \
awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | \
grep -v Makefile | \
sort
#? help: List all available make targets with their descriptions
help: Makefile
@$(call print, "Listing commands:")
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'
#? sqlc: Generate sql models and queries in Go
sqlc:
@$(call print, "Generating sql models and queries in Go")
./scripts/gen_sqlc_docker.sh
#? sqlc-check: Make sure sql models and queries are up to date
sqlc-check: sqlc
@$(call print, "Verifying sql code generation.")
if test -n "$$(git status --porcelain '*.go')"; then echo "SQL models not properly generated!"; git status --porcelain '*.go'; exit 1; fi
#? rpc: Compile protobuf definitions and generate REST proxy stubs
rpc:
@$(call print, "Compiling protos.")
cd ./lnrpc; ./gen_protos_docker.sh
#? rpc-format: Format protobuf definition files
rpc-format:
@$(call print, "Formatting protos.")
cd ./lnrpc; find . -name "*.proto" | xargs clang-format --style=file -i
#? rpc-check: Make sure protobuf definitions are up to date
rpc-check: rpc
@$(call print, "Verifying protos.")
cd ./lnrpc; ../scripts/check-rest-annotations.sh
if test -n "$$(git status --porcelain)"; then echo "Protos not properly formatted or not compiled with v3.4.0"; git status; git diff; exit 1; fi
#? rpc-js-compile: Compile protobuf definitions and generate JSON/WASM stubs
rpc-js-compile:
@$(call print, "Compiling JSON/WASM stubs.")
GOOS=js GOARCH=wasm $(GOBUILD) -tags="$(WASM_RELEASE_TAGS)" $(PKG)/lnrpc/...
#? sample-conf-check: Make sure default values in the sample-lnd.conf file are set correctly
sample-conf-check:
@$(call print, "Making sure every flag has an example in the sample-lnd.conf file")
for flag in $$(GO_FLAGS_COMPLETION=1 go run -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lnd -- | grep -v help | cut -c3-); do if ! grep -q $$flag sample-lnd.conf; then echo "Command line flag --$$flag not added to sample-lnd.conf"; exit 1; fi; done
@$(call print, "Checking that default values in the sample-lnd.conf file are set correctly")
scripts/check-sample-lnd-conf.sh "$(RELEASE_TAGS)"
#? mobile-rpc: Compile mobile RPC stubs from the protobuf definitions
mobile-rpc:
@$(call print, "Creating mobile RPC from protos.")
cd ./lnrpc; COMPILE_MOBILE=1 SUBSERVER_PREFIX=1 ./gen_protos_docker.sh
#? vendor: Create a vendor directory with all dependencies
vendor:
@$(call print, "Re-creating vendor directory.")
rm -r vendor/; go mod vendor
#? apple: Build mobile RPC stubs and project template for iOS and macOS
apple: mobile-rpc
@$(call print, "Building iOS and macOS cxframework ($(IOS_BUILD)).")
mkdir -p $(IOS_BUILD_DIR)
$(GOMOBILE_BIN) bind -target=ios,iossimulator,macos -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -ldflags "$(RELEASE_LDFLAGS)" -v -o $(IOS_BUILD) $(MOBILE_PKG)
#? ios: Build mobile RPC stubs and project template for iOS
ios: mobile-rpc
@$(call print, "Building iOS cxframework ($(IOS_BUILD)).")
mkdir -p $(IOS_BUILD_DIR)
$(GOMOBILE_BIN) bind -target=ios,iossimulator -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -ldflags "$(RELEASE_LDFLAGS)" -v -o $(IOS_BUILD) $(MOBILE_PKG)
#? macos: Build mobile RPC stubs and project template for macOS
macos: mobile-rpc
@$(call print, "Building macOS cxframework ($(IOS_BUILD)).")
mkdir -p $(IOS_BUILD_DIR)
$(GOMOBILE_BIN) bind -target=macos -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -ldflags "$(RELEASE_LDFLAGS)" -v -o $(IOS_BUILD) $(MOBILE_PKG)
#? android: Build mobile RPC stubs and project template for Android
android: mobile-rpc
@$(call print, "Building Android library ($(ANDROID_BUILD)).")
mkdir -p $(ANDROID_BUILD_DIR)
$(GOMOBILE_BIN) bind -target=android -androidapi 21 -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -ldflags "$(RELEASE_LDFLAGS)" -v -o $(ANDROID_BUILD) $(MOBILE_PKG)
#? mobile: Build mobile RPC stubs and project templates for iOS and Android
mobile: ios android
#? clean: Remove all generated files
clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) ./lnd-debug ./lncli-debug
$(RM) ./lnd-itest ./lncli-itest
$(RM) -r ./vendor .vendor-new
#? clean-mobile: Remove all generated mobile files
clean-mobile:
@$(call print, "Cleaning autogenerated mobile RPC stubs.")
$(RM) -r mobile/build
@ -317,6 +452,7 @@ clean-mobile:
install \
scratch \
check \
help \
itest-only \
itest \
unit \

152
README.md
View File

@ -1,97 +1,89 @@
## Lightning Network Daemon
# BTCPayServer LND
[![Build Status](https://img.shields.io/travis/lightningnetwork/lnd.svg)](https://travis-ci.org/lightningnetwork/lnd)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lightningnetwork/lnd/blob/master/LICENSE)
[![Irc](https://img.shields.io/badge/chat-on%20libera-brightgreen.svg)](https://web.libera.chat/#lnd)
[![Godoc](https://godoc.org/github.com/lightningnetwork/lnd?status.svg)](https://godoc.org/github.com/lightningnetwork/lnd)
This repository is used to build LND Docker container images that are distributed with BTCPayServer by default.
<img src="logo.png">
Docker images are published to https://hub.docker.com/r/btcpayserver/lnd/
The Lightning Network Daemon (`lnd`) - is a complete implementation of a
[Lightning Network](https://lightning.network) node. `lnd` has several pluggable back-end
chain services including [`btcd`](https://github.com/btcsuite/btcd) (a
full-node), [`bitcoind`](https://github.com/bitcoin/bitcoin), and
[`neutrino`](https://github.com/lightninglabs/neutrino) (a new experimental light client). The project's codebase uses the
[btcsuite](https://github.com/btcsuite/) set of Bitcoin libraries, and also
exports a large set of isolated re-usable Lightning Network related libraries
within it. In the current state `lnd` is capable of:
* Creating channels.
* Closing channels.
* Completely managing all channel states (including the exceptional ones!).
* Maintaining a fully authenticated+validated channel graph.
* Performing path finding within the network, passively forwarding incoming payments.
* Sending outgoing [onion-encrypted payments](https://github.com/lightningnetwork/lightning-onion)
through the network.
* Updating advertised fee schedules.
* Automatic channel management ([`autopilot`](https://github.com/lightningnetwork/lnd/tree/master/autopilot)).
Versions:
- [0.18.3-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.18.3-beta/images/sha256-513ddd55a5af44a14e27110ee14cb28f1c7a69205bcaa2fba4e66275c1f725e5?context=repo)
- Includes 0.28.7-beta Loop
- [Fix for lnd unlock password \n problem](https://github.com/btcpayserver/lnd/pull/7)
- [0.18.1-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.18.1-beta/images/sha256-5fbfa76a218ab59bf9206485f4c0c071a525f9f0906255a5672054741d043b79?context=repo)
- Includes 0.28.5-beta Loop
- [0.18.0-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.18.0-beta/images/sha256-e6043dddf0bdbd5c740e882447c441b37f87f2c736ebb08747a4aff5e100d9bf?context=repo)
- Includes 0.28.2-beta Loop
- [0.17.4-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.17.4-beta/images/sha256-b62ecff5ca71d37f9b4846f35b4d86ddc4faa3fc1dd0618ae9221d99f47708bd?context=explore)
- Includes 0.26.6-beta Loop
- [0.17.3-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.17.3-beta/images/sha256-141611de6c062835e9513dd1ec4155c779d7a7b55258eb1fe06e228b0835fa56?context=repo)
- Includes 0.26.6-beta Loop
- [0.17.2-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.17.2-beta/images/sha256-936767369b703a67daf6db6a008a3b53c15f407d29a7ad2327a0de28f5951b30?context=explore)
- Includes 0.26.5-beta Loop
- [0.17.1-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.17.1-beta/images/sha256-b5c106136bd33a422463c736a1db8bd3541f95ac6f277dae86ab2a01b0c3445a?context=explore)
- Includes 0.26.5-beta Loop
- [0.17.0-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.17.0-beta/images/sha256-58b98f983cd786bcb4d48ea8586144cafd44d58dc3018e26bfbfcf875f495368?context=explore)
- Includes 0.26.4-beta Loop
- [0.17.0-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.17.0-beta/images/sha256-58b98f983cd786bcb4d48ea8586144cafd44d58dc3018e26bfbfcf875f495368?context=explore)
- Includes 0.26.4-beta Loop
- [0.16.4-beta-1](https://hub.docker.com/layers/btcpayserver/lnd/v0.16.4-beta-1/images/sha256-9dd204b62d6c892485b3dd8a76e8f48545ceda5702c9d47329ba4bcbc535a8b4?context=explore)
- [0.16.3-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.16.3-beta/images/sha256-9ff34769378cfca18664c7d1da3747e7ad7fb7f38a9a7b82a3d4f85e5bfef7bf?context=explore)
- [0.16.2-beta-1](https://hub.docker.com/layers/btcpayserver/lnd/v0.16.2-beta-1/images/sha256-bfff9de84a0a4af9d643ff555125358861b70374976b970cc00d1e7fc44ed520?context=explore)
- [0.16.1-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.16.0-beta/images/sha256-f0eb70c20691aaa2ffc34fd5bd6c284299c84e96152cda5e46882a3aa4a3c6a2?context=explore)
- [0.16.0-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.16.0-beta/images/sha256-f0eb70c20691aaa2ffc34fd5bd6c284299c84e96152cda5e46882a3aa4a3c6a2?context=explore)
- [0.15.4-beta](https://hub.docker.com/layers/btcpayserver/lnd/v0.15.4-beta-1/images/sha256-cadbbff93cf36146e24fa4f32170b4b9d278a2e1acfdc50470790a94506ee9c3?context=explore)
- [Other versions are tagged](https://github.com/btcpayserver/lnd/tags), but obsoleted and not supported.
- All LND versions prior to 0.15.4 contain a consensus bug that prevents them from properly parsing transactions with more than 500,000 witness items per input (https://github.com/btcsuite/btcd/issues/1906)
- All LND versions prior to 0.15.2 contain a bug that prevents them from properly parsing Taproot transactions with script size over 11000 bytes (https://github.com/lightningnetwork/lnd/issues/7002)
- LND version 0.14.0-beta shipped with check that made it incompatable with c-lightning and eclair (https://github.com/lightningnetwork/lnd/issues/5890)
- All LND versions prior to 0.13.3 contain specification-level vulnerability (https://lists.linuxfoundation.org/pipermail/lightning-dev/2021-October/003257.html)
- All LND versions prior to 0.7 contain critical vulnerability (https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-September/002174.html)
## Lightning Network Specification Compliance
`lnd` _fully_ conforms to the [Lightning Network specification
(BOLTs)](https://github.com/lightningnetwork/lightning-rfc). BOLT stands for:
Basis of Lightning Technology. The specifications are currently being drafted
by several groups of implementers based around the world including the
developers of `lnd`. The set of specification documents as well as our
implementation of the specification are still a work-in-progress. With that
said, the current status of `lnd`'s BOLT compliance is:
Each version is marked with appropriate `basedon-vX.X.X-beta` tags. We are using `basedon` prefix in order not to conflict with LND tags from source repository.
- [X] BOLT 1: Base Protocol
- [X] BOLT 2: Peer Protocol for Channel Management
- [X] BOLT 3: Bitcoin Transaction and Script Formats
- [X] BOLT 4: Onion Routing Protocol
- [X] BOLT 5: Recommendations for On-chain Transaction Handling
- [X] BOLT 7: P2P Node and Channel Discovery
- [X] BOLT 8: Encrypted and Authenticated Transport
- [X] BOLT 9: Assigned Feature Flags
- [X] BOLT 10: DNS Bootstrap and Assisted Node Location
- [X] BOLT 11: Invoice Protocol for Lightning Payments
## Updating LND version in BTCPay Server
## Developer Resources
1. **Update https://github.com/btcpayserver/lnd**
The daemon has been designed to be as developer friendly as possible in order
to facilitate application development on top of `lnd`. Two primary RPC
interfaces are exported: an HTTP REST API, and a [gRPC](https://grpc.io/)
service. The exported API's are not yet stable, so be warned: they may change
drastically in the near future.
a) Go to https://github.com/lightningnetwork/lnd/releases and find the commit on which we should add our resources.
b) Checkout a new branch for that commit, usually in the format of `lnd/v0.18.3-beta`.
c) Cherry-pick the `Adding BtcPayServer related files and resources` commit. [Example commit](https://github.com/btcpayserver/lnd/commit/ae4bb33c6a3db8b7cc01d18fdf46e600ead9bed4).
d) Tag it with the `basedon-v*` prefix name and push it. For v0.18.1, the tag name was `basedon-v0.18.3-beta`.
i. Before you push the tag to CircleCI to build and publish image to Docker Hub, you can test if building the image works locally.
ii. You can do this for linuxamd64 for example by using command `docker build --pull -t local-lnd:test_version -f linuxamd64.Dockerfile .`
e) The build process will start (it [matches on tag format](.circleci/config.yml#L11)). Here is [an example CircleCI build](https://app.circleci.com/pipelines/github/btcpayserver/lnd/202/workflows/b90b5888-c0b8-4207-860e-a63ce21077af).
f) The resulting image will be published to Docker Hub. Example [Docker Hub image for v0.18.3](https://hub.docker.com/layers/btcpayserver/lnd/v0.18.3-beta/images/sha256-513ddd55a5af44a14e27110ee14cb28f1c7a69205bcaa2fba4e66275c1f725e5?context=repo).
An automatically generated set of documentation for the RPC APIs can be found
at [api.lightning.community](https://api.lightning.community). A set of developer
resources including guides, articles, example applications and community resources can be found at:
[docs.lightning.engineering](https://docs.lightning.engineering).
Occasionally, there are problems with:
- Versioning of base Docker images used for building Go binaries. You may need to bump that base image - [example commit](https://github.com/btcpayserver/lnd/commit/c841954c515a9d067c24987291316b093b91c2f2).
- [Updating Loop](https://github.com/lightninglabs/loop) as part of the package, which needs to happen occasionally. [Example bump of Loop version](https://github.com/btcpayserver/lnd/commit/b3aecc7ac58280ef662e39ba99461573a30fe79a
Finally, we also have an active
[Slack](https://lightning.engineering/slack.html) where protocol developers, application developers, testers and users gather to
discuss various aspects of `lnd` and also Lightning in general.
3. **Update https://github.com/btcpayserver/BTCPayServer.Lightning**
## Installation
In order to build from source, please see [the installation
instructions](docs/INSTALL.md).
Now we need to update the dependency in our Lightning library project. This library has tests, so we will know if something is broken.
## Docker
To run lnd from Docker, please see the main [Docker instructions](docs/DOCKER.md)
a) Modify the `docker-compose.yml` file to reference the new LND version. [Example](https://github.com/btcpayserver/BTCPayServer.Lightning/pull/162/commits/413784ef9b2a8e7aa0496eb91f792ff0086c0ef7).
b) Checkout a new branch for that commit, usually in the format of `feat/lnd-0.18.1`.
c) Title the commit `Bumping LND to 0.18.1-beta`.
d) Open a pull request and reference Docker Hub and Tag. [Example PR](https://github.com/btcpayserver/BTCPayServer.Lightning/pull/162).
e) Once tests pass, you can merge it.
## IRC
* irc.libera.chat
* channel #lnd
* [webchat](https://web.libera.chat/#lnd)
4. **Update https://github.com/btcpayserver/btcpayserver**
## Safety
This will give access to LND to the whole dev team and allow for further testing on their dev machines if everything works as expected.
When operating a mainnet `lnd` node, please refer to our [operational safety
guidelines](docs/safety.md). It is important to note that `lnd` is still
**beta** software and that ignoring these operational guidelines can lead to
loss of funds.
a) Modify 4 `docker-compose.yml` files in `BTCPayServer.Tests`. [Example pull request to emulate](https://github.com/btcpayserver/btcpayserver/pull/6795).
b) When you open the PR, include the version and link to the BTCPayServer.Lightning PR.
c) Once tests pass, you can merge it.
## Security
5. **Update https://github.com/btcpayserver/btcpayserver-docker**
The developers of `lnd` take security _very_ seriously. The disclosure of
security vulnerabilities helps us secure the health of `lnd`, privacy of our
users, and also the health of the Lightning Network as a whole. If you find
any issues regarding security or privacy, please disclose the information
responsibly by sending an email to security at lightning dot engineering,
preferably encrypted using our designated PGP key
(`91FE464CD75101DA6B6BAB60555C6465E5BCB3AF`) which can be found
[here](https://gist.githubusercontent.com/Roasbeef/6fb5b52886183239e4aa558f83d085d3/raw/5fa96010af201628bcfa61e9309d9b13d23d220f/security@lightning.engineering).
a) Now that everything is prepared, open a PR in the btcpayserver-docker repository to allow these changes to propagate to everyone. [Example pull request](https://github.com/btcpayserver/btcpayserver-docker/pull/911).
b) Open the PR in DRAFT mode and tag @NicolasDorier and @Pavlenex as reviewers. They typically handle releases, and once they test that the LND version update works on their server, they can ACK the update and merge it as part of the release process.
## Further reading
* [Step-by-step send payment guide with docker](https://github.com/lightningnetwork/lnd/tree/master/docker)
* [Contribution guide](https://github.com/lightningnetwork/lnd/blob/master/docs/code_contribution_guidelines.md)
## Source repository
https://github.com/lightningnetwork/lnd
## Links
* [BTCPayServer main repo](https://github.com/btcpayserver/btcpayserver)
* [BTCPayServer-Docker repo](https://github.com/btcpayserver/btcpayserver-docker)
* [BTCPayServer.Lightning](https://github.com/btcpayserver/BTCPayServer.Lightning)

View File

@ -11,7 +11,7 @@ process. A lack of a birthday means that wallets dont know how far
back to look in the chain to ensure that they derive all the proper
user addresses. Additionally, BIP39 use a very weak [KDF](https://en.wikipedia.org/wiki/Key_derivation_function). We use
scrypt with modern parameters (n=32768, r=8, p=1). A set of benchmarks has
been added, on my laptop I get about 100ms per attempt):
been added, on my laptop I get about 100ms per attempt:
```shell
$ go test -run=XXX -bench=.
@ -48,13 +48,13 @@ the keys of the wallet.
The 2 byte timestamp is expressed in Bitcoin Days Genesis, meaning that
the number of days since the timestamp in Bitcoins genesis block. This
allow us to save space, and also avoid using a wasteful level of
allows us to save space, and also avoid using a wasteful level of
granularity. This can currently express time up until 2188.
Finally, the entropy is raw entropy that should be used to derive the
wallets HD root.
## aezeed enciphering/deciperhing
## aezeed enciphering/deciphering
Next, well take the plaintext seed described above and encipher it to
procure a final cipher text. Well then take this cipher text (the

View File

@ -11,7 +11,7 @@ var (
seed *CipherSeed
)
// BenchmarkFrommnemonic benchmarks the process of converting a cipher seed
// BenchmarkTomnemonic benchmarks the process of converting a cipher seed
// (given the salt), to an enciphered mnemonic.
func BenchmarkTomnemonic(b *testing.B) {
scryptN = 32768

View File

@ -533,7 +533,17 @@ func TestDecipherIncorrectMnemonic(t *testing.T) {
// a checksum failure.
swapIndex1 := 9
swapIndex2 := 13
mnemonic[swapIndex1], mnemonic[swapIndex2] = mnemonic[swapIndex2], mnemonic[swapIndex1]
mnemonic[swapIndex1], mnemonic[swapIndex2] =
mnemonic[swapIndex2], mnemonic[swapIndex1]
// If the words happen to be the same by pure chance, we'll try again
// with different indexes.
if mnemonic[swapIndex1] == mnemonic[swapIndex2] {
swapIndex1 = 3
mnemonic[swapIndex1], mnemonic[swapIndex2] =
mnemonic[swapIndex2], mnemonic[swapIndex1]
}
// If we attempt to decrypt now, we should get a checksum failure.
// If we attempt to map back to the original cipher seed now, then we

View File

@ -5,11 +5,22 @@ import (
"fmt"
"sync"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
"golang.org/x/exp/maps"
)
// UpdateLinkAliases is a function type for a function that locates the active
// link that matches the given shortID and triggers an update based on the
// latest values of the alias manager.
type UpdateLinkAliases func(shortID lnwire.ShortChannelID) error
// ScidAliasMap is a map from a base short channel ID to a set of alias short
// channel IDs.
type ScidAliasMap map[lnwire.ShortChannelID][]lnwire.ShortChannelID
var (
// aliasBucket stores aliases as keys and their base SCIDs as values.
// This is used to populate the maps that the Manager uses. The keys
@ -47,17 +58,18 @@ var (
// operations.
byteOrder = binary.BigEndian
// startBlockHeight is the starting block height of the alias range.
startingBlockHeight = 16_000_000
// AliasStartBlockHeight is the starting block height of the alias
// range.
AliasStartBlockHeight uint32 = 16_000_000
// endBlockHeight is the ending block height of the alias range.
endBlockHeight = 16_250_000
// AliasEndBlockHeight is the ending block height of the alias range.
AliasEndBlockHeight uint32 = 16_250_000
// StartingAlias is the first alias ShortChannelID that will get
// assigned by RequestAlias. The starting BlockHeight is chosen so that
// legitimate SCIDs in integration tests aren't mistaken for an alias.
StartingAlias = lnwire.ShortChannelID{
BlockHeight: uint32(startingBlockHeight),
BlockHeight: AliasStartBlockHeight,
TxIndex: 0,
TxPosition: 0,
}
@ -68,6 +80,10 @@ var (
// errNoPeerAlias is returned when the peer's alias for a given
// channel is not found.
errNoPeerAlias = fmt.Errorf("no peer alias found")
// ErrAliasNotFound is returned when the alias is not found and can't
// be mapped to a base SCID.
ErrAliasNotFound = fmt.Errorf("alias not found")
)
// Manager is a struct that handles aliases for LND. It has an underlying
@ -77,10 +93,14 @@ var (
type Manager struct {
backend kvdb.Backend
// linkAliasUpdater is a function used by the alias manager to
// facilitate live update of aliases in other subsystems.
linkAliasUpdater UpdateLinkAliases
// baseToSet is a mapping from the "base" SCID to the set of aliases
// for this channel. This mapping includes all channels that
// negotiated the option-scid-alias feature bit.
baseToSet map[lnwire.ShortChannelID][]lnwire.ShortChannelID
baseToSet ScidAliasMap
// aliasToBase is a mapping that maps all aliases for a given channel
// to its base SCID. This is only used for channels that have
@ -98,9 +118,15 @@ type Manager struct {
}
// NewManager initializes an alias Manager from the passed database backend.
func NewManager(db kvdb.Backend) (*Manager, error) {
m := &Manager{backend: db}
m.baseToSet = make(map[lnwire.ShortChannelID][]lnwire.ShortChannelID)
func NewManager(db kvdb.Backend, linkAliasUpdater UpdateLinkAliases) (*Manager,
error) {
m := &Manager{
backend: db,
baseToSet: make(ScidAliasMap),
linkAliasUpdater: linkAliasUpdater,
}
m.aliasToBase = make(map[lnwire.ShortChannelID]lnwire.ShortChannelID)
m.peerAlias = make(map[lnwire.ChannelID]lnwire.ShortChannelID)
@ -215,12 +241,22 @@ func (m *Manager) populateMaps() error {
// AddLocalAlias adds a database mapping from the passed alias to the passed
// base SCID. The gossip boolean marks whether or not to create a mapping
// that the gossiper will use. It is set to false for the upgrade path where
// the feature-bit is toggled on and there are existing channels.
// the feature-bit is toggled on and there are existing channels. The linkUpdate
// flag is used to signal whether this function should also trigger an update
// on the htlcswitch scid alias maps.
func (m *Manager) AddLocalAlias(alias, baseScid lnwire.ShortChannelID,
gossip bool) error {
gossip, linkUpdate bool) error {
// We need to lock the manager for the whole duration of this method,
// except for the very last part where we call the link updater. In
// order for us to safely use a defer _and_ still be able to manually
// unlock, we use a sync.Once.
m.Lock()
defer m.Unlock()
unlockOnce := sync.Once{}
unlock := func() {
unlockOnce.Do(m.Unlock)
}
defer unlock()
err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error {
// If the caller does not want to allow the alias to be used
@ -270,6 +306,18 @@ func (m *Manager) AddLocalAlias(alias, baseScid lnwire.ShortChannelID,
m.aliasToBase[alias] = baseScid
}
// We definitely need to unlock the Manager before calling the link
// updater. If we don't, we'll deadlock. We use a sync.Once to ensure
// that we only unlock once.
unlock()
// Finally, we trigger a htlcswitch update if the flag is set, in order
// for any future htlc that references the added alias to be properly
// routed.
if linkUpdate {
return m.linkAliasUpdater(baseScid)
}
return nil
}
@ -340,6 +388,74 @@ func (m *Manager) DeleteSixConfs(baseScid lnwire.ShortChannelID) error {
return nil
}
// DeleteLocalAlias removes a mapping from the database and the Manager's maps.
func (m *Manager) DeleteLocalAlias(alias,
baseScid lnwire.ShortChannelID) error {
// We need to lock the manager for the whole duration of this method,
// except for the very last part where we call the link updater. In
// order for us to safely use a defer _and_ still be able to manually
// unlock, we use a sync.Once.
m.Lock()
unlockOnce := sync.Once{}
unlock := func() {
unlockOnce.Do(m.Unlock)
}
defer unlock()
err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error {
aliasToBaseBucket, err := tx.CreateTopLevelBucket(aliasBucket)
if err != nil {
return err
}
var aliasBytes [8]byte
byteOrder.PutUint64(aliasBytes[:], alias.ToUint64())
// If the user attempts to delete an alias that doesn't exist,
// we'll want to inform them about it and not just do nothing.
if aliasToBaseBucket.Get(aliasBytes[:]) == nil {
return ErrAliasNotFound
}
return aliasToBaseBucket.Delete(aliasBytes[:])
}, func() {})
if err != nil {
return err
}
// Now that the database state has been updated, we'll delete the
// mapping from the Manager's maps.
aliasSet, ok := m.baseToSet[baseScid]
if !ok {
return ErrAliasNotFound
}
// We'll filter the alias set and remove the alias from it.
aliasSet = fn.Filter(func(a lnwire.ShortChannelID) bool {
return a.ToUint64() != alias.ToUint64()
}, aliasSet)
// If the alias set is empty, we'll delete the base SCID from the
// baseToSet map.
if len(aliasSet) == 0 {
delete(m.baseToSet, baseScid)
} else {
m.baseToSet[baseScid] = aliasSet
}
// Finally, we'll delete the aliasToBase mapping from the Manager's
// cache (but this is only set if we gossip the alias).
delete(m.aliasToBase, alias)
// We definitely need to unlock the Manager before calling the link
// updater. If we don't, we'll deadlock. We use a sync.Once to ensure
// that we only unlock once.
unlock()
return m.linkAliasUpdater(baseScid)
}
// PutPeerAlias stores the peer's alias SCID once we learn of it in the
// channel_ready message.
func (m *Manager) PutPeerAlias(chanID lnwire.ChannelID,
@ -392,6 +508,19 @@ func (m *Manager) GetPeerAlias(chanID lnwire.ChannelID) (lnwire.ShortChannelID,
func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) {
var nextAlias lnwire.ShortChannelID
m.RLock()
defer m.RUnlock()
// haveAlias returns true if the passed alias is already assigned to a
// channel in the baseToSet map.
haveAlias := func(maybeNextAlias lnwire.ShortChannelID) bool {
return fn.Any(func(aliasList []lnwire.ShortChannelID) bool {
return fn.Any(func(alias lnwire.ShortChannelID) bool {
return alias == maybeNextAlias
}, aliasList)
}, maps.Values(m.baseToSet))
}
err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error {
bucket, err := tx.CreateTopLevelBucket(aliasAllocBucket)
if err != nil {
@ -404,6 +533,29 @@ func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) {
// StartingAlias to it.
nextAlias = StartingAlias
// If the very first alias is already assigned, we'll
// keep incrementing until we find an unassigned alias.
// This is to avoid collision with custom added SCID
// aliases that fall into the same range as the ones we
// generate here monotonically. Those custom SCIDs are
// stored in a different bucket, but we can just check
// the in-memory map for simplicity.
for {
if !haveAlias(nextAlias) {
break
}
nextAlias = getNextScid(nextAlias)
// Abort if we've reached the end of the range.
if nextAlias.BlockHeight >=
AliasEndBlockHeight {
return fmt.Errorf("range for custom " +
"aliases exhausted")
}
}
var scratch [8]byte
byteOrder.PutUint64(scratch[:], nextAlias.ToUint64())
return bucket.Put(lastAliasKey, scratch[:])
@ -418,6 +570,26 @@ func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) {
)
nextAlias = getNextScid(lastScid)
// If the next alias is already assigned, we'll keep
// incrementing until we find an unassigned alias. This is to
// avoid collision with custom added SCID aliases that fall into
// the same range as the ones we generate here monotonically.
// Those custom SCIDs are stored in a different bucket, but we
// can just check the in-memory map for simplicity.
for {
if !haveAlias(nextAlias) {
break
}
nextAlias = getNextScid(nextAlias)
// Abort if we've reached the end of the range.
if nextAlias.BlockHeight >= AliasEndBlockHeight {
return fmt.Errorf("range for custom " +
"aliases exhausted")
}
}
var scratch [8]byte
byteOrder.PutUint64(scratch[:], nextAlias.ToUint64())
return bucket.Put(lastAliasKey, scratch[:])
@ -433,11 +605,11 @@ func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) {
// ListAliases returns a carbon copy of baseToSet. This is used by the rpc
// layer.
func (m *Manager) ListAliases() map[lnwire.ShortChannelID][]lnwire.ShortChannelID {
func (m *Manager) ListAliases() ScidAliasMap {
m.RLock()
defer m.RUnlock()
baseCopy := make(map[lnwire.ShortChannelID][]lnwire.ShortChannelID)
baseCopy := make(ScidAliasMap)
for k, v := range m.baseToSet {
setCopy := make([]lnwire.ShortChannelID, len(v))
@ -496,10 +668,10 @@ func getNextScid(last lnwire.ShortChannelID) lnwire.ShortChannelID {
// IsAlias returns true if the passed SCID is an alias. The function determines
// this by looking at the BlockHeight. If the BlockHeight is greater than
// startingBlockHeight and less than endBlockHeight, then it is an alias
// AliasStartBlockHeight and less than AliasEndBlockHeight, then it is an alias
// assigned by RequestAlias. These bounds only apply to aliases we generate.
// Our peers are free to use any range they choose.
func IsAlias(scid lnwire.ShortChannelID) bool {
return scid.BlockHeight >= uint32(startingBlockHeight) &&
scid.BlockHeight < uint32(endBlockHeight)
return scid.BlockHeight >= AliasStartBlockHeight &&
scid.BlockHeight < AliasEndBlockHeight
}

View File

@ -23,7 +23,11 @@ func TestAliasStorePeerAlias(t *testing.T) {
require.NoError(t, err)
defer db.Close()
aliasStore, err := NewManager(db)
linkUpdater := func(shortID lnwire.ShortChannelID) error {
return nil
}
aliasStore, err := NewManager(db, linkUpdater)
require.NoError(t, err)
var chanID1 [32]byte
@ -52,7 +56,11 @@ func TestAliasStoreRequest(t *testing.T) {
require.NoError(t, err)
defer db.Close()
aliasStore, err := NewManager(db)
linkUpdater := func(shortID lnwire.ShortChannelID) error {
return nil
}
aliasStore, err := NewManager(db, linkUpdater)
require.NoError(t, err)
// We'll assert that the very first alias we receive is StartingAlias.
@ -68,6 +76,118 @@ func TestAliasStoreRequest(t *testing.T) {
require.Equal(t, nextAlias, alias2)
}
// TestAliasLifecycle tests that the aliases can be created and deleted.
func TestAliasLifecycle(t *testing.T) {
t.Parallel()
// Create the backend database and use this to create the aliasStore.
dbPath := filepath.Join(t.TempDir(), "testdb")
db, err := kvdb.Create(
kvdb.BoltBackendName, dbPath, true, kvdb.DefaultDBTimeout,
)
require.NoError(t, err)
defer db.Close()
updateChan := make(chan struct{}, 1)
linkUpdater := func(shortID lnwire.ShortChannelID) error {
updateChan <- struct{}{}
return nil
}
aliasStore, err := NewManager(db, linkUpdater)
require.NoError(t, err)
const (
base = uint64(123123123)
alias = uint64(456456456)
)
// Parse the aliases and base to short channel ID format.
baseScid := lnwire.NewShortChanIDFromInt(base)
aliasScid := lnwire.NewShortChanIDFromInt(alias)
aliasScid2 := lnwire.NewShortChanIDFromInt(alias + 1)
// Add the first alias.
err = aliasStore.AddLocalAlias(aliasScid, baseScid, false, true)
require.NoError(t, err)
// The link updater should be called.
<-updateChan
// Query the aliases and verify the results.
aliasList := aliasStore.GetAliases(baseScid)
require.Len(t, aliasList, 1)
require.Contains(t, aliasList, aliasScid)
// Add the second alias.
err = aliasStore.AddLocalAlias(aliasScid2, baseScid, false, true)
require.NoError(t, err)
// The link updater should be called.
<-updateChan
// Query the aliases and verify the results.
aliasList = aliasStore.GetAliases(baseScid)
require.Len(t, aliasList, 2)
require.Contains(t, aliasList, aliasScid)
require.Contains(t, aliasList, aliasScid2)
// Delete the first alias.
err = aliasStore.DeleteLocalAlias(aliasScid, baseScid)
require.NoError(t, err)
// The link updater should be called.
<-updateChan
// We expect to get an error if we attempt to delete the same alias
// again.
err = aliasStore.DeleteLocalAlias(aliasScid, baseScid)
require.ErrorIs(t, err, ErrAliasNotFound)
// The link updater should _not_ be called.
select {
case <-updateChan:
t.Fatal("link alias updater should not have been called")
default:
}
// Query the aliases and verify that first one doesn't exist anymore.
aliasList = aliasStore.GetAliases(baseScid)
require.Len(t, aliasList, 1)
require.Contains(t, aliasList, aliasScid2)
require.NotContains(t, aliasList, aliasScid)
// Delete the second alias.
err = aliasStore.DeleteLocalAlias(aliasScid2, baseScid)
require.NoError(t, err)
// The link updater should be called.
<-updateChan
// Query the aliases and verify that none exists.
aliasList = aliasStore.GetAliases(baseScid)
require.Len(t, aliasList, 0)
// We now request an alias generated by the aliasStore. This should give
// the first from the pre-defined list of allocated aliases.
firstRequested, err := aliasStore.RequestAlias()
require.NoError(t, err)
require.Equal(t, StartingAlias, firstRequested)
// We now manually add the next alias from the range as a custom alias.
secondAlias := getNextScid(firstRequested)
err = aliasStore.AddLocalAlias(secondAlias, baseScid, false, true)
require.NoError(t, err)
// When we now request another alias from the allocation list, we expect
// the third one (tx position 2) to be returned.
thirdRequested, err := aliasStore.RequestAlias()
require.NoError(t, err)
require.Equal(t, getNextScid(secondAlias), thirdRequested)
require.EqualValues(t, 2, thirdRequested.TxPosition)
}
// TestGetNextScid tests that given a current lnwire.ShortChannelID,
// getNextScid returns the expected alias to use next.
func TestGetNextScid(t *testing.T) {
@ -80,7 +200,7 @@ func TestGetNextScid(t *testing.T) {
name: "starting alias",
current: StartingAlias,
expected: lnwire.ShortChannelID{
BlockHeight: uint32(startingBlockHeight),
BlockHeight: AliasStartBlockHeight,
TxIndex: 0,
TxPosition: 1,
},

View File

@ -141,7 +141,7 @@ type Agent struct {
// time.
chanOpenFailures chan *chanOpenFailureUpdate
// heuristicUpdates is a channel where updates from active heurstics
// heuristicUpdates is a channel where updates from active heuristics
// will be sent.
heuristicUpdates chan *heuristicUpdate
@ -629,7 +629,7 @@ func (a *Agent) openChans(availableFunds btcutil.Amount, numChans uint32,
nodes[nID] = struct{}{}
return nil
}); err != nil {
return fmt.Errorf("unable to get graph nodes: %v", err)
return fmt.Errorf("unable to get graph nodes: %w", err)
}
// Use the heuristic to calculate a score for each node in the
@ -639,7 +639,7 @@ func (a *Agent) openChans(availableFunds btcutil.Amount, numChans uint32,
a.cfg.Graph, totalChans, chanSize, nodes,
)
if err != nil {
return fmt.Errorf("unable to calculate node scores : %v", err)
return fmt.Errorf("unable to calculate node scores : %w", err)
}
log.Debugf("Got scores for %d nodes", len(scores))
@ -648,7 +648,7 @@ func (a *Agent) openChans(availableFunds btcutil.Amount, numChans uint32,
// to open channels to.
scores, err = chooseN(numChans, scores)
if err != nil {
return fmt.Errorf("unable to make weighted choice: %v",
return fmt.Errorf("unable to make weighted choice: %w",
err)
}

View File

@ -31,7 +31,7 @@ type AgentConstraints interface {
MaxChanSize() btcutil.Amount
}
// agenConstraints is an implementation of the AgentConstraints interface that
// agentConstraints is an implementation of the AgentConstraints interface that
// indicate the constraints the autopilot agent must adhere to when opening
// channels.
type agentConstraints struct {

View File

@ -254,7 +254,7 @@ func respondMoreChans(t *testing.T, testCtx *testContext, resp moreChansResp) {
}
}
// respondMoreChans consumes the nodeScoresArgs element and responds to the
// respondNodeScores consumes the nodeScoresArgs element and responds to the
// agent with the given node scores.
func respondNodeScores(t *testing.T, testCtx *testContext,
resp map[NodeID]*NodeScore) {
@ -468,7 +468,7 @@ func TestAgentChannelCloseSignal(t *testing.T) {
}
}
// TestAgentBalanceUpdateIncrease ensures that once the agent receives an
// TestAgentBalanceUpdate ensures that once the agent receives an
// outside signal concerning a balance update, then it will re-query the
// heuristic to determine its next action.
func TestAgentBalanceUpdate(t *testing.T) {

View File

@ -21,7 +21,7 @@ func TestWeightedChoiceEmptyMap(t *testing.T) {
}
}
// singeNonZero is a type used to generate float64 slices with one non-zero
// singleNonZero is a type used to generate float64 slices with one non-zero
// element.
type singleNonZero []float64

View File

@ -84,7 +84,7 @@ func (c *WeightedCombAttachment) NodeScores(g ChannelGraph, chans []LocalChannel
g, chans, chanSize, nodes,
)
if err != nil {
return nil, fmt.Errorf("unable to get sub score: %v",
return nil, fmt.Errorf("unable to get sub score: %w",
err)
}

View File

@ -12,6 +12,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
@ -53,6 +54,8 @@ func ChannelGraphFromDatabase(db *channeldb.ChannelGraph) ChannelGraph {
// channeldb.LightningNode. The wrapper method implement the autopilot.Node
// interface.
type dbNode struct {
db *channeldb.ChannelGraph
tx kvdb.RTx
node *channeldb.LightningNode
@ -67,7 +70,7 @@ var _ Node = (*dbNode)(nil)
// will be returned in serialized compressed format.
//
// NOTE: Part of the autopilot.Node interface.
func (d dbNode) PubKey() [33]byte {
func (d *dbNode) PubKey() [33]byte {
return d.node.PubKeyBytes
}
@ -75,7 +78,7 @@ func (d dbNode) PubKey() [33]byte {
// peer is known to be listening on.
//
// NOTE: Part of the autopilot.Node interface.
func (d dbNode) Addrs() []net.Addr {
func (d *dbNode) Addrs() []net.Addr {
return d.node.Addresses
}
@ -85,32 +88,44 @@ func (d dbNode) Addrs() []net.Addr {
// describes the active channel.
//
// NOTE: Part of the autopilot.Node interface.
func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error {
return d.node.ForEachChannel(d.tx, func(tx kvdb.RTx,
ei *channeldb.ChannelEdgeInfo, ep, _ *channeldb.ChannelEdgePolicy) error {
func (d *dbNode) ForEachChannel(cb func(ChannelEdge) error) error {
return d.db.ForEachNodeChannelTx(d.tx, d.node.PubKeyBytes,
func(tx kvdb.RTx, ei *models.ChannelEdgeInfo, ep,
_ *models.ChannelEdgePolicy) error {
// Skip channels for which no outgoing edge policy is available.
//
// TODO(joostjager): Ideally the case where channels have a nil
// policy should be supported, as autopilot is not looking at
// the policies. For now, it is not easily possible to get a
// reference to the other end LightningNode object without
// retrieving the policy.
if ep == nil {
return nil
}
// Skip channels for which no outgoing edge policy is
// available.
//
// TODO(joostjager): Ideally the case where channels
// have a nil policy should be supported, as autopilot
// is not looking at the policies. For now, it is not
// easily possible to get a reference to the other end
// LightningNode object without retrieving the policy.
if ep == nil {
return nil
}
edge := ChannelEdge{
ChanID: lnwire.NewShortChanIDFromInt(ep.ChannelID),
Capacity: ei.Capacity,
Peer: dbNode{
tx: tx,
node: ep.Node,
},
}
node, err := d.db.FetchLightningNodeTx(
tx, ep.ToNode,
)
if err != nil {
return err
}
return cb(edge)
})
edge := ChannelEdge{
ChanID: lnwire.NewShortChanIDFromInt(
ep.ChannelID,
),
Capacity: ei.Capacity,
Peer: &dbNode{
tx: tx,
db: d.db,
node: node,
},
}
return cb(edge)
})
}
// ForEachNode is a higher-order function that should be called once for each
@ -127,7 +142,8 @@ func (d *databaseChannelGraph) ForEachNode(cb func(Node) error) error {
return nil
}
node := dbNode{
node := &dbNode{
db: d.db,
tx: tx,
node: n,
}
@ -222,7 +238,7 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
}
chanID := randChanID()
edge := &channeldb.ChannelEdgeInfo{
edge := &models.ChannelEdgeInfo{
ChannelID: chanID.ToUint64(),
Capacity: capacity,
}
@ -230,7 +246,7 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
if err := d.db.AddChannelEdge(edge); err != nil {
return nil, nil, err
}
edgePolicy := &channeldb.ChannelEdgePolicy{
edgePolicy := &models.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
ChannelID: chanID.ToUint64(),
LastUpdate: time.Now(),
@ -246,7 +262,7 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
if err := d.db.UpdateEdgePolicy(edgePolicy); err != nil {
return nil, nil, err
}
edgePolicy = &channeldb.ChannelEdgePolicy{
edgePolicy = &models.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
ChannelID: chanID.ToUint64(),
LastUpdate: time.Now(),
@ -265,14 +281,16 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
return &ChannelEdge{
ChanID: chanID,
Capacity: capacity,
Peer: dbNode{
Peer: &dbNode{
db: d.db,
node: vertex1,
},
},
&ChannelEdge{
ChanID: chanID,
Capacity: capacity,
Peer: dbNode{
Peer: &dbNode{
db: d.db,
node: vertex2,
},
},

View File

@ -6,9 +6,9 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/graph"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing"
)
// ManagerCfg houses a set of values and methods that is passed to the Manager
@ -36,7 +36,7 @@ type ManagerCfg struct {
// SubscribeTopology is used to get a subscription for topology changes
// on the network.
SubscribeTopology func() (*routing.TopologyClient, error)
SubscribeTopology func() (*graph.TopologyClient, error)
}
// Manager is struct that manages an autopilot agent, making it possible to
@ -293,7 +293,7 @@ func (m *Manager) queryHeuristics(nodes map[NodeID]struct{}, localState bool) (
HeuristicScores, error) {
// If we want to take the local state into action when querying the
// heuristics, we fetch it. If not we'll just pass an emply slice to
// heuristics, we fetch it. If not we'll just pass an empty slice to
// the heuristic.
var totalChans []LocalChannel
var err error
@ -341,7 +341,7 @@ func (m *Manager) queryHeuristics(nodes map[NodeID]struct{}, localState bool) (
m.cfg.PilotCfg.Graph, totalChans, chanSize, nodes,
)
if err != nil {
return nil, fmt.Errorf("unable to get sub score: %v",
return nil, fmt.Errorf("unable to get sub score: %w",
err)
}

View File

@ -7,7 +7,7 @@ package autopilot
// where 0 is maximally costly.
const diameterCutoff = 0.75
// SimpleGraph stores a simplifed adj graph of a channel graph to speed
// SimpleGraph stores a simplified adj graph of a channel graph to speed
// up graph processing by eliminating all unnecessary hashing and map access.
type SimpleGraph struct {
// Nodes is a map from node index to NodeID.
@ -26,7 +26,7 @@ func NewSimpleGraph(g ChannelGraph) (*SimpleGraph, error) {
nextIndex := 0
// getNodeIndex returns the integer index of the passed node.
// The returned index is then used to create a simplifed adjacency list
// The returned index is then used to create a simplified adjacency list
// where each node is identified by its index instead of its pubkey, and
// also to create a mapping from node index to node pubkey.
getNodeIndex := func(node Node) int {

View File

@ -66,7 +66,7 @@ func testTopCentrality(t *testing.T, graph testGraph,
}
}
// TestTopCentrality tests that we return the correct normalized centralitiy
// TestTopCentrality tests that we return the correct normalized centrality
// values given a non empty graph, and given our node has an increasing amount
// of channels from 0 to N-1 simulating the whole range from non-connected to
// fully connected.

View File

@ -48,7 +48,7 @@ func LazyAdd() SchedulerOption {
// set of Requests, executes them, and returns the error from the operation.
type Scheduler interface {
// Execute schedules a Request for execution with the next available
// batch. This method blocks until the the underlying closure has been
// batch. This method blocks until the underlying closure has been
// run against the database. The resulting error is returned to the
// caller.
Execute(req *Request) error

View File

@ -14,7 +14,7 @@ import (
// BlockCache is an lru cache for blocks.
type BlockCache struct {
Cache *lru.Cache[wire.InvVect, *neutrino.CacheableBlock]
HashMutex *multimutex.HashMutex
HashMutex *multimutex.Mutex[lntypes.Hash]
}
// NewBlockCache creates a new BlockCache with the given maximum capacity.
@ -23,7 +23,7 @@ func NewBlockCache(capacity uint64) *BlockCache {
Cache: lru.NewCache[wire.InvVect, *neutrino.CacheableBlock](
capacity,
),
HashMutex: multimutex.NewHashMutex(),
HashMutex: multimutex.NewMutex[lntypes.Hash](),
}
}
@ -52,22 +52,26 @@ func (bc *BlockCache) GetBlock(hash *chainhash.Hash,
}
// Fetch the block from the chain backends.
block, err := getBlockImpl(hash)
msgBlock, err := getBlockImpl(hash)
if err != nil {
return nil, err
}
// Make a copy of the block so it won't escape to the heap.
msgBlockCopy := msgBlock.Copy()
block := btcutil.NewBlock(msgBlockCopy)
// Add the new block to blockCache. If the Cache is at its maximum
// capacity then the LFU item will be evicted in favour of this new
// block.
_, err = bc.Cache.Put(
*inv, &neutrino.CacheableBlock{
Block: btcutil.NewBlock(block),
Block: block,
},
)
if err != nil {
return nil, err
}
return block, nil
return msgBlockCopy, nil
}

View File

@ -2,12 +2,16 @@ package brontide
import (
"bytes"
"crypto/ecdsa"
"encoding/hex"
"io"
"math"
"math/rand"
"testing"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/davecgh/go-spew/spew"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/lightningnetwork/lnd/keychain"
)
@ -59,66 +63,77 @@ var (
// and completes the brontide handshake between them. If any part of the
// handshake fails, this function will panic.
func completeHandshake(t *testing.T, initiator, responder *Machine) {
t.Helper()
if err := handshake(initiator, responder); err != nil {
nilAndPanic(t, initiator, responder, err)
}
}
// handshake actually completes the brontide handshake and bubbles up
// an error to the calling function.
func handshake(initiator, responder *Machine) error {
// Generate ActOne and send to the responder.
actOne, err := initiator.GenActOne()
if err != nil {
return err
dumpAndFail(t, initiator, responder, err)
}
if err := responder.RecvActOne(actOne); err != nil {
return err
dumpAndFail(t, initiator, responder, err)
}
// Generate ActTwo and send to initiator.
actTwo, err := responder.GenActTwo()
if err != nil {
return err
dumpAndFail(t, initiator, responder, err)
}
if err := initiator.RecvActTwo(actTwo); err != nil {
return err
dumpAndFail(t, initiator, responder, err)
}
// Generate ActThree and send to responder.
actThree, err := initiator.GenActThree()
if err != nil {
return err
dumpAndFail(t, initiator, responder, err)
}
return responder.RecvActThree(actThree)
if err := responder.RecvActThree(actThree); err != nil {
dumpAndFail(t, initiator, responder, err)
}
}
// nilAndPanic first nils the initiator and responder's Curve fields and then
// panics.
func nilAndPanic(t *testing.T, initiator, responder *Machine, err error) {
// dumpAndFail dumps the initiator and responder Machines and fails.
func dumpAndFail(t *testing.T, initiator, responder *Machine, err error) {
t.Helper()
t.Fatalf("error: %v, initiator: %v, responder: %v", err,
spew.Sdump(initiator), spew.Sdump(responder))
}
// getBrontideMachines returns two brontide machines that use random keys
// everywhere.
func getBrontideMachines() (*Machine, *Machine) {
initPriv, _ := btcec.NewPrivateKey()
respPriv, _ := btcec.NewPrivateKey()
respPub := (respPriv.PubKey())
// newInsecurePrivateKey returns a private key that is generated using a
// cryptographically insecure RNG. This function should only be used for testing
// where reproducibility is required.
func newInsecurePrivateKey(t *testing.T,
insecureRNG io.Reader) *btcec.PrivateKey {
key, err := ecdsa.GenerateKey(secp256k1.S256(), insecureRNG)
if err != nil {
t.Fatalf("error generating private key: %v", err)
}
return secp256k1.PrivKeyFromBytes(key.D.Bytes())
}
// getBrontideMachines returns two brontide machines that use pseudorandom keys
// everywhere, generated from seed.
func getBrontideMachines(t *testing.T, seed int64) (*Machine, *Machine) {
rng := rand.New(rand.NewSource(seed))
initPriv := newInsecurePrivateKey(t, rng)
respPriv := newInsecurePrivateKey(t, rng)
respPub := respPriv.PubKey()
initPrivECDH := &keychain.PrivKeyECDH{PrivKey: initPriv}
respPrivECDH := &keychain.PrivKeyECDH{PrivKey: respPriv}
initiator := NewBrontideMachine(true, initPrivECDH, respPub)
responder := NewBrontideMachine(false, respPrivECDH, nil)
ephGen := EphemeralGenerator(func() (*btcec.PrivateKey, error) {
return newInsecurePrivateKey(t, rng), nil
})
initiator := NewBrontideMachine(true, initPrivECDH, respPub, ephGen)
responder := NewBrontideMachine(false, respPrivECDH, nil, ephGen)
return initiator, responder
}
@ -144,14 +159,14 @@ func getStaticBrontideMachines() (*Machine, *Machine) {
// FuzzRandomActOne fuzz tests ActOne in the brontide handshake.
func FuzzRandomActOne(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// Check if data is large enough.
if len(data) < ActOneSize {
return
}
// This will return brontide machines with random keys.
_, responder := getBrontideMachines()
_, responder := getBrontideMachines(t, seed)
// Copy data into [ActOneSize]byte.
var actOne [ActOneSize]byte
@ -159,31 +174,31 @@ func FuzzRandomActOne(f *testing.F) {
// Responder receives ActOne, should fail on the MAC check.
if err := responder.RecvActOne(actOne); err == nil {
nilAndPanic(t, nil, responder, nil)
dumpAndFail(t, nil, responder, nil)
}
})
}
// FuzzRandomActThree fuzz tests ActThree in the brontide handshake.
func FuzzRandomActThree(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// Check if data is large enough.
if len(data) < ActThreeSize {
return
}
// This will return brontide machines with random keys.
initiator, responder := getBrontideMachines()
initiator, responder := getBrontideMachines(t, seed)
// Generate ActOne and send to the responder.
actOne, err := initiator.GenActOne()
if err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Receiving ActOne should succeed, so we panic on error.
if err := responder.RecvActOne(actOne); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Generate ActTwo - this is not sent to the initiator because
@ -192,7 +207,7 @@ func FuzzRandomActThree(f *testing.F) {
// the appropriate state in the responder machine.
_, err = responder.GenActTwo()
if err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Copy data into [ActThreeSize]byte.
@ -201,21 +216,21 @@ func FuzzRandomActThree(f *testing.F) {
// Responder receives ActThree, should fail on the MAC check.
if err := responder.RecvActThree(actThree); err == nil {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
// FuzzRandomActTwo fuzz tests ActTwo in the brontide handshake.
func FuzzRandomActTwo(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// Check if data is large enough.
if len(data) < ActTwoSize {
return
}
// This will return brontide machines with random keys.
initiator, _ := getBrontideMachines()
initiator, _ := getBrontideMachines(t, seed)
// Generate ActOne - this isn't sent to the responder because
// nothing is done with the responder machine and this would
@ -223,7 +238,7 @@ func FuzzRandomActTwo(f *testing.F) {
// appropriate state in the initiator machine.
_, err := initiator.GenActOne()
if err != nil {
nilAndPanic(t, initiator, nil, err)
dumpAndFail(t, initiator, nil, err)
}
// Copy data into [ActTwoSize]byte.
@ -232,7 +247,7 @@ func FuzzRandomActTwo(f *testing.F) {
// Initiator receives ActTwo, should fail.
if err := initiator.RecvActTwo(actTwo); err == nil {
nilAndPanic(t, initiator, nil, nil)
dumpAndFail(t, initiator, nil, nil)
}
})
}
@ -240,9 +255,9 @@ func FuzzRandomActTwo(f *testing.F) {
// FuzzRandomInitDecrypt fuzz tests decrypting arbitrary data with the
// initiator.
func FuzzRandomInitDecrypt(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// This will return brontide machines with random keys.
initiator, responder := getBrontideMachines()
initiator, responder := getBrontideMachines(t, seed)
// Complete the brontide handshake.
completeHandshake(t, initiator, responder)
@ -253,7 +268,7 @@ func FuzzRandomInitDecrypt(f *testing.F) {
// Decrypt the encrypted message using ReadMessage w/ initiator
// machine.
if _, err := initiator.ReadMessage(r); err == nil {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -261,7 +276,7 @@ func FuzzRandomInitDecrypt(f *testing.F) {
// FuzzRandomInitEncDec fuzz tests round-trip encryption and decryption between
// the initiator and the responder.
func FuzzRandomInitEncDec(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// Ensure that length of message is not greater than max allowed
// size.
if len(data) > math.MaxUint16 {
@ -269,7 +284,7 @@ func FuzzRandomInitEncDec(f *testing.F) {
}
// This will return brontide machines with random keys.
initiator, responder := getBrontideMachines()
initiator, responder := getBrontideMachines(t, seed)
// Complete the brontide handshake.
completeHandshake(t, initiator, responder)
@ -278,25 +293,25 @@ func FuzzRandomInitEncDec(f *testing.F) {
// Encrypt the message using WriteMessage w/ initiator machine.
if err := initiator.WriteMessage(data); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Flush the encrypted message w/ initiator machine.
if _, err := initiator.Flush(&b); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Decrypt the ciphertext using ReadMessage w/ responder
// machine.
plaintext, err := responder.ReadMessage(&b)
if err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Check that the decrypted message and the original message are
// equal.
if !bytes.Equal(data, plaintext) {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -304,7 +319,7 @@ func FuzzRandomInitEncDec(f *testing.F) {
// FuzzRandomInitEncrypt fuzz tests the encryption of arbitrary data with the
// initiator.
func FuzzRandomInitEncrypt(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// Ensure that length of message is not greater than max allowed
// size.
if len(data) > math.MaxUint16 {
@ -312,7 +327,7 @@ func FuzzRandomInitEncrypt(f *testing.F) {
}
// This will return brontide machines with random keys.
initiator, responder := getBrontideMachines()
initiator, responder := getBrontideMachines(t, seed)
// Complete the brontide handshake.
completeHandshake(t, initiator, responder)
@ -321,12 +336,12 @@ func FuzzRandomInitEncrypt(f *testing.F) {
// Encrypt the message using WriteMessage w/ initiator machine.
if err := initiator.WriteMessage(data); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Flush the encrypted message w/ initiator machine.
if _, err := initiator.Flush(&b); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
})
}
@ -334,9 +349,9 @@ func FuzzRandomInitEncrypt(f *testing.F) {
// FuzzRandomRespDecrypt fuzz tests the decryption of arbitrary data with the
// responder.
func FuzzRandomRespDecrypt(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// This will return brontide machines with random keys.
initiator, responder := getBrontideMachines()
initiator, responder := getBrontideMachines(t, seed)
// Complete the brontide handshake.
completeHandshake(t, initiator, responder)
@ -347,7 +362,7 @@ func FuzzRandomRespDecrypt(f *testing.F) {
// Decrypt the encrypted message using ReadMessage w/ responder
// machine.
if _, err := responder.ReadMessage(r); err == nil {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -355,7 +370,7 @@ func FuzzRandomRespDecrypt(f *testing.F) {
// FuzzRandomRespEncDec fuzz tests round-trip encryption and decryption between
// the responder and the initiator.
func FuzzRandomRespEncDec(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// Ensure that length of message is not greater than max allowed
// size.
if len(data) > math.MaxUint16 {
@ -363,7 +378,7 @@ func FuzzRandomRespEncDec(f *testing.F) {
}
// This will return brontide machines with random keys.
initiator, responder := getBrontideMachines()
initiator, responder := getBrontideMachines(t, seed)
// Complete the brontide handshake.
completeHandshake(t, initiator, responder)
@ -372,25 +387,25 @@ func FuzzRandomRespEncDec(f *testing.F) {
// Encrypt the message using WriteMessage w/ responder machine.
if err := responder.WriteMessage(data); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Flush the encrypted message w/ responder machine.
if _, err := responder.Flush(&b); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Decrypt the ciphertext using ReadMessage w/ initiator
// machine.
plaintext, err := initiator.ReadMessage(&b)
if err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Check that the decrypted message and the original message are
// equal.
if !bytes.Equal(data, plaintext) {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -398,7 +413,7 @@ func FuzzRandomRespEncDec(f *testing.F) {
// FuzzRandomRespEncrypt fuzz tests encryption of arbitrary data with the
// responder.
func FuzzRandomRespEncrypt(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(t *testing.T, seed int64, data []byte) {
// Ensure that length of message is not greater than max allowed
// size.
if len(data) > math.MaxUint16 {
@ -406,7 +421,7 @@ func FuzzRandomRespEncrypt(f *testing.F) {
}
// This will return brontide machines with random keys.
initiator, responder := getBrontideMachines()
initiator, responder := getBrontideMachines(t, seed)
// Complete the brontide handshake.
completeHandshake(t, initiator, responder)
@ -415,12 +430,12 @@ func FuzzRandomRespEncrypt(f *testing.F) {
// Encrypt the message using WriteMessage w/ responder machine.
if err := responder.WriteMessage(data); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Flush the encrypted message w/ responder machine.
if _, err := responder.Flush(&b); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
})
}
@ -442,7 +457,7 @@ func FuzzStaticActOne(f *testing.F) {
// Responder receives ActOne, should fail.
if err := responder.RecvActOne(actOne); err == nil {
nilAndPanic(t, nil, responder, nil)
dumpAndFail(t, nil, responder, nil)
}
})
}
@ -461,12 +476,12 @@ func FuzzStaticActThree(f *testing.F) {
// Generate ActOne and send to the responder.
actOne, err := initiator.GenActOne()
if err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Receiving ActOne should succeed, so we panic on error.
if err := responder.RecvActOne(actOne); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Generate ActTwo - this is not sent to the initiator because
@ -475,7 +490,7 @@ func FuzzStaticActThree(f *testing.F) {
// the appropriate state in the responder machine.
_, err = responder.GenActTwo()
if err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Copy data into [ActThreeSize]byte.
@ -484,7 +499,7 @@ func FuzzStaticActThree(f *testing.F) {
// Responder receives ActThree, should fail.
if err := responder.RecvActThree(actThree); err == nil {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -506,7 +521,7 @@ func FuzzStaticActTwo(f *testing.F) {
// appropriate state in the initiator machine.
_, err := initiator.GenActOne()
if err != nil {
nilAndPanic(t, initiator, nil, err)
dumpAndFail(t, initiator, nil, err)
}
// Copy data into [ActTwoSize]byte.
@ -515,7 +530,7 @@ func FuzzStaticActTwo(f *testing.F) {
// Initiator receives ActTwo, should fail.
if err := initiator.RecvActTwo(actTwo); err == nil {
nilAndPanic(t, initiator, nil, nil)
dumpAndFail(t, initiator, nil, nil)
}
})
}
@ -536,7 +551,7 @@ func FuzzStaticInitDecrypt(f *testing.F) {
// Decrypt the encrypted message using ReadMessage w/ initiator
// machine.
if _, err := initiator.ReadMessage(r); err == nil {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -561,25 +576,25 @@ func FuzzStaticInitEncDec(f *testing.F) {
// Encrypt the message using WriteMessage w/ initiator machine.
if err := initiator.WriteMessage(data); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Flush the encrypted message w/ initiator machine.
if _, err := initiator.Flush(&b); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Decrypt the ciphertext using ReadMessage w/ responder
// machine.
plaintext, err := responder.ReadMessage(&b)
if err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Check that the decrypted message and the original message are
// equal.
if !bytes.Equal(data, plaintext) {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -604,12 +619,12 @@ func FuzzStaticInitEncrypt(f *testing.F) {
// Encrypt the message using WriteMessage w/ initiator machine.
if err := initiator.WriteMessage(data); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Flush the encrypted message w/ initiator machine.
if _, err := initiator.Flush(&b); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
})
}
@ -630,7 +645,7 @@ func FuzzStaticRespDecrypt(f *testing.F) {
// Decrypt the encrypted message using ReadMessage w/ responder
// machine.
if _, err := responder.ReadMessage(r); err == nil {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -655,25 +670,25 @@ func FuzzStaticRespEncDec(f *testing.F) {
// Encrypt the message using WriteMessage w/ responder machine.
if err := responder.WriteMessage(data); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Flush the encrypted message w/ responder machine.
if _, err := responder.Flush(&b); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Decrypt the ciphertext using ReadMessage w/ initiator
// machine.
plaintext, err := initiator.ReadMessage(&b)
if err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Check that the decrypted message and the original message are
// equal.
if !bytes.Equal(data, plaintext) {
nilAndPanic(t, initiator, responder, nil)
dumpAndFail(t, initiator, responder, nil)
}
})
}
@ -698,12 +713,12 @@ func FuzzStaticRespEncrypt(f *testing.F) {
// Encrypt the message using WriteMessage w/ responder machine.
if err := responder.WriteMessage(data); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
// Flush the encrypted message w/ responder machine.
if _, err := responder.Flush(&b); err != nil {
nilAndPanic(t, initiator, responder, err)
dumpAndFail(t, initiator, responder, err)
}
})
}

View File

@ -91,7 +91,7 @@ func (l *Listener) listen() {
// rejectedConnErr is a helper function that prepends the remote address of the
// failed connection attempt to the original error message.
func rejectedConnErr(err error, remoteAddr string) error {
return fmt.Errorf("unable to accept connection from %v: %v", remoteAddr,
return fmt.Errorf("unable to accept connection from %v: %w", remoteAddr,
err)
}

View File

@ -379,7 +379,7 @@ type Machine struct {
// errors that cause partial writes.
nextHeaderSend []byte
// nextHeaderBody holds a reference to the remaining body bytes to write
// nextBodySend holds a reference to the remaining body bytes to write
// out for a pending message. This allows us to tolerate timeout errors
// that cause partial writes.
nextBodySend []byte

View File

@ -148,7 +148,7 @@ func TestConnectionCorrectness(t *testing.T) {
}
}
// TestConecurrentHandshakes verifies the listener's ability to not be blocked
// TestConcurrentHandshakes verifies the listener's ability to not be blocked
// by other pending handshakes. This is tested by opening multiple tcp
// connections with the listener, without completing any of the brontide acts.
// The test passes if real brontide dialer connects while the others are
@ -274,7 +274,7 @@ func TestWriteMessageChunking(t *testing.T) {
bytesWritten, err := localConn.Write(largeMessage)
if err != nil {
errCh <- fmt.Errorf("unable to write message: %v", err)
errCh <- fmt.Errorf("unable to write message: %w", err)
return
}

View File

@ -64,13 +64,13 @@ func (r *RotatingLogWriter) InitLogRotator(logFile string, maxLogFileSize int,
logDir, _ := filepath.Split(logFile)
err := os.MkdirAll(logDir, 0700)
if err != nil {
return fmt.Errorf("failed to create log directory: %v", err)
return fmt.Errorf("failed to create log directory: %w", err)
}
r.logRotator, err = rotator.New(
logFile, int64(maxLogFileSize*1024), false, maxLogFiles,
)
if err != nil {
return fmt.Errorf("failed to create file rotator: %v", err)
return fmt.Errorf("failed to create file rotator: %w", err)
}
// Run rotator as a goroutine now but make sure we catch any errors

View File

@ -40,13 +40,13 @@ const (
AppMajor uint = 0
// AppMinor defines the minor version of this binary.
AppMinor uint = 16
AppMinor uint = 18
// AppPatch defines the application patch for this binary.
AppPatch uint = 4
// AppPreRelease MUST only contain characters from semanticAlphabet
// per the semantic versioning spec.
// AppPreRelease MUST only contain characters from semanticAlphabet per
// the semantic versioning spec.
AppPreRelease = "beta"
)

View File

@ -1,8 +1,14 @@
module github.com/lightningnetwork/lnd/cert
go 1.16
go 1.19
require github.com/stretchr/testify v1.8.2
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/stretchr/testify v1.5.1
github.com/kr/pretty v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View File

@ -1,12 +1,32 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -9,7 +9,6 @@ import (
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"io/ioutil"
"math/big"
"net"
"os"
@ -261,7 +260,7 @@ func GenCertPair(org string, tlsExtraIPs, tlsExtraDomains []string,
&template, &priv.PublicKey, priv,
)
if err != nil {
return nil, nil, fmt.Errorf("failed to create certificate: %v",
return nil, nil, fmt.Errorf("failed to create certificate: %w",
err)
}
@ -270,13 +269,13 @@ func GenCertPair(org string, tlsExtraIPs, tlsExtraDomains []string,
certBuf, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes},
)
if err != nil {
return nil, nil, fmt.Errorf("failed to encode certificate: %v",
return nil, nil, fmt.Errorf("failed to encode certificate: %w",
err)
}
keybytes, err := x509.MarshalECPrivateKey(priv)
if err != nil {
return nil, nil, fmt.Errorf("unable to encode privkey: %v",
return nil, nil, fmt.Errorf("unable to encode privkey: %w",
err)
}
keyBuf := &bytes.Buffer{}
@ -284,7 +283,7 @@ func GenCertPair(org string, tlsExtraIPs, tlsExtraDomains []string,
keyBuf, &pem.Block{Type: "EC PRIVATE KEY", Bytes: keybytes},
)
if err != nil {
return nil, nil, fmt.Errorf("failed to encode private key: %v",
return nil, nil, fmt.Errorf("failed to encode private key: %w",
err)
}
@ -295,14 +294,14 @@ func GenCertPair(org string, tlsExtraIPs, tlsExtraDomains []string,
func WriteCertPair(certFile, keyFile string, certBytes, keyBytes []byte) error {
// Write cert and key files.
if certFile != "" {
err := ioutil.WriteFile(certFile, certBytes, 0644)
err := os.WriteFile(certFile, certBytes, 0644)
if err != nil {
return err
}
}
if keyFile != "" {
err := ioutil.WriteFile(keyFile, keyBytes, 0600)
err := os.WriteFile(keyFile, keyBytes, 0600)
if err != nil {
os.Remove(certFile)
return err

View File

@ -1,7 +1,7 @@
package cert_test
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"
@ -42,10 +42,10 @@ func TestIsOutdatedCert(t *testing.T) {
// number of IPs and domains.
for numIPs := 1; numIPs <= len(extraIPs); numIPs++ {
for numDomains := 1; numDomains <= len(extraDomains); numDomains++ {
certBytes, err := ioutil.ReadFile(certPath)
certBytes, err := os.ReadFile(certPath)
require.NoError(t, err)
keyBytes, err := ioutil.ReadFile(keyPath)
keyBytes, err := os.ReadFile(keyPath)
require.NoError(t, err)
_, parsedCert, err := cert.LoadCertFromBytes(
@ -79,7 +79,7 @@ func TestIsOutdatedCert(t *testing.T) {
}
// TestIsOutdatedPermutation tests that the order of listed IPs or DNS names,
// nor dulicates in the lists, matter for whether we consider the certificate
// nor duplicates in the lists, matter for whether we consider the certificate
// outdated.
func TestIsOutdatedPermutation(t *testing.T) {
tempDir := t.TempDir()
@ -98,10 +98,10 @@ func TestIsOutdatedPermutation(t *testing.T) {
err = cert.WriteCertPair(certPath, keyPath, certBytes, keyBytes)
require.NoError(t, err)
certBytes, err = ioutil.ReadFile(certPath)
certBytes, err = os.ReadFile(certPath)
require.NoError(t, err)
keyBytes, err = ioutil.ReadFile(keyPath)
keyBytes, err = os.ReadFile(keyPath)
require.NoError(t, err)
_, parsedCert, err := cert.LoadCertFromBytes(certBytes, keyBytes)
@ -171,10 +171,10 @@ func TestTLSDisableAutofill(t *testing.T) {
require.NoError(t, err)
// Read certs from disk.
certBytes, err = ioutil.ReadFile(certPath)
certBytes, err = os.ReadFile(certPath)
require.NoError(t, err)
keyBytes, err = ioutil.ReadFile(keyPath)
keyBytes, err = os.ReadFile(keyPath)
require.NoError(t, err)
// Load the certificate.
@ -230,10 +230,10 @@ func TestTLSConfig(t *testing.T) {
err = cert.WriteCertPair(certPath, keyPath, certBytes, keyBytes)
require.NoError(t, err)
certBytes, err = ioutil.ReadFile(certPath)
certBytes, err = os.ReadFile(certPath)
require.NoError(t, err)
keyBytes, err = ioutil.ReadFile(keyPath)
keyBytes, err = os.ReadFile(keyPath)
require.NoError(t, err)
// Load the certificate.

View File

@ -3,7 +3,7 @@ package cert
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"os"
"sync"
)
@ -31,11 +31,11 @@ var (
func GetCertBytesFromPath(certPath, keyPath string) (certBytes,
keyBytes []byte, err error) {
certBytes, err = ioutil.ReadFile(certPath)
certBytes, err = os.ReadFile(certPath)
if err != nil {
return nil, nil, err
}
keyBytes, err = ioutil.ReadFile(keyPath)
keyBytes, err = os.ReadFile(keyPath)
if err != nil {
return nil, nil, err
}
@ -57,7 +57,7 @@ func LoadCert(certPath, keyPath string) (tls.Certificate, *x509.Certificate,
return tls.Certificate{}, nil, err
}
// Now parse the the PEM block of the certificate into its x509 data
// Now parse the PEM block of the certificate into its x509 data
// structure so it can be examined in more detail.
x509Cert, err := x509.ParseCertificate(certData.Certificate[0])
if err != nil {
@ -82,7 +82,7 @@ func LoadCertFromBytes(certBytes, keyBytes []byte) (tls.Certificate,
return tls.Certificate{}, nil, err
}
// Now parse the the PEM block of the certificate into its x509 data
// Now parse the PEM block of the certificate into its x509 data
// structure so it can be examined in more detail.
x509Cert, err := x509.ParseCertificate(certData.Certificate[0])
if err != nil {

View File

@ -0,0 +1,135 @@
package chainntnfs
import (
"errors"
"fmt"
"sync"
"sync/atomic"
"github.com/btcsuite/btcd/wire"
)
// BestBlockView is an interface that allows the querying of the most
// up-to-date blockchain state with low overhead. Valid implementations of this
// interface must track the latest chain state.
type BestBlockView interface {
// BestHeight gets the most recent block height known to the view.
BestHeight() (uint32, error)
// BestBlockHeader gets the most recent block header known to the view.
BestBlockHeader() (*wire.BlockHeader, error)
}
// BestBlockTracker is a tiny subsystem that tracks the blockchain tip
// and saves the most recent tip information in memory for querying. It is a
// valid implementation of BestBlockView and additionally includes
// methods for starting and stopping the system.
type BestBlockTracker struct {
notifier ChainNotifier
blockNtfnStream *BlockEpochEvent
current atomic.Pointer[BlockEpoch]
mu sync.Mutex
quit chan struct{}
wg sync.WaitGroup
}
// This is a compile time check to ensure that BestBlockTracker implements
// BestBlockView.
var _ BestBlockView = (*BestBlockTracker)(nil)
// NewBestBlockTracker creates a new BestBlockTracker that isn't running yet.
// It will not provide up to date information unless it has been started. The
// ChainNotifier parameter must also be started prior to starting the
// BestBlockTracker.
func NewBestBlockTracker(chainNotifier ChainNotifier) *BestBlockTracker {
return &BestBlockTracker{
notifier: chainNotifier,
blockNtfnStream: nil,
quit: make(chan struct{}),
}
}
// BestHeight gets the most recent block height known to the
// BestBlockTracker.
func (t *BestBlockTracker) BestHeight() (uint32, error) {
epoch := t.current.Load()
if epoch == nil {
return 0, errors.New("best block height not yet known")
}
return uint32(epoch.Height), nil
}
// BestBlockHeader gets the most recent block header known to the
// BestBlockTracker.
func (t *BestBlockTracker) BestBlockHeader() (*wire.BlockHeader, error) {
epoch := t.current.Load()
if epoch == nil {
return nil, errors.New("best block header not yet known")
}
return epoch.BlockHeader, nil
}
// updateLoop is a helper that subscribes to the underlying BlockEpochEvent
// stream and updates the internal values to match the new BlockEpochs that
// are discovered.
//
// MUST be run as a goroutine.
func (t *BestBlockTracker) updateLoop() {
defer t.wg.Done()
for {
select {
case epoch, ok := <-t.blockNtfnStream.Epochs:
if !ok {
Log.Error("dead epoch stream in " +
"BestBlockTracker")
return
}
t.current.Store(epoch)
case <-t.quit:
t.current.Store(nil)
return
}
}
}
// Start starts the BestBlockTracker. It is an error to start it if it
// is already started.
func (t *BestBlockTracker) Start() error {
t.mu.Lock()
defer t.mu.Unlock()
if t.blockNtfnStream != nil {
return fmt.Errorf("BestBlockTracker is already started")
}
var err error
t.blockNtfnStream, err = t.notifier.RegisterBlockEpochNtfn(nil)
if err != nil {
return err
}
t.wg.Add(1)
go t.updateLoop()
return nil
}
// Stop stops the BestBlockTracker. It is an error to stop it if it has
// not been started or if it has already been stopped.
func (t *BestBlockTracker) Stop() error {
t.mu.Lock()
defer t.mu.Unlock()
if t.blockNtfnStream == nil {
return fmt.Errorf("BestBlockTracker is not running")
}
close(t.quit)
t.wg.Wait()
t.blockNtfnStream.Cancel()
t.blockNtfnStream = nil
return nil
}

View File

@ -0,0 +1,112 @@
package chainntnfs_test
import (
"math/rand"
"reflect"
"testing"
"testing/quick"
"time"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/lntest/mock"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/stretchr/testify/require"
)
type blockEpoch chainntnfs.BlockEpoch
func (blockEpoch) Generate(r *rand.Rand, size int) reflect.Value {
var chainHash, prevBlockHash, merkleRootHash chainhash.Hash
r.Read(chainHash[:])
r.Read(prevBlockHash[:])
r.Read(merkleRootHash[:])
return reflect.ValueOf(blockEpoch(chainntnfs.BlockEpoch{
Hash: &chainHash,
Height: r.Int31n(1000000),
BlockHeader: &wire.BlockHeader{
Version: 2,
PrevBlock: prevBlockHash,
MerkleRoot: merkleRootHash,
Timestamp: time.Now(),
Bits: r.Uint32(),
Nonce: r.Uint32(),
},
}))
}
// TestBestBlockTracker ensures that the most recent event pushed on the
// underlying EpochChan is remembered by the BestBlockView functions as well
// as testing the idempotence of the BestBlockView interface.
func TestBestBlockTracker(t *testing.T) {
t.Parallel()
notifier := &mock.ChainNotifier{
SpendChan: nil,
EpochChan: make(chan *chainntnfs.BlockEpoch),
ConfChan: nil,
}
chainNotifierI := chainntnfs.ChainNotifier(notifier)
tracker := chainntnfs.NewBestBlockTracker(chainNotifierI)
require.Nil(t, tracker.Start(),
"BestBlockTacker could not be started")
// we have to limit test cases because the poll interval of
// wait.Predicate isn't tight enough to support the usual 100
cfg := quick.Config{MaxCount: 50}
correctness := func(epochRand blockEpoch) bool {
epoch := chainntnfs.BlockEpoch(epochRand)
notifier.EpochChan <- &epoch
// wait for new block to propagate
err := wait.Predicate(
func() bool {
_, err := tracker.BestHeight()
return err == nil
},
1*time.Second,
)
require.Nil(t, err,
"BestBlockTracker: block propagation timeout")
height, _ := tracker.BestHeight()
header, _ := tracker.BestBlockHeader()
return height == uint32(epoch.Height) &&
header == epoch.BlockHeader
}
idempotence := func(epochRand blockEpoch) bool {
epoch := chainntnfs.BlockEpoch(epochRand)
notifier.EpochChan <- &epoch
// wait for new block to propagate
err := wait.Predicate(
func() bool {
_, err := tracker.BestHeight()
return err == nil
},
1*time.Second,
)
require.Nil(t, err,
"ChainStateTracker: block propagation timeout")
height0, _ := tracker.BestHeight()
height1, _ := tracker.BestHeight()
header0, _ := tracker.BestBlockHeader()
header1, _ := tracker.BestBlockHeader()
return height0 == height1 && header0 == header1
}
err := quick.Check(correctness, &cfg)
require.Nil(t, err,
"ChainStateTracker does not give up to date info: %v", err)
require.Nil(t, quick.Check(idempotence, &cfg),
"ChainStateTracker is not idempotent")
require.Nil(t, tracker.Stop(), "ChainStateTracker could not be stopped")
}

View File

@ -15,6 +15,7 @@ import (
"github.com/btcsuite/btcwallet/chain"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/queue"
)
@ -132,7 +133,8 @@ func (b *BitcoindNotifier) Stop() error {
return nil
}
chainntnfs.Log.Info("bitcoind notifier shutting down")
chainntnfs.Log.Info("bitcoind notifier shutting down...")
defer chainntnfs.Log.Debug("bitcoind notifier shutdown complete")
// Shutdown the rpc client, this gracefully disconnects from bitcoind,
// and cleans up all related resources.
@ -149,7 +151,12 @@ func (b *BitcoindNotifier) Stop() error {
close(epochClient.epochChan)
}
b.txNotifier.TearDown()
// The txNotifier is only initialized in the start method therefore we
// need to make sure we don't access a nil pointer here.
if b.txNotifier != nil {
b.txNotifier.TearDown()
}
// Stop the mempool notifier.
b.memNotifier.TearDown()
@ -486,7 +493,12 @@ func (b *BitcoindNotifier) handleRelevantTx(tx *btcutil.Tx,
// If this is a mempool spend, we'll ask the mempool notifier to hanlde
// it.
if mempool {
b.memNotifier.ProcessRelevantSpendTx(tx)
err := b.memNotifier.ProcessRelevantSpendTx(tx)
if err != nil {
chainntnfs.Log.Errorf("Unable to process transaction "+
"%v: %v", tx.Hash(), err)
}
return
}
@ -607,7 +619,7 @@ func (b *BitcoindNotifier) confDetailsManually(confRequest chainntnfs.ConfReques
}
return &chainntnfs.TxConfirmation{
Tx: tx,
Tx: tx.Copy(),
BlockHash: blockHash,
BlockHeight: height,
TxIndex: uint32(txIndex),
@ -630,7 +642,7 @@ func (b *BitcoindNotifier) handleBlockConnected(block chainntnfs.BlockEpoch) err
// clients.
rawBlock, err := b.GetBlock(block.Hash)
if err != nil {
return fmt.Errorf("unable to get block: %v", err)
return fmt.Errorf("unable to get block: %w", err)
}
utilBlock := btcutil.NewBlock(rawBlock)
@ -639,7 +651,7 @@ func (b *BitcoindNotifier) handleBlockConnected(block chainntnfs.BlockEpoch) err
// us.
err = b.txNotifier.ConnectTip(utilBlock, uint32(block.Height))
if err != nil {
return fmt.Errorf("unable to connect tip: %v", err)
return fmt.Errorf("unable to connect tip: %w", err)
}
chainntnfs.Log.Infof("New block: height=%v, sha=%v", block.Height,
@ -713,7 +725,8 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
pkScript, b.chainParams,
)
if err != nil {
return nil, fmt.Errorf("unable to parse script: %v", err)
return nil, fmt.Errorf("unable to parse script: %w",
err)
}
if err := b.chainConn.NotifyReceived(addrs); err != nil {
return nil, err
@ -785,8 +798,8 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
// proceed with fallback methods.
jsonErr, ok := err.(*btcjson.RPCError)
if !ok || jsonErr.Code != btcjson.ErrRPCNoTxInfo {
return nil, fmt.Errorf("unable to query for txid %v: %v",
outpoint.Hash, err)
return nil, fmt.Errorf("unable to query for txid "+
"%v: %w", outpoint.Hash, err)
}
}
@ -868,11 +881,13 @@ func (b *BitcoindNotifier) historicalSpendDetails(
continue
}
txHash := tx.TxHash()
txCopy := tx.Copy()
txHash := txCopy.TxHash()
spendOutPoint := &txCopy.TxIn[inputIdx].PreviousOutPoint
return &chainntnfs.SpendDetail{
SpentOutPoint: &tx.TxIn[inputIdx].PreviousOutPoint,
SpentOutPoint: spendOutPoint,
SpenderTxHash: &txHash,
SpendingTx: tx,
SpendingTx: txCopy,
SpenderInputIndex: inputIdx,
SpendingHeight: int32(height),
}, nil
@ -1061,3 +1076,26 @@ func (b *BitcoindNotifier) CancelMempoolSpendEvent(
b.memNotifier.UnsubscribeEvent(sub)
}
// LookupInputMempoolSpend takes an outpoint and queries the mempool to find
// its spending tx. Returns the tx if found, otherwise fn.None.
//
// NOTE: part of the MempoolWatcher interface.
func (b *BitcoindNotifier) LookupInputMempoolSpend(
op wire.OutPoint) fn.Option[wire.MsgTx] {
// Find the spending txid.
txid, found := b.chainConn.LookupInputMempoolSpend(op)
if !found {
return fn.None[wire.MsgTx]()
}
// Query the spending tx using the id.
tx, err := b.chainConn.GetRawTransaction(&txid)
if err != nil {
// TODO(yy): enable logging errors in this package.
return fn.None[wire.MsgTx]()
}
return fn.Some(*tx.MsgTx().Copy())
}

View File

@ -5,6 +5,7 @@ package bitcoindnotify
import (
"bytes"
"fmt"
"testing"
"time"
@ -14,6 +15,8 @@ import (
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lntest/unittest"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/stretchr/testify/require"
)
@ -59,7 +62,7 @@ func setUpNotifier(t *testing.T, bitcoindConn *chain.BitcoindConn,
t.Helper()
notifier := New(
bitcoindConn, chainntnfs.NetParams, spendHintCache,
bitcoindConn, unittest.NetParams, spendHintCache,
confirmHintCache, blockCache,
)
if err := notifier.Start(); err != nil {
@ -90,6 +93,9 @@ func syncNotifierWithMiner(t *testing.T, notifier *BitcoindNotifier,
"height: %v", err)
}
t.Logf("miner height=%v, bitcoind height=%v", minerHeight,
bitcoindHeight)
if bitcoindHeight == minerHeight {
return uint32(bitcoindHeight)
}
@ -97,7 +103,9 @@ func syncNotifierWithMiner(t *testing.T, notifier *BitcoindNotifier,
select {
case <-time.After(100 * time.Millisecond):
case <-timeout:
t.Fatalf("timed out waiting to sync notifier")
t.Fatalf("timed out in syncNotifierWithMiner, got "+
"err=%v, minerHeight=%v, bitcoindHeight=%v",
err, minerHeight, bitcoindHeight)
}
}
}
@ -117,12 +125,12 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) {
}
func testHistoricalConfDetailsTxIndex(t *testing.T, rpcPolling bool) {
miner := chainntnfs.NewMiner(
t, []string{"--txindex"}, true, 25,
miner := unittest.NewMiner(
t, unittest.NetParams, []string{"--txindex"}, true, 25,
)
bitcoindConn := chainntnfs.NewBitcoindBackend(
t, miner.P2PAddress(), true, rpcPolling,
bitcoindConn := unittest.NewBitcoindBackend(
t, unittest.NetParams, miner.P2PAddress(), true, rpcPolling,
)
hintCache := initHintCache(t)
@ -162,18 +170,21 @@ func testHistoricalConfDetailsTxIndex(t *testing.T, rpcPolling bool) {
confReq, err := chainntnfs.NewConfRequest(txid, pkScript)
require.NoError(t, err, "unable to create conf request")
// The transaction should be found in the mempool at this point.
_, txStatus, err = notifier.historicalConfDetails(confReq, 0, 0)
require.NoError(t, err, "unable to retrieve historical conf details")
// The transaction should be found in the mempool at this point. We use
// wait here to give miner some time to propagate the tx to our node.
err = wait.NoError(func() error {
// The call should return no error.
_, txStatus, err = notifier.historicalConfDetails(confReq, 0, 0)
require.NoError(t, err)
// Since it has yet to be included in a block, it should have been found
// within the mempool.
switch txStatus {
case chainntnfs.TxFoundMempool:
default:
t.Fatalf("should have found the transaction within the "+
"mempool, but did not: %v", txStatus)
}
if txStatus != chainntnfs.TxFoundMempool {
return fmt.Errorf("cannot the tx in mempool, status "+
"is: %v", txStatus)
}
return nil
}, wait.DefaultTimeout)
require.NoError(t, err, "timeout waitinfg for historicalConfDetails")
if _, err := miner.Client.Generate(1); err != nil {
t.Fatalf("unable to generate block: %v", err)
@ -212,10 +223,10 @@ func TestHistoricalConfDetailsNoTxIndex(t *testing.T) {
}
func testHistoricalConfDetailsNoTxIndex(t *testing.T, rpcpolling bool) {
miner := chainntnfs.NewMiner(t, nil, true, 25)
miner := unittest.NewMiner(t, unittest.NetParams, nil, true, 25)
bitcoindConn := chainntnfs.NewBitcoindBackend(
t, miner.P2PAddress(), false, rpcpolling,
bitcoindConn := unittest.NewBitcoindBackend(
t, unittest.NetParams, miner.P2PAddress(), false, rpcpolling,
)
hintCache := initHintCache(t)

View File

@ -14,8 +14,10 @@ import (
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/chain"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/queue"
)
@ -58,7 +60,7 @@ type BtcdNotifier struct {
active int32 // To be used atomically.
stopped int32 // To be used atomically.
chainConn *rpcclient.Client
chainConn *chain.RPCClient
chainParams *chaincfg.Params
notificationCancels chan interface{}
@ -127,21 +129,30 @@ func New(config *rpcclient.ConnConfig, chainParams *chaincfg.Params,
quit: make(chan struct{}),
}
// Disable connecting to btcd within the rpcclient.New method. We
// defer establishing the connection to our .Start() method.
config.DisableConnectOnNew = true
config.DisableAutoReconnect = false
ntfnCallbacks := &rpcclient.NotificationHandlers{
OnBlockConnected: notifier.onBlockConnected,
OnBlockDisconnected: notifier.onBlockDisconnected,
OnRedeemingTx: notifier.onRedeemingTx,
}
// Disable connecting to btcd within the rpcclient.New method. We
// defer establishing the connection to our .Start() method.
config.DisableConnectOnNew = true
config.DisableAutoReconnect = false
chainConn, err := rpcclient.New(config, ntfnCallbacks)
rpcCfg := &chain.RPCClientConfig{
ReconnectAttempts: 20,
Conn: config,
Chain: chainParams,
NotificationHandlers: ntfnCallbacks,
}
chainRPC, err := chain.NewRPCClientWithConfig(rpcCfg)
if err != nil {
return nil, err
}
notifier.chainConn = chainConn
notifier.chainConn = chainRPC
return notifier, nil
}
@ -169,7 +180,8 @@ func (b *BtcdNotifier) Stop() error {
return nil
}
chainntnfs.Log.Info("btcd notifier shutting down")
chainntnfs.Log.Info("btcd notifier shutting down...")
defer chainntnfs.Log.Debug("btcd notifier shutdown complete")
// Shutdown the rpc client, this gracefully disconnects from btcd, and
// cleans up all related resources.
@ -535,7 +547,12 @@ func (b *BtcdNotifier) handleRelevantTx(tx *btcutil.Tx,
// If this is a mempool spend, we'll ask the mempool notifier to hanlde
// it.
if mempool {
b.memNotifier.ProcessRelevantSpendTx(tx)
err := b.memNotifier.ProcessRelevantSpendTx(tx)
if err != nil {
chainntnfs.Log.Errorf("Unable to process transaction "+
"%v: %v", tx.Hash(), err)
}
return
}
@ -661,7 +678,7 @@ func (b *BtcdNotifier) confDetailsManually(confRequest chainntnfs.ConfRequest,
}
return &chainntnfs.TxConfirmation{
Tx: tx,
Tx: tx.Copy(),
BlockHash: blockHash,
BlockHeight: height,
TxIndex: uint32(txIndex),
@ -686,7 +703,7 @@ func (b *BtcdNotifier) handleBlockConnected(epoch chainntnfs.BlockEpoch) error {
// clients.
rawBlock, err := b.GetBlock(epoch.Hash)
if err != nil {
return fmt.Errorf("unable to get block: %v", err)
return fmt.Errorf("unable to get block: %w", err)
}
newBlock := &filteredBlock{
hash: *epoch.Hash,
@ -700,7 +717,7 @@ func (b *BtcdNotifier) handleBlockConnected(epoch chainntnfs.BlockEpoch) error {
// us.
err = b.txNotifier.ConnectTip(newBlock.block, newBlock.height)
if err != nil {
return fmt.Errorf("unable to connect tip: %v", err)
return fmt.Errorf("unable to connect tip: %w", err)
}
chainntnfs.Log.Infof("New block: height=%v, sha=%v", epoch.Height,
@ -779,7 +796,8 @@ func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
pkScript, b.chainParams,
)
if err != nil {
return nil, fmt.Errorf("unable to parse script: %v", err)
return nil, fmt.Errorf("unable to parse script: %w",
err)
}
if err := b.chainConn.NotifyReceived(addrs); err != nil {
return nil, err
@ -817,7 +835,8 @@ func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
pkScript, b.chainParams,
)
if err != nil {
return nil, fmt.Errorf("unable to parse address: %v", err)
return nil, fmt.Errorf("unable to parse address: %w",
err)
}
asyncResult := b.chainConn.RescanAsync(startHash, addrs, nil)
@ -878,8 +897,8 @@ func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
// proceed with fallback methods.
jsonErr, ok := err.(*btcjson.RPCError)
if !ok || jsonErr.Code != btcjson.ErrRPCNoTxInfo {
return nil, fmt.Errorf("unable to query for txid %v: %v",
outpoint.Hash, err)
return nil, fmt.Errorf("unable to query for txid %v: "+
"%w", outpoint.Hash, err)
}
}
@ -1119,3 +1138,26 @@ func (b *BtcdNotifier) CancelMempoolSpendEvent(
b.memNotifier.UnsubscribeEvent(sub)
}
// LookupInputMempoolSpend takes an outpoint and queries the mempool to find
// its spending tx. Returns the tx if found, otherwise fn.None.
//
// NOTE: part of the MempoolWatcher interface.
func (b *BtcdNotifier) LookupInputMempoolSpend(
op wire.OutPoint) fn.Option[wire.MsgTx] {
// Find the spending txid.
txid, found := b.chainConn.LookupInputMempoolSpend(op)
if !found {
return fn.None[wire.MsgTx]()
}
// Query the spending tx using the id.
tx, err := b.chainConn.GetRawTransaction(&txid)
if err != nil {
// TODO(yy): enable logging errors in this package.
return fn.None[wire.MsgTx]()
}
return fn.Some(*tx.MsgTx().Copy())
}

View File

@ -12,6 +12,7 @@ import (
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lntest/unittest"
"github.com/stretchr/testify/require"
)
@ -55,7 +56,7 @@ func setUpNotifier(t *testing.T, h *rpctest.Harness) *BtcdNotifier {
rpcCfg := h.RPCConfig()
notifier, err := New(
&rpcCfg, chainntnfs.NetParams, hintCache, hintCache, blockCache,
&rpcCfg, unittest.NetParams, hintCache, hintCache, blockCache,
)
require.NoError(t, err, "unable to create notifier")
if err := notifier.Start(); err != nil {
@ -73,8 +74,8 @@ func setUpNotifier(t *testing.T, h *rpctest.Harness) *BtcdNotifier {
func TestHistoricalConfDetailsTxIndex(t *testing.T) {
t.Parallel()
harness := chainntnfs.NewMiner(
t, []string{"--txindex"}, true, 25,
harness := unittest.NewMiner(
t, unittest.NetParams, []string{"--txindex"}, true, 25,
)
notifier := setUpNotifier(t, harness)
@ -145,7 +146,7 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) {
func TestHistoricalConfDetailsNoTxIndex(t *testing.T) {
t.Parallel()
harness := chainntnfs.NewMiner(t, nil, true, 25)
harness := unittest.NewMiner(t, unittest.NetParams, nil, true, 25)
notifier := setUpNotifier(t, harness)

View File

@ -13,6 +13,7 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn"
)
var (
@ -278,6 +279,34 @@ type SpendDetail struct {
SpendingHeight int32
}
// HasSpenderWitness returns true if the spending transaction has non-empty
// witness.
func (s *SpendDetail) HasSpenderWitness() bool {
tx := s.SpendingTx
// If there are no inputs, then there is no witness.
if len(tx.TxIn) == 0 {
return false
}
// If the spender input index is larger than the number of inputs, then
// we don't have a witness and this is an error case so we log it.
if uint32(len(tx.TxIn)) <= s.SpenderInputIndex {
Log.Errorf("SpenderInputIndex %d is out of range for tx %v",
s.SpenderInputIndex, tx.TxHash())
return false
}
// If the witness is empty, then there is no witness.
if len(tx.TxIn[s.SpenderInputIndex].Witness) == 0 {
return false
}
// If the witness is non-empty, then we have a witness.
return true
}
// String returns a string representation of SpendDetail.
func (s *SpendDetail) String() string {
return fmt.Sprintf("%v[%d] spending %v at height=%v", s.SpenderTxHash,
@ -455,13 +484,13 @@ func GetCommonBlockAncestorHeight(chainConn ChainConn, reorgHash,
for reorgHash != chainHash {
reorgHeader, err := chainConn.GetBlockHeader(&reorgHash)
if err != nil {
return 0, fmt.Errorf("unable to get header for hash=%v: %v",
reorgHash, err)
return 0, fmt.Errorf("unable to get header for "+
"hash=%v: %w", reorgHash, err)
}
chainHeader, err := chainConn.GetBlockHeader(&chainHash)
if err != nil {
return 0, fmt.Errorf("unable to get header for hash=%v: %v",
chainHash, err)
return 0, fmt.Errorf("unable to get header for "+
"hash=%v: %w", chainHash, err)
}
reorgHash = reorgHeader.PrevBlock
chainHash = chainHeader.PrevBlock
@ -469,8 +498,8 @@ func GetCommonBlockAncestorHeight(chainConn ChainConn, reorgHash,
verboseHeader, err := chainConn.GetBlockHeaderVerbose(&chainHash)
if err != nil {
return 0, fmt.Errorf("unable to get verbose header for hash=%v: %v",
chainHash, err)
return 0, fmt.Errorf("unable to get verbose header for "+
"hash=%v: %w", chainHash, err)
}
return verboseHeader.Height, nil
@ -513,7 +542,7 @@ func GetClientMissedBlocks(chainConn ChainConn, clientBestBlock *BlockEpoch,
chainConn, startingHeight+1, notifierBestHeight+1,
)
if err != nil {
return nil, fmt.Errorf("unable to get missed blocks: %v", err)
return nil, fmt.Errorf("unable to get missed blocks: %w", err)
}
return missedBlocks, nil
@ -691,7 +720,7 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest,
}
return nil, TxNotFoundIndex,
fmt.Errorf("unable to query for txid %v: %v",
fmt.Errorf("unable to query for txid %v: %w",
r.TxID, err)
}
@ -700,13 +729,13 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest,
rawTx, err := hex.DecodeString(rawTxRes.Hex)
if err != nil {
return nil, TxNotFoundIndex,
fmt.Errorf("unable to deserialize tx %v: %v",
fmt.Errorf("unable to deserialize tx %v: %w",
r.TxID, err)
}
var tx wire.MsgTx
if err := tx.Deserialize(bytes.NewReader(rawTx)); err != nil {
return nil, TxNotFoundIndex,
fmt.Errorf("unable to deserialize tx %v: %v",
fmt.Errorf("unable to deserialize tx %v: %w",
r.TxID, err)
}
@ -731,13 +760,14 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest,
if err != nil {
return nil, TxNotFoundIndex,
fmt.Errorf("unable to get block hash %v for "+
"historical dispatch: %v", rawTxRes.BlockHash, err)
"historical dispatch: %w", rawTxRes.BlockHash,
err)
}
block, err := chainConn.GetBlock(blockHash)
if err != nil {
return nil, TxNotFoundIndex,
fmt.Errorf("unable to get block with hash %v for "+
"historical dispatch: %v", blockHash, err)
"historical dispatch: %w", blockHash, err)
}
// In the modern chain (the only one we really care about for LN), the
@ -760,7 +790,7 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest,
}
return &TxConfirmation{
Tx: &tx,
Tx: tx.Copy(),
BlockHash: blockHash,
BlockHeight: uint32(blockHeight),
TxIndex: uint32(txIndex),
@ -820,4 +850,9 @@ type MempoolWatcher interface {
// CancelMempoolSpendEvent allows the caller to cancel a subscription to
// watch for a spend of an outpoint in the mempool.
CancelMempoolSpendEvent(sub *MempoolSpendEvent)
// LookupInputMempoolSpend looks up the mempool to find a spending tx
// which spends the given outpoint. A fn.None is returned if it's not
// found.
LookupInputMempoolSpend(op wire.OutPoint) fn.Option[wire.MsgTx]
}

View File

@ -146,7 +146,13 @@ func (m *MempoolNotifier) UnsubsribeConfirmedSpentTx(tx *btcutil.Tx) {
Log.Tracef("Unsubscribe confirmed tx %s", tx.Hash())
// Get the spent inputs of interest.
spentInputs := m.findRelevantInputs(tx)
spentInputs, err := m.findRelevantInputs(tx)
if err != nil {
Log.Errorf("Unable to find relevant inputs for tx %s: %v",
tx.Hash(), err)
return
}
// Unsubscribe the subscribers.
for outpoint := range spentInputs {
@ -160,27 +166,36 @@ func (m *MempoolNotifier) UnsubsribeConfirmedSpentTx(tx *btcutil.Tx) {
// ProcessRelevantSpendTx takes a transaction and checks whether it spends any
// of the subscribed inputs. If so, spend notifications are sent to the
// relevant subscribers.
func (m *MempoolNotifier) ProcessRelevantSpendTx(tx *btcutil.Tx) {
func (m *MempoolNotifier) ProcessRelevantSpendTx(tx *btcutil.Tx) error {
Log.Tracef("Processing mempool tx %s", tx.Hash())
defer Log.Tracef("Finished processing mempool tx %s", tx.Hash())
// Get the spent inputs of interest.
spentInputs := m.findRelevantInputs(tx)
spentInputs, err := m.findRelevantInputs(tx)
if err != nil {
return err
}
// Notify the subscribers.
m.notifySpent(spentInputs)
return nil
}
// TearDown stops the notifier and cleans up resources.
func (m *MempoolNotifier) TearDown() {
Log.Infof("Stopping mempool notifier")
defer Log.Debug("mempool notifier stopped")
close(m.quit)
m.wg.Wait()
}
// findRelevantInputs takes a transaction to find the subscribed inputs and
// returns them.
func (m *MempoolNotifier) findRelevantInputs(tx *btcutil.Tx) inputsWithTx {
func (m *MempoolNotifier) findRelevantInputs(tx *btcutil.Tx) (inputsWithTx,
error) {
txid := tx.Hash()
watchedInputs := make(inputsWithTx)
@ -207,9 +222,23 @@ func (m *MempoolNotifier) findRelevantInputs(tx *btcutil.Tx) inputsWithTx {
SpendingHeight: 0,
}
watchedInputs[*op] = details
// Sanity check the witness stack. If it's not empty, continue
// to next iteration.
if details.HasSpenderWitness() {
continue
}
// Return an error if the witness data is not present in the
// spending transaction.
Log.Criticalf("Found spending tx for outpoint=%v in mempool, "+
"but the transaction %v does not have witness",
op, details.SpendingTx.TxHash())
return nil, ErrEmptyWitnessStack
}
return watchedInputs
return watchedInputs, nil
}
// notifySpent iterates all the spentInputs and notifies the subscribers about

View File

@ -11,6 +11,9 @@ import (
const testTimeout = 5 * time.Second
// dummyWitness is used to fill the witness data in a transaction.
var dummyWitness = [][]byte{{0x01}}
// TestMempoolSubscribeInput tests that we can successfully subscribe an input.
func TestMempoolSubscribeInput(t *testing.T) {
t.Parallel()
@ -107,9 +110,9 @@ func TestMempoolUnsubscribeEvent(t *testing.T) {
require.True(t, loaded)
}
// TestMempoolFindRelevantInputs tests that the mempool notifier can find the
// spend of subscribed inputs from a given transaction.
func TestMempoolFindRelevantInputs(t *testing.T) {
// TestMempoolFindRelevantInputsEmptyWitness tests that the mempool notifier
// returns an error when the witness stack is empty.
func TestMempoolFindRelevantInputsEmptyWitness(t *testing.T) {
t.Parallel()
// Create a new mempool notifier instance.
@ -132,6 +135,37 @@ func TestMempoolFindRelevantInputs(t *testing.T) {
}
tx := btcutil.NewTx(msgTx)
// Call the method.
result, err := notifier.findRelevantInputs(tx)
require.ErrorIs(t, err, ErrEmptyWitnessStack)
require.Nil(t, result)
}
// TestMempoolFindRelevantInputs tests that the mempool notifier can find the
// spend of subscribed inputs from a given transaction.
func TestMempoolFindRelevantInputs(t *testing.T) {
t.Parallel()
// Create a new mempool notifier instance.
notifier := NewMempoolNotifier()
// Create two inputs and subscribe to the second one.
input1 := wire.OutPoint{Hash: [32]byte{1}}
input2 := wire.OutPoint{Hash: [32]byte{2}}
// Make input2 the subscribed input.
notifier.SubscribeInput(input2)
// Create a transaction that spends the above two inputs.
msgTx := &wire.MsgTx{
TxIn: []*wire.TxIn{
{PreviousOutPoint: input1, Witness: dummyWitness},
{PreviousOutPoint: input2, Witness: dummyWitness},
},
TxOut: []*wire.TxOut{},
}
tx := btcutil.NewTx(msgTx)
// Create the expected spend detail.
detailExp := &SpendDetail{
SpentOutPoint: &input2,
@ -141,7 +175,8 @@ func TestMempoolFindRelevantInputs(t *testing.T) {
}
// Call the method.
result := notifier.findRelevantInputs(tx)
result, err := notifier.findRelevantInputs(tx)
require.NoError(t, err)
// Verify that the result is as expected.
require.Contains(t, result, input2)
@ -365,7 +400,7 @@ func TestMempoolUnsubscribeConfirmedSpentTx(t *testing.T) {
// Create a transaction that spends input1.
msgTx := &wire.MsgTx{
TxIn: []*wire.TxIn{
{PreviousOutPoint: input1},
{PreviousOutPoint: input1, Witness: dummyWitness},
},
}
tx := btcutil.NewTx(msgTx)

123
chainntnfs/mocks.go Normal file
View File

@ -0,0 +1,123 @@
package chainntnfs
import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn"
"github.com/stretchr/testify/mock"
)
// MockMempoolWatcher is a mock implementation of the MempoolWatcher interface.
// This is used by other subsystems to mock the behavior of the mempool
// watcher.
type MockMempoolWatcher struct {
mock.Mock
}
// NewMockMempoolWatcher returns a new instance of a mock mempool watcher.
func NewMockMempoolWatcher() *MockMempoolWatcher {
return &MockMempoolWatcher{}
}
// Compile-time check to ensure MockMempoolWatcher implements MempoolWatcher.
var _ MempoolWatcher = (*MockMempoolWatcher)(nil)
// SubscribeMempoolSpent implements the MempoolWatcher interface.
func (m *MockMempoolWatcher) SubscribeMempoolSpent(
op wire.OutPoint) (*MempoolSpendEvent, error) {
args := m.Called(op)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*MempoolSpendEvent), args.Error(1)
}
// CancelMempoolSpendEvent implements the MempoolWatcher interface.
func (m *MockMempoolWatcher) CancelMempoolSpendEvent(
sub *MempoolSpendEvent) {
m.Called(sub)
}
// LookupInputMempoolSpend looks up the mempool to find a spending tx which
// spends the given outpoint.
func (m *MockMempoolWatcher) LookupInputMempoolSpend(
op wire.OutPoint) fn.Option[wire.MsgTx] {
args := m.Called(op)
return args.Get(0).(fn.Option[wire.MsgTx])
}
// MockNotifier is a mock implementation of the ChainNotifier interface.
type MockChainNotifier struct {
mock.Mock
}
// Compile-time check to ensure MockChainNotifier implements ChainNotifier.
var _ ChainNotifier = (*MockChainNotifier)(nil)
// RegisterConfirmationsNtfn registers an intent to be notified once txid
// reaches numConfs confirmations.
func (m *MockChainNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
pkScript []byte, numConfs, heightHint uint32,
opts ...NotifierOption) (*ConfirmationEvent, error) {
args := m.Called(txid, pkScript, numConfs, heightHint)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*ConfirmationEvent), args.Error(1)
}
// RegisterSpendNtfn registers an intent to be notified once the target
// outpoint is successfully spent within a transaction.
func (m *MockChainNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
pkScript []byte, heightHint uint32) (*SpendEvent, error) {
args := m.Called(outpoint, pkScript, heightHint)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*SpendEvent), args.Error(1)
}
// RegisterBlockEpochNtfn registers an intent to be notified of each new block
// connected to the tip of the main chain.
func (m *MockChainNotifier) RegisterBlockEpochNtfn(epoch *BlockEpoch) (
*BlockEpochEvent, error) {
args := m.Called(epoch)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*BlockEpochEvent), args.Error(1)
}
// Start the ChainNotifier. Once started, the implementation should be ready,
// and able to receive notification registrations from clients.
func (m *MockChainNotifier) Start() error {
args := m.Called()
return args.Error(0)
}
// Started returns true if this instance has been started, and false otherwise.
func (m *MockChainNotifier) Started() bool {
args := m.Called()
return args.Bool(0)
}
// Stops the concrete ChainNotifier.
func (m *MockChainNotifier) Stop() error {
args := m.Called()
return args.Error(0)
}

View File

@ -136,7 +136,8 @@ func (n *NeutrinoNotifier) Stop() error {
return nil
}
chainntnfs.Log.Info("neutrino notifier shutting down")
chainntnfs.Log.Info("neutrino notifier shutting down...")
defer chainntnfs.Log.Debug("neutrino notifier shutdown complete")
close(n.quit)
n.wg.Wait()
@ -151,7 +152,12 @@ func (n *NeutrinoNotifier) Stop() error {
close(epochClient.epochChan)
}
n.txNotifier.TearDown()
// The txNotifier is only initialized in the start method therefore we
// need to make sure we don't access a nil pointer here.
if n.txNotifier != nil {
n.txNotifier.TearDown()
}
return nil
}
@ -581,8 +587,8 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ
// can compute the current block hash.
blockHash, err := n.p2pNode.GetBlockHash(int64(scanHeight))
if err != nil {
return nil, fmt.Errorf("unable to get header for height=%v: %v",
scanHeight, err)
return nil, fmt.Errorf("unable to get header for "+
"height=%v: %w", scanHeight, err)
}
// With the hash computed, we can now fetch the basic filter for this
@ -599,8 +605,8 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ
neutrino.MaxBatchSize(int64(scanHeight-startHeight+1)),
)
if err != nil {
return nil, fmt.Errorf("unable to retrieve regular filter for "+
"height=%v: %v", scanHeight, err)
return nil, fmt.Errorf("unable to retrieve regular "+
"filter for height=%v: %w", scanHeight, err)
}
// In the case that the filter exists, we'll attempt to see if
@ -608,7 +614,8 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ
key := builder.DeriveKey(blockHash)
match, err := regFilter.Match(key, confRequest.PkScript.Script())
if err != nil {
return nil, fmt.Errorf("unable to query filter: %v", err)
return nil, fmt.Errorf("unable to query filter: %w",
err)
}
// If there's no match, then we can continue forward to the
@ -622,7 +629,8 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ
// to send the proper response.
block, err := n.GetBlock(*blockHash)
if err != nil {
return nil, fmt.Errorf("unable to get block from network: %v", err)
return nil, fmt.Errorf("unable to get block from "+
"network: %w", err)
}
// For every transaction in the block, check which one matches
@ -634,7 +642,7 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ
}
return &chainntnfs.TxConfirmation{
Tx: tx.MsgTx(),
Tx: tx.MsgTx().Copy(),
BlockHash: blockHash,
BlockHeight: scanHeight,
TxIndex: uint32(i),
@ -662,11 +670,11 @@ func (n *NeutrinoNotifier) handleBlockConnected(newBlock *filteredBlock) error {
// result in the items we care about being dispatched.
rawBlock, err := n.GetBlock(newBlock.hash)
if err != nil {
return fmt.Errorf("unable to get full block: %v", err)
return fmt.Errorf("unable to get full block: %w", err)
}
err = n.txNotifier.ConnectTip(rawBlock, newBlock.height)
if err != nil {
return fmt.Errorf("unable to connect tip: %v", err)
return fmt.Errorf("unable to connect tip: %w", err)
}
chainntnfs.Log.Infof("New block: height=%v, sha=%v", newBlock.height,
@ -691,7 +699,7 @@ func (n *NeutrinoNotifier) handleBlockConnected(newBlock *filteredBlock) error {
func (n *NeutrinoNotifier) getFilteredBlock(epoch chainntnfs.BlockEpoch) (*filteredBlock, error) {
rawBlock, err := n.GetBlock(*epoch.Hash)
if err != nil {
return nil, fmt.Errorf("unable to get block: %v", err)
return nil, fmt.Errorf("unable to get block: %w", err)
}
txns := rawBlock.Transactions()
@ -799,7 +807,7 @@ func (n *NeutrinoNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
return nil, chainntnfs.ErrChainNotifierShuttingDown
}
if err != nil {
return nil, fmt.Errorf("unable to update filter: %v", err)
return nil, fmt.Errorf("unable to update filter: %w", err)
}
// If the txNotifier didn't return any details to perform a historical
@ -936,7 +944,7 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
params := n.p2pNode.ChainParams()
_, addrs, _, err := txscript.ExtractPkScriptAddrs(pkScript, &params)
if err != nil {
return nil, fmt.Errorf("unable to extract script: %v", err)
return nil, fmt.Errorf("unable to extract script: %w", err)
}
// We'll send the filter update request to the notifier's main event
@ -961,7 +969,7 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
return nil, chainntnfs.ErrChainNotifierShuttingDown
}
if err != nil {
return nil, fmt.Errorf("unable to update filter: %v", err)
return nil, fmt.Errorf("unable to update filter: %w", err)
}
// If a historical rescan was not requested by the txNotifier, then we

View File

@ -25,6 +25,8 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs/btcdnotify"
"github.com/lightningnetwork/lnd/chainntnfs/neutrinonotify"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lntest/unittest"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/stretchr/testify/require"
)
@ -1042,14 +1044,9 @@ func testReorgConf(miner *rpctest.Harness,
notifier chainntnfs.TestChainNotifier, scriptDispatch bool, t *testing.T) {
// Set up a new miner that we can use to cause a reorg.
miner2, err := rpctest.New(
chainntnfs.NetParams, nil, []string{"--txindex"}, "",
miner2 := unittest.NewMiner(
t, unittest.NetParams, []string{"--txindex"}, false, 0,
)
require.NoError(t, err, "unable to create mining node")
if err := miner2.SetUp(false, 0); err != nil {
t.Fatalf("unable to set up mining node: %v", err)
}
defer miner2.TearDown()
// We start by connecting the new miner to our original miner,
// such that it will sync to our original chain.
@ -1203,14 +1200,9 @@ func testReorgSpend(miner *rpctest.Harness,
require.NoError(t, err, "unable to register for spend")
// Set up a new miner that we can use to cause a reorg.
miner2, err := rpctest.New(
chainntnfs.NetParams, nil, []string{"--txindex"}, "",
miner2 := unittest.NewMiner(
t, unittest.NetParams, []string{"--txindex"}, false, 0,
)
require.NoError(t, err, "unable to create mining node")
if err := miner2.SetUp(false, 0); err != nil {
t.Fatalf("unable to set up mining node: %v", err)
}
defer miner2.TearDown()
// We start by connecting the new miner to our original miner, in order
// to have a consistent view of the chain from both miners. They should
@ -1526,14 +1518,9 @@ func testCatchUpOnMissedBlocksWithReorg(miner1 *rpctest.Harness,
var wg sync.WaitGroup
// Set up a new miner that we can use to cause a reorg.
miner2, err := rpctest.New(
chainntnfs.NetParams, nil, []string{"--txindex"}, "",
miner2 := unittest.NewMiner(
t, unittest.NetParams, []string{"--txindex"}, false, 0,
)
require.NoError(t, err, "unable to create mining node")
if err := miner2.SetUp(false, 0); err != nil {
t.Fatalf("unable to set up mining node: %v", err)
}
defer miner2.TearDown()
// We start by connecting the new miner to our original miner,
// such that it will sync to our original chain.
@ -1709,6 +1696,90 @@ func testCatchUpOnMissedBlocksWithReorg(miner1 *rpctest.Harness,
}
}
// testIncludeBlockAsymmetry tests that if the same output is registered for a
// notification by two callers, one is able to get a notification with the
// block and the other one without it.
func testIncludeBlockAsymmetry(miner *rpctest.Harness,
notifier chainntnfs.TestChainNotifier, scriptDispatch bool,
t *testing.T) {
// We'll start by creating a new test transaction, waiting long enough
// for it to get into the mempool.
txid, pkScript, err := chainntnfs.GetTestTxidAndScript(miner)
require.NoError(t, err, "unable to create test tx")
if err := chainntnfs.WaitForMempoolTx(miner, txid); err != nil {
t.Fatalf("tx not relayed to miner: %v", err)
}
_, currentHeight, err := miner.Client.GetBestBlock()
require.NoError(t, err, "unable to get current height")
var (
confIntentNoBlock *chainntnfs.ConfirmationEvent
confIntentBlock *chainntnfs.ConfirmationEvent
numConfsLong = uint32(6)
numConfsShort = uint32(1)
)
dispatchClients := func() {
dispatchTxid := txid
if scriptDispatch {
dispatchTxid = nil
}
confIntentNoBlock, err = notifier.RegisterConfirmationsNtfn(
dispatchTxid, pkScript, numConfsLong,
uint32(currentHeight),
)
require.NoError(t, err)
confIntentBlock, err = notifier.RegisterConfirmationsNtfn(
dispatchTxid, pkScript, numConfsShort,
uint32(currentHeight), chainntnfs.WithIncludeBlock(),
)
require.NoError(t, err)
}
assertNtfns := func() {
// Make sure the long confirmation client receives the
// notification but not the block.
confNtfnNoBlock, err := lnutils.RecvOrTimeout(
confIntentNoBlock.Confirmed, time.Second*5,
)
require.NoError(t, err)
require.Nil(t, (*confNtfnNoBlock).Block, "block not included")
// And the short confirmation client receives the notification
// and the block.
confNtfnBlock, err := lnutils.RecvOrTimeout(
confIntentBlock.Confirmed, time.Second*5,
)
require.NoError(t, err)
require.NotNil(t, (*confNtfnBlock).Block, "block included")
}
// First, we start off by registering two clients for the same txid and
// pkScript. One of them will require 6 confirmations but not request
// the block, the other will just require a single confirmation and
// request the block.
dispatchClients()
// Next, we'll generate a few blocks, which should confirm the
// transaction created above and trigger the notifications, as it should
// be confirmed enough for both clients.
_, err = miner.Client.Generate(6)
require.NoError(t, err, "unable to generate single block")
// Make sure we got the notifications we expected.
assertNtfns()
// Now dispatch the same clients again, which should hit the same
// conditions as above and use the cached rescan details.
dispatchClients()
// And again, the notifications should be triggered as expected.
assertNtfns()
}
type txNtfnTestCase struct {
name string
test func(node *rpctest.Harness, notifier chainntnfs.TestChainNotifier,
@ -1772,6 +1843,10 @@ var txNtfnTests = []txNtfnTestCase{
name: "cancel spend ntfn",
test: testCancelSpendNtfn,
},
{
name: "test include block asymmetry",
test: testIncludeBlockAsymmetry,
},
}
var blockNtfnTests = []blockNtfnTestCase{
@ -1816,9 +1891,8 @@ func TestInterfaces(t *testing.T, targetBackEnd string) {
// dedicated miner to generate blocks, cause re-orgs, etc. We'll set up
// this node with a chain length of 125, so we have plenty of BTC to
// play around with.
miner := chainntnfs.NewMiner(t, nil, true, 25)
miner := unittest.NewMiner(t, unittest.NetParams, nil, true, 25)
rpcConfig := miner.RPCConfig()
p2pAddr := miner.P2PAddress()
log.Printf("Running %v ChainNotifier interface tests",
@ -1855,39 +1929,42 @@ func TestInterfaces(t *testing.T, targetBackEnd string) {
switch notifierType {
case "bitcoind":
var bitcoindConn *chain.BitcoindConn
bitcoindConn = chainntnfs.NewBitcoindBackend(
t, p2pAddr, true, false,
bitcoindConn = unittest.NewBitcoindBackend(
t, unittest.NetParams, p2pAddr, true, false,
)
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
return bitcoindnotify.New(
bitcoindConn, chainntnfs.NetParams,
bitcoindConn, unittest.NetParams,
hintCache, hintCache, blockCache,
), nil
}
case "bitcoind-rpc-polling":
var bitcoindConn *chain.BitcoindConn
bitcoindConn = chainntnfs.NewBitcoindBackend(
t, p2pAddr, true, true,
bitcoindConn = unittest.NewBitcoindBackend(
t, unittest.NetParams, p2pAddr, true, true,
)
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
return bitcoindnotify.New(
bitcoindConn, chainntnfs.NetParams,
bitcoindConn, unittest.NetParams,
hintCache, hintCache, blockCache,
), nil
}
case "btcd":
rpcConfig := miner.RPCConfig()
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
return btcdnotify.New(
&rpcConfig, chainntnfs.NetParams,
&rpcConfig, unittest.NetParams,
hintCache, hintCache, blockCache,
)
}
case "neutrino":
var spvNode *neutrino.ChainService
spvNode = chainntnfs.NewNeutrinoBackend(t, p2pAddr)
spvNode = unittest.NewNeutrinoBackend(
t, unittest.NetParams, p2pAddr,
)
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
return neutrinonotify.New(
spvNode, hintCache, hintCache,

View File

@ -6,26 +6,18 @@ package chainntnfs
import (
"errors"
"fmt"
"io/ioutil"
"math/rand"
"os/exec"
"path/filepath"
"testing"
"time"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/integration/rpctest"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/walletdb"
"github.com/lightninglabs/neutrino"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lntest/unittest"
"github.com/stretchr/testify/require"
)
@ -36,10 +28,6 @@ var (
TrickleInterval = 10 * time.Millisecond
)
var (
NetParams = &chaincfg.RegressionNetParams
)
// randPubKeyHashScript generates a P2PKH script that pays to the public key of
// a randomly-generated private key.
func randPubKeyHashScript() ([]byte, *btcec.PrivateKey, error) {
@ -49,7 +37,9 @@ func randPubKeyHashScript() ([]byte, *btcec.PrivateKey, error) {
}
pubKeyHash := btcutil.Hash160(privKey.PubKey().SerializeCompressed())
addrScript, err := btcutil.NewAddressPubKeyHash(pubKeyHash, NetParams)
addrScript, err := btcutil.NewAddressWitnessPubKeyHash(
pubKeyHash, unittest.NetParams,
)
if err != nil {
return nil, nil, err
}
@ -67,7 +57,8 @@ func randPubKeyHashScript() ([]byte, *btcec.PrivateKey, error) {
func GetTestTxidAndScript(h *rpctest.Harness) (*chainhash.Hash, []byte, error) {
pkScript, _, err := randPubKeyHashScript()
if err != nil {
return nil, nil, fmt.Errorf("unable to generate pkScript: %v", err)
return nil, nil, fmt.Errorf("unable to generate pkScript: %w",
err)
}
output := &wire.TxOut{Value: 2e8, PkScript: pkScript}
txid, err := h.SendOutputs([]*wire.TxOut{output}, 10)
@ -149,173 +140,26 @@ func CreateSpendTx(t *testing.T, prevOutPoint *wire.OutPoint,
t.Helper()
spendingTx := wire.NewMsgTx(1)
spendingTx.AddTxIn(&wire.TxIn{PreviousOutPoint: *prevOutPoint})
spendingTx.AddTxOut(&wire.TxOut{Value: 1e8, PkScript: prevOutput.PkScript})
// Create a new output.
outputAmt := int64(1e8)
witnessProgram, _, err := randPubKeyHashScript()
require.NoError(t, err, "unable to generate pkScript")
output := wire.NewTxOut(outputAmt, witnessProgram)
sigScript, err := txscript.SignatureScript(
spendingTx, 0, prevOutput.PkScript, txscript.SigHashAll,
privKey, true,
// Create a new tx.
tx := wire.NewMsgTx(2)
tx.AddTxIn(wire.NewTxIn(prevOutPoint, nil, nil))
tx.AddTxOut(output)
// Generate the witness.
sigHashes := input.NewTxSigHashesV0Only(tx)
witnessScript, err := txscript.WitnessSignature(
tx, sigHashes, 0, prevOutput.Value, prevOutput.PkScript,
txscript.SigHashAll, privKey, true,
)
require.NoError(t, err, "unable to sign tx")
spendingTx.TxIn[0].SignatureScript = sigScript
return spendingTx
}
// NewMiner spawns testing harness backed by a btcd node that can serve as a
// miner.
func NewMiner(t *testing.T, extraArgs []string, createChain bool,
spendableOutputs uint32) *rpctest.Harness {
t.Helper()
// Add the trickle interval argument to the extra args.
trickle := fmt.Sprintf("--trickleinterval=%v", TrickleInterval)
extraArgs = append(extraArgs, trickle)
node, err := rpctest.New(NetParams, nil, extraArgs, "")
require.NoError(t, err, "unable to create backend node")
t.Cleanup(func() {
require.NoError(t, node.TearDown())
})
if err := node.SetUp(createChain, spendableOutputs); err != nil {
t.Fatalf("unable to set up backend node: %v", err)
}
return node
}
// NewBitcoindBackend spawns a new bitcoind node that connects to a miner at the
// specified address. The txindex boolean can be set to determine whether the
// backend node should maintain a transaction index. The rpcpolling boolean
// can be set to determine whether bitcoind's RPC polling interface should be
// used for block and tx notifications or if its ZMQ interface should be used.
// A connection to the newly spawned bitcoind node is returned.
func NewBitcoindBackend(t *testing.T, minerAddr string, txindex,
rpcpolling bool) *chain.BitcoindConn {
t.Helper()
// We use ioutil.TempDir here instead of t.TempDir because some versions
// of bitcoind complain about the zmq connection string formats when the
// t.TempDir directory string is used.
tempBitcoindDir, err := ioutil.TempDir("", "bitcoind")
require.NoError(t, err, "unable to create temp dir")
rpcPort := rand.Intn(65536-1024) + 1024
zmqBlockHost := "ipc:///" + tempBitcoindDir + "/blocks.socket"
zmqTxHost := "ipc:///" + tempBitcoindDir + "/tx.socket"
args := []string{
"-connect=" + minerAddr,
"-datadir=" + tempBitcoindDir,
"-regtest",
"-rpcauth=weks:469e9bb14ab2360f8e226efed5ca6fd$507c670e800a952" +
"84294edb5773b05544b220110063096c221be9933c82d38e1",
fmt.Sprintf("-rpcport=%d", rpcPort),
"-disablewallet",
"-zmqpubrawblock=" + zmqBlockHost,
"-zmqpubrawtx=" + zmqTxHost,
}
if txindex {
args = append(args, "-txindex")
}
bitcoind := exec.Command("bitcoind", args...)
if err := bitcoind.Start(); err != nil {
t.Fatalf("unable to start bitcoind: %v", err)
}
t.Cleanup(func() {
_ = bitcoind.Process.Kill()
_ = bitcoind.Wait()
})
// Wait for the bitcoind instance to start up.
host := fmt.Sprintf("127.0.0.1:%d", rpcPort)
cfg := &chain.BitcoindConfig{
ChainParams: NetParams,
Host: host,
User: "weks",
Pass: "weks",
// Fields only required for pruned nodes, not needed for these
// tests.
Dialer: nil,
PrunedModeMaxPeers: 0,
}
if rpcpolling {
cfg.PollingConfig = &chain.PollingConfig{
BlockPollingInterval: time.Millisecond * 20,
TxPollingInterval: time.Millisecond * 20,
}
} else {
cfg.ZMQConfig = &chain.ZMQConfig{
ZMQBlockHost: zmqBlockHost,
ZMQTxHost: zmqTxHost,
ZMQReadDeadline: 5 * time.Second,
}
}
var conn *chain.BitcoindConn
err = wait.NoError(func() error {
var err error
conn, err = chain.NewBitcoindConn(cfg)
if err != nil {
return err
}
return conn.Start()
}, 10*time.Second)
if err != nil {
t.Fatalf("unable to establish connection to bitcoind: %v", err)
}
t.Cleanup(conn.Stop)
return conn
}
// NewNeutrinoBackend spawns a new neutrino node that connects to a miner at
// the specified address.
func NewNeutrinoBackend(t *testing.T, minerAddr string) *neutrino.ChainService {
t.Helper()
spvDir := t.TempDir()
dbName := filepath.Join(spvDir, "neutrino.db")
spvDatabase, err := walletdb.Create(
"bdb", dbName, true, kvdb.DefaultDBTimeout,
)
if err != nil {
t.Fatalf("unable to create walletdb: %v", err)
}
t.Cleanup(func() {
spvDatabase.Close()
})
// Create an instance of neutrino connected to the running btcd
// instance.
spvConfig := neutrino.Config{
DataDir: spvDir,
Database: spvDatabase,
ChainParams: *NetParams,
ConnectPeers: []string{minerAddr},
}
spvNode, err := neutrino.NewChainService(spvConfig)
if err != nil {
t.Fatalf("unable to create neutrino: %v", err)
}
// We'll also wait for the instance to sync up fully to the chain
// generated by the btcd instance.
spvNode.Start()
for !spvNode.IsCurrent() {
time.Sleep(time.Millisecond * 100)
}
t.Cleanup(func() {
spvNode.Stop()
})
return spvNode
tx.TxIn[0].Witness = witnessScript
return tx
}

View File

@ -74,6 +74,11 @@ var (
// out of range.
ErrNumConfsOutOfRange = fmt.Errorf("number of confirmations must be "+
"between %d and %d", 1, MaxNumConfs)
// ErrEmptyWitnessStack is returned when a spending transaction has an
// empty witness stack. More details in,
// - https://github.com/bitcoin/bitcoin/issues/28730
ErrEmptyWitnessStack = errors.New("witness stack is empty")
)
// rescanState indicates the progression of a registration before the notifier
@ -666,11 +671,15 @@ func (n *TxNotifier) RegisterConf(txid *chainhash.Hash, pkScript []byte,
// block along with the rest of the details. However not all
// clients want the block, so we make a copy here w/o the block
// if needed so we can give clients only what they ask for.
if !ntfn.includeBlock && confSet.details != nil {
confSet.details.Block = nil
confDetails := confSet.details
if !ntfn.includeBlock && confDetails != nil {
confDetailsCopy := *confDetails
confDetailsCopy.Block = nil
confDetails = &confDetailsCopy
}
err := n.dispatchConfDetails(ntfn, confSet.details)
err := n.dispatchConfDetails(ntfn, confDetails)
if err != nil {
return nil, err
}
@ -763,8 +772,8 @@ func (n *TxNotifier) CancelConf(confRequest ConfRequest, confID uint64) {
return
}
Log.Infof("Canceling confirmation notification: conf_id=%d, %v", confID,
confRequest)
Log.Debugf("Canceling confirmation notification: conf_id=%d, %v",
confID, confRequest)
// We'll close all the notification channels to let the client know
// their cancel request has been fulfilled.
@ -916,7 +925,7 @@ func (n *TxNotifier) dispatchConfDetails(
// we'll dispatch a confirmation notification to the caller.
confHeight := details.BlockHeight + ntfn.NumConfirmations - 1
if confHeight <= n.currentHeight {
Log.Infof("Dispatching %v confirmation notification for %v",
Log.Debugf("Dispatching %v confirmation notification for %v",
ntfn.NumConfirmations, ntfn.ConfRequest)
// We'll send a 0 value to the Updates channel,
@ -1049,7 +1058,7 @@ func (n *TxNotifier) RegisterSpend(outpoint *wire.OutPoint, pkScript []byte,
n.Lock()
defer n.Unlock()
Log.Infof("New spend subscription: spend_id=%d, %v, height_hint=%d",
Log.Debugf("New spend subscription: spend_id=%d, %v, height_hint=%d",
ntfn.SpendID, ntfn.SpendRequest, startHeight)
// Keep track of the notification request so that we can properly
@ -1127,7 +1136,7 @@ func (n *TxNotifier) RegisterSpend(outpoint *wire.OutPoint, pkScript []byte,
// notifications don't also attempt a historical dispatch.
spendSet.rescanStatus = rescanPending
Log.Infof("Dispatching historical spend rescan for %v, start=%d, "+
Log.Debugf("Dispatching historical spend rescan for %v, start=%d, "+
"end=%d", ntfn.SpendRequest, startHeight, n.currentHeight)
return &SpendRegistration{
@ -1162,7 +1171,7 @@ func (n *TxNotifier) CancelSpend(spendRequest SpendRequest, spendID uint64) {
return
}
Log.Infof("Canceling spend notification: spend_id=%d, %v", spendID,
Log.Debugf("Canceling spend notification: spend_id=%d, %v", spendID,
spendRequest)
// We'll close all the notification channels to let the client know
@ -1293,6 +1302,19 @@ func (n *TxNotifier) updateSpendDetails(spendRequest SpendRequest,
return nil
}
// Return an error if the witness data is not present in the spending
// transaction.
//
// NOTE: if the witness stack is empty, we will do a critical log which
// shuts down the node.
if !details.HasSpenderWitness() {
Log.Criticalf("Found spending tx for outpoint=%v, but the "+
"transaction %v does not have witness",
spendRequest.OutPoint, details.SpendingTx.TxHash())
return ErrEmptyWitnessStack
}
// If the historical rescan found the spending transaction for this
// request, but it's at a later height than the notifier (this can
// happen due to latency with the backend during a reorg), then we'll
@ -1342,7 +1364,7 @@ func (n *TxNotifier) dispatchSpendDetails(ntfn *SpendNtfn, details *SpendDetail)
return nil
}
Log.Infof("Dispatching confirmed spend notification for %v at "+
Log.Debugf("Dispatching confirmed spend notification for %v at "+
"current height=%d: %v", ntfn.SpendRequest, n.currentHeight,
details)
@ -1721,7 +1743,7 @@ func (n *TxNotifier) NotifyHeight(height uint32) error {
for ntfn := range n.ntfnsByConfirmHeight[height] {
confSet := n.confNotifications[ntfn.ConfRequest]
Log.Infof("Dispatching %v confirmation notification for %v",
Log.Debugf("Dispatching %v confirmation notification for %v",
ntfn.NumConfirmations, ntfn.ConfRequest)
// The default notification we assigned above includes the

View File

@ -34,6 +34,8 @@ var (
0x86, 0xf4, 0xcb, 0xf9, 0x8e, 0xae, 0xd2, 0x21,
0xb3, 0x0b, 0xd9, 0xa0, 0xb9, 0x28,
}
testWitness = [][]byte{{0x01}}
)
type mockHintCache struct {
@ -747,6 +749,7 @@ func TestTxNotifierHistoricalSpendDispatch(t *testing.T) {
spendTx := wire.NewMsgTx(2)
spendTx.AddTxIn(&wire.TxIn{
PreviousOutPoint: spentOutpoint,
Witness: testWitness,
SignatureScript: testSigScript,
})
spendTxHash := spendTx.TxHash()
@ -812,7 +815,7 @@ func TestTxNotifierHistoricalSpendDispatch(t *testing.T) {
}
}
// TestTxNotifierMultipleHistoricalRescans ensures that we don't attempt to
// TestTxNotifierMultipleHistoricalConfRescans ensures that we don't attempt to
// request multiple historical confirmation rescans per transactions.
func TestTxNotifierMultipleHistoricalConfRescans(t *testing.T) {
t.Parallel()
@ -859,7 +862,7 @@ func TestTxNotifierMultipleHistoricalConfRescans(t *testing.T) {
}
}
// TestTxNotifierMultipleHistoricalRescans ensures that we don't attempt to
// TestTxNotifierMultipleHistoricalSpendRescans ensures that we don't attempt to
// request multiple historical spend rescans per outpoints.
func TestTxNotifierMultipleHistoricalSpendRescans(t *testing.T) {
t.Parallel()
@ -894,10 +897,17 @@ func TestTxNotifierMultipleHistoricalSpendRescans(t *testing.T) {
// register another notification. We should also expect not to see a
// historical rescan request since the confirmation details should be
// cached.
msgTx := &wire.MsgTx{
TxIn: []*wire.TxIn{
{PreviousOutPoint: op, Witness: testWitness},
},
TxOut: []*wire.TxOut{},
}
spendDetails := &chainntnfs.SpendDetail{
SpentOutPoint: &op,
SpenderTxHash: &chainntnfs.ZeroHash,
SpendingTx: wire.NewMsgTx(2),
SpendingTx: msgTx,
SpenderInputIndex: 0,
SpendingHeight: startingHeight - 1,
}
@ -1021,10 +1031,17 @@ func TestTxNotifierMultipleHistoricalNtfns(t *testing.T) {
// We'll assume a historical rescan was dispatched and found the
// following spend details. We'll let the notifier know so that it can
// stop watching at tip.
msgTx := &wire.MsgTx{
TxIn: []*wire.TxIn{
{PreviousOutPoint: op, Witness: testWitness},
},
TxOut: []*wire.TxOut{},
}
expectedSpendDetails := &chainntnfs.SpendDetail{
SpentOutPoint: &op,
SpenderTxHash: &chainntnfs.ZeroHash,
SpendingTx: wire.NewMsgTx(2),
SpendingTx: msgTx,
SpenderInputIndex: 0,
SpendingHeight: startingHeight - 1,
}
@ -1724,7 +1741,7 @@ func TestTxNotifierSpendReorg(t *testing.T) {
}
}
// TestTxNotifierUpdateSpendReorg tests that a call to RegisterSpend after the
// TestTxNotifierSpendReorgMissed tests that a call to RegisterSpend after the
// spend has been confirmed, and then UpdateSpendDetails (called by historical
// dispatch), followed by a chain re-org will notify on the Reorg channel. This
// was not always the case and has since been fixed.
@ -1744,6 +1761,7 @@ func TestTxNotifierSpendReorgMissed(t *testing.T) {
spendTx := wire.NewMsgTx(2)
spendTx.AddTxIn(&wire.TxIn{
PreviousOutPoint: op,
Witness: testWitness,
SignatureScript: testSigScript,
})
spendTxHash := spendTx.TxHash()
@ -2142,7 +2160,7 @@ func TestTxNotifierSpendHintCache(t *testing.T) {
}
}
// TestTxNotifierSpendHinthistoricalRescan checks that the height hints and
// TestTxNotifierSpendDuringHistoricalRescan checks that the height hints and
// spend notifications behave as expected when a spend is found at tip during a
// historical rescan.
func TestTxNotifierSpendDuringHistoricalRescan(t *testing.T) {

View File

@ -1,25 +0,0 @@
package chainreg
// ChainCode is an enum-like structure for keeping track of the chains
// currently supported within lnd.
type ChainCode uint32
const (
// BitcoinChain is Bitcoin's chain.
BitcoinChain ChainCode = iota
// LitecoinChain is Litecoin's chain.
LitecoinChain
)
// String returns a string representation of the target ChainCode.
func (c ChainCode) String() string {
switch c {
case BitcoinChain:
return "bitcoin"
case LitecoinChain:
return "litecoin"
default:
return "kekcoin"
}
}

View File

@ -1,13 +1,9 @@
package chainreg
import (
"github.com/btcsuite/btcd/chaincfg"
bitcoinCfg "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
bitcoinWire "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/keychain"
litecoinCfg "github.com/ltcsuite/ltcd/chaincfg"
litecoinWire "github.com/ltcsuite/ltcd/wire"
)
// BitcoinNetParams couples the p2p parameters of a network with the
@ -18,14 +14,6 @@ type BitcoinNetParams struct {
CoinType uint32
}
// LitecoinNetParams couples the p2p parameters of a network with the
// corresponding RPC port of a daemon running on the particular network.
type LitecoinNetParams struct {
*litecoinCfg.Params
RPCPort string
CoinType uint32
}
// BitcoinTestNetParams contains parameters specific to the 3rd version of the
// test network.
var BitcoinTestNetParams = BitcoinNetParams{
@ -57,38 +45,6 @@ var BitcoinSigNetParams = BitcoinNetParams{
CoinType: keychain.CoinTypeTestnet,
}
// LitecoinSimNetParams contains parameters specific to the simulation test
// network.
var LitecoinSimNetParams = LitecoinNetParams{
Params: &litecoinCfg.TestNet4Params,
RPCPort: "18556",
CoinType: keychain.CoinTypeTestnet,
}
// LitecoinTestNetParams contains parameters specific to the 4th version of the
// test network.
var LitecoinTestNetParams = LitecoinNetParams{
Params: &litecoinCfg.TestNet4Params,
RPCPort: "19334",
CoinType: keychain.CoinTypeTestnet,
}
// LitecoinMainNetParams contains the parameters specific to the current
// Litecoin mainnet.
var LitecoinMainNetParams = LitecoinNetParams{
Params: &litecoinCfg.MainNetParams,
RPCPort: "9334",
CoinType: keychain.CoinTypeLitecoin,
}
// LitecoinRegTestNetParams contains parameters specific to a local litecoin
// regtest network.
var LitecoinRegTestNetParams = LitecoinNetParams{
Params: &litecoinCfg.RegressionNetParams,
RPCPort: "18334",
CoinType: keychain.CoinTypeTestnet,
}
// BitcoinRegTestNetParams contains parameters specific to a local bitcoin
// regtest network.
var BitcoinRegTestNetParams = BitcoinNetParams{
@ -97,56 +53,8 @@ var BitcoinRegTestNetParams = BitcoinNetParams{
CoinType: keychain.CoinTypeTestnet,
}
// ApplyLitecoinParams applies the relevant chain configuration parameters that
// differ for litecoin to the chain parameters typed for btcsuite derivation.
// This function is used in place of using something like interface{} to
// abstract over _which_ chain (or fork) the parameters are for.
func ApplyLitecoinParams(params *BitcoinNetParams,
litecoinParams *LitecoinNetParams) {
params.Name = litecoinParams.Name
params.Net = bitcoinWire.BitcoinNet(litecoinParams.Net)
params.DefaultPort = litecoinParams.DefaultPort
params.CoinbaseMaturity = litecoinParams.CoinbaseMaturity
copy(params.GenesisHash[:], litecoinParams.GenesisHash[:])
// Address encoding magics
params.PubKeyHashAddrID = litecoinParams.PubKeyHashAddrID
params.ScriptHashAddrID = litecoinParams.ScriptHashAddrID
params.PrivateKeyID = litecoinParams.PrivateKeyID
params.WitnessPubKeyHashAddrID = litecoinParams.WitnessPubKeyHashAddrID
params.WitnessScriptHashAddrID = litecoinParams.WitnessScriptHashAddrID
params.Bech32HRPSegwit = litecoinParams.Bech32HRPSegwit
copy(params.HDPrivateKeyID[:], litecoinParams.HDPrivateKeyID[:])
copy(params.HDPublicKeyID[:], litecoinParams.HDPublicKeyID[:])
params.HDCoinType = litecoinParams.HDCoinType
checkPoints := make([]chaincfg.Checkpoint, len(litecoinParams.Checkpoints))
for i := 0; i < len(litecoinParams.Checkpoints); i++ {
var chainHash chainhash.Hash
copy(chainHash[:], litecoinParams.Checkpoints[i].Hash[:])
checkPoints[i] = chaincfg.Checkpoint{
Height: litecoinParams.Checkpoints[i].Height,
Hash: &chainHash,
}
}
params.Checkpoints = checkPoints
params.RPCPort = litecoinParams.RPCPort
params.CoinType = litecoinParams.CoinType
}
// IsTestnet tests if the givern params correspond to a testnet
// parameter configuration.
func IsTestnet(params *BitcoinNetParams) bool {
switch params.Params.Net {
case bitcoinWire.TestNet3, bitcoinWire.BitcoinNet(litecoinWire.TestNet4):
return true
default:
return false
}
return params.Params.Net == bitcoinWire.TestNet3
}

View File

@ -5,16 +5,14 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net"
"net/url"
"os"
"strconv"
"strings"
"sync"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcwallet/chain"
@ -25,7 +23,8 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs/btcdnotify"
"github.com/lightningnetwork/lnd/chainntnfs/neutrinonotify"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb"
@ -43,13 +42,6 @@ type Config struct {
// Bitcoin defines settings for the Bitcoin chain.
Bitcoin *lncfg.Chain
// Litecoin defines settings for the Litecoin chain.
Litecoin *lncfg.Chain
// PrimaryChain is a function that returns our primary chain via its
// ChainCode.
PrimaryChain func() ChainCode
// HeightHintCacheQueryDisable is a boolean that disables height hint
// queries if true.
HeightHintCacheQueryDisable bool
@ -61,15 +53,9 @@ type Config struct {
// BitcoindMode defines settings for connecting to a bitcoind node.
BitcoindMode *lncfg.Bitcoind
// LitecoindMode defines settings for connecting to a litecoind node.
LitecoindMode *lncfg.Bitcoind
// BtcdMode defines settings for connecting to a btcd node.
BtcdMode *lncfg.Btcd
// LtcdMode defines settings for connecting to an ltcd node.
LtcdMode *lncfg.Btcd
// HeightHintDB is a pointer to the database that stores the height
// hints.
HeightHintDB kvdb.Backend
@ -78,6 +64,14 @@ type Config struct {
// state.
ChanStateDB *channeldb.ChannelStateDB
// AuxLeafStore is an optional store that can be used to store auxiliary
// leaves for certain custom channel types.
AuxLeafStore fn.Option[lnwallet.AuxLeafStore]
// AuxSigner is an optional signer that can be used to sign auxiliary
// leaves for certain custom channel types.
AuxSigner fn.Option[lnwallet.AuxSigner]
// BlockCache is the main cache for storing block information.
BlockCache *blockcache.BlockCache
@ -92,10 +86,14 @@ type Config struct {
// ActiveNetParams details the current chain we are on.
ActiveNetParams BitcoinNetParams
// FeeURL defines the URL for fee estimation we will use. This field is
// optional.
// Deprecated: Use Fee.URL. FeeURL defines the URL for fee estimation
// we will use. This field is optional.
FeeURL string
// Fee defines settings for the web fee estimator. This field is
// optional.
Fee *lncfg.Fee
// Dialer is a function closure that will be used to establish outbound
// TCP connections to Bitcoin peers in the event of a pruned block being
// requested.
@ -130,13 +128,6 @@ const (
// delta.
DefaultBitcoinTimeLockDelta = 80
DefaultLitecoinMinHTLCInMSat = lnwire.MilliSatoshi(1)
DefaultLitecoinMinHTLCOutMSat = lnwire.MilliSatoshi(1000)
DefaultLitecoinBaseFeeMSat = lnwire.MilliSatoshi(1000)
DefaultLitecoinFeeRate = lnwire.MilliSatoshi(1)
DefaultLitecoinTimeLockDelta = 576
DefaultLitecoinDustLimit = btcutil.Amount(54600)
// DefaultBitcoinStaticFeePerKW is the fee rate of 50 sat/vbyte
// expressed in sat/kw.
DefaultBitcoinStaticFeePerKW = chainfee.SatPerKWeight(12500)
@ -145,22 +136,12 @@ const (
// static estimators.
DefaultBitcoinStaticMinRelayFeeRate = chainfee.FeePerKwFloor
// DefaultLitecoinStaticFeePerKW is the fee rate of 200 sat/vbyte
// expressed in sat/kw.
DefaultLitecoinStaticFeePerKW = chainfee.SatPerKWeight(50000)
// BtcToLtcConversionRate is a fixed ratio used in order to scale up
// payments when running on the Litecoin chain.
BtcToLtcConversionRate = 60
// DefaultMinOutboundPeers is the min number of connected
// outbound peers the chain backend should have to maintain a
// healthy connection to the network.
DefaultMinOutboundPeers = 6
)
// DefaultLtcChannelConstraints is the default set of channel constraints that
// are meant to be used when initially funding a Litecoin channel.
var DefaultLtcChannelConstraints = channeldb.ChannelConstraints{
DustLimit: DefaultLitecoinDustLimit,
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
}
// PartialChainControl contains all the primary interfaces of the chain control
// that can be purely constructed from the global configuration. No wallet
// instance is required for constructing this partial state.
@ -182,6 +163,10 @@ type PartialChainControl struct {
// interested in.
ChainNotifier chainntnfs.ChainNotifier
// BestBlockTracker is used to maintain a view of the global
// chain state that changes over time
BestBlockTracker *chainntnfs.BestBlockTracker
// MempoolNotifier is used to watch for spending events happened in
// mempool.
MempoolNotifier chainntnfs.MempoolWatcher
@ -195,14 +180,10 @@ type PartialChainControl struct {
ChainSource chain.Interface
// RoutingPolicy is the routing policy we have decided to use.
RoutingPolicy htlcswitch.ForwardingPolicy
RoutingPolicy models.ForwardingPolicy
// MinHtlcIn is the minimum HTLC we will accept.
MinHtlcIn lnwire.MilliSatoshi
// ChannelConstraints is the set of default constraints that will be
// used for any incoming or outgoing channel reservation requests.
ChannelConstraints channeldb.ChannelConstraints
}
// ChainControl couples the three primary interfaces lnd utilizes for a
@ -237,64 +218,25 @@ type ChainControl struct {
Wallet *lnwallet.LightningWallet
}
// GenDefaultBtcConstraints generates the default set of channel constraints
// that are to be used when funding a Bitcoin channel.
func GenDefaultBtcConstraints() channeldb.ChannelConstraints {
// We use the dust limit for the maximally sized witness program with
// a 40-byte data push.
dustLimit := lnwallet.DustLimitForSize(input.UnknownWitnessSize)
return channeldb.ChannelConstraints{
DustLimit: dustLimit,
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
}
}
// NewPartialChainControl creates a new partial chain control that contains all
// the parts that can be purely constructed from the passed in global
// configuration and doesn't need any wallet instance yet.
//
//nolint:lll
func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
// Set the RPC config from the "home" chain. Multi-chain isn't yet
// active, so we'll restrict usage to a particular chain for now.
homeChainConfig := cfg.Bitcoin
if cfg.PrimaryChain() == LitecoinChain {
homeChainConfig = cfg.Litecoin
}
log.Infof("Primary chain is set to: %v", cfg.PrimaryChain())
cc := &PartialChainControl{
Cfg: cfg,
}
switch cfg.PrimaryChain() {
case BitcoinChain:
cc.RoutingPolicy = htlcswitch.ForwardingPolicy{
RoutingPolicy: models.ForwardingPolicy{
MinHTLCOut: cfg.Bitcoin.MinHTLCOut,
BaseFee: cfg.Bitcoin.BaseFee,
FeeRate: cfg.Bitcoin.FeeRate,
TimeLockDelta: cfg.Bitcoin.TimeLockDelta,
}
cc.MinHtlcIn = cfg.Bitcoin.MinHTLCIn
cc.FeeEstimator = chainfee.NewStaticEstimator(
},
MinHtlcIn: cfg.Bitcoin.MinHTLCIn,
FeeEstimator: chainfee.NewStaticEstimator(
DefaultBitcoinStaticFeePerKW,
DefaultBitcoinStaticMinRelayFeeRate,
)
case LitecoinChain:
cc.RoutingPolicy = htlcswitch.ForwardingPolicy{
MinHTLCOut: cfg.Litecoin.MinHTLCOut,
BaseFee: cfg.Litecoin.BaseFee,
FeeRate: cfg.Litecoin.FeeRate,
TimeLockDelta: cfg.Litecoin.TimeLockDelta,
}
cc.MinHtlcIn = cfg.Litecoin.MinHTLCIn
cc.FeeEstimator = chainfee.NewStaticEstimator(
DefaultLitecoinStaticFeePerKW, 0,
)
default:
return nil, nil, fmt.Errorf("default routing policy for chain "+
"%v is unknown", cfg.PrimaryChain())
),
}
var err error
@ -314,10 +256,20 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
"cache: %v", err)
}
// Map the deprecated feeurl flag to fee.url.
if cfg.FeeURL != "" {
if cfg.Fee.URL != "" {
return nil, nil, errors.New("fee.url and " +
"feeurl are mutually exclusive")
}
cfg.Fee.URL = cfg.FeeURL
}
// If spv mode is active, then we'll be using a distinct set of
// chainControl interfaces that interface directly with the p2p network
// of the selected chain.
switch homeChainConfig.Node {
switch cfg.Bitcoin.Node {
case "neutrino":
// We'll create ChainNotifier and FilteredChainView instances,
// along with the wallet's ChainSource, which are all backed by
@ -332,18 +284,6 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
return nil, nil, err
}
// Map the deprecated neutrino feeurl flag to the general fee
// url.
if cfg.NeutrinoMode.FeeURL != "" {
if cfg.FeeURL != "" {
return nil, nil, errors.New("feeurl and " +
"neutrino.feeurl are mutually " +
"exclusive")
}
cfg.FeeURL = cfg.NeutrinoMode.FeeURL
}
cc.ChainSource = chain.NewNeutrinoClient(
cfg.ActiveNetParams.Params, cfg.NeutrinoCS,
)
@ -354,16 +294,11 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
return err
}
case "bitcoind", "litecoind":
var bitcoindMode *lncfg.Bitcoind
switch {
case cfg.Bitcoin.Active:
bitcoindMode = cfg.BitcoindMode
case cfg.Litecoin.Active:
bitcoindMode = cfg.LitecoindMode
}
case "bitcoind":
bitcoindMode := cfg.BitcoindMode
// Otherwise, we'll be speaking directly via RPC and ZMQ to a
// bitcoind node. If the specified host for the btcd/ltcd RPC
// bitcoind node. If the specified host for the btcd RPC
// server already has a port specified, then we use that
// directly. Otherwise, we assume the default port according to
// the selected chain parameters.
@ -382,18 +317,13 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
rpcPort -= 2
bitcoindHost = fmt.Sprintf("%v:%d",
bitcoindMode.RPCHost, rpcPort)
if (cfg.Bitcoin.Active &&
(cfg.Bitcoin.RegTest || cfg.Bitcoin.SigNet)) ||
(cfg.Litecoin.Active && cfg.Litecoin.RegTest) {
if cfg.Bitcoin.RegTest || cfg.Bitcoin.SigNet {
conn, err := net.Dial("tcp", bitcoindHost)
if err != nil || conn == nil {
switch {
case cfg.Bitcoin.Active && cfg.Bitcoin.RegTest:
case cfg.Bitcoin.RegTest:
rpcPort = 18443
case cfg.Litecoin.Active && cfg.Litecoin.RegTest:
rpcPort = 19443
case cfg.Bitcoin.Active && cfg.Bitcoin.SigNet:
case cfg.Bitcoin.SigNet:
rpcPort = 38332
}
bitcoindHost = fmt.Sprintf("%v:%d",
@ -466,7 +396,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
DisableTLS: true,
HTTPPostMode: true,
}
if cfg.Bitcoin.Active && !cfg.Bitcoin.RegTest {
if !cfg.Bitcoin.RegTest {
log.Infof("Initializing bitcoind backed fee estimator "+
"in %s mode", bitcoindMode.EstimateMode)
@ -482,23 +412,6 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
if err != nil {
return nil, nil, err
}
} else if cfg.Litecoin.Active && !cfg.Litecoin.RegTest {
log.Infof("Initializing litecoind backed fee "+
"estimator in %s mode",
bitcoindMode.EstimateMode)
// Finally, we'll re-initialize the fee estimator, as
// if we're using litecoind as a backend, then we can
// use live fee estimates, rather than a statically
// coded value.
fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000)
cc.FeeEstimator, err = chainfee.NewBitcoindEstimator(
*rpcConfig, bitcoindMode.EstimateMode,
fallBackFeeRate.FeePerKWeight(),
)
if err != nil {
return nil, nil, err
}
}
// We need to use some apis that are not exposed by btcwallet,
@ -607,24 +520,34 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
cc.HealthCheck = func() error {
_, err := chainConn.RawRequest(cmd, nil)
return err
if err != nil {
return err
}
// On local test networks we usually don't have multiple
// chain backend peers, so we can skip
// the checkOutboundPeers test.
if cfg.Bitcoin.SimNet || cfg.Bitcoin.RegTest {
return nil
}
// Make sure the bitcoind chain backend maintains a
// healthy connection to the network by checking the
// number of outbound peers.
return checkOutboundPeers(chainConn)
}
case "btcd", "ltcd":
case "btcd":
// Otherwise, we'll be speaking directly via RPC to a node.
//
// So first we'll load btcd/ltcd's TLS cert for the RPC
// So first we'll load btcd's TLS cert for the RPC
// connection. If a raw cert was specified in the config, then
// we'll set that directly. Otherwise, we attempt to read the
// cert from the path specified in the config.
var btcdMode *lncfg.Btcd
switch {
case cfg.Bitcoin.Active:
var (
rpcCert []byte
btcdMode = cfg.BtcdMode
case cfg.Litecoin.Active:
btcdMode = cfg.LtcdMode
}
var rpcCert []byte
)
if btcdMode.RawRPCCert != "" {
rpcCert, err = hex.DecodeString(btcdMode.RawRPCCert)
if err != nil {
@ -635,7 +558,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
if err != nil {
return nil, nil, err
}
rpcCert, err = ioutil.ReadAll(certFile)
rpcCert, err = io.ReadAll(certFile)
if err != nil {
return nil, nil, err
}
@ -644,7 +567,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
}
}
// If the specified host for the btcd/ltcd RPC server already
// If the specified host for the btcd RPC server already
// has a port specified, then we use that directly. Otherwise,
// we assume the default port according to the selected chain
// parameters.
@ -720,14 +643,26 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
// Use a query for our best block as a health check.
cc.HealthCheck = func() error {
_, _, err := cc.ChainSource.GetBestBlock()
return err
if err != nil {
return err
}
// On local test networks we usually don't have multiple
// chain backend peers, so we can skip
// the checkOutboundPeers test.
if cfg.Bitcoin.SimNet || cfg.Bitcoin.RegTest {
return nil
}
// Make sure the btcd chain backend maintains a
// healthy connection to the network by checking the
// number of outbound peers.
return checkOutboundPeers(chainRPC.Client)
}
// If we're not in simnet or regtest mode, then we'll attempt
// to use a proper fee estimator for testnet.
if !cfg.Bitcoin.SimNet && !cfg.Litecoin.SimNet &&
!cfg.Bitcoin.RegTest && !cfg.Litecoin.RegTest {
if !cfg.Bitcoin.SimNet && !cfg.Bitcoin.RegTest {
log.Info("Initializing btcd backed fee estimator")
// Finally, we'll re-initialize the fee estimator, as
@ -760,34 +695,44 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
default:
return nil, nil, fmt.Errorf("unknown node type: %s",
homeChainConfig.Node)
cfg.Bitcoin.Node)
}
cc.BestBlockTracker =
chainntnfs.NewBestBlockTracker(cc.ChainNotifier)
switch {
// If the fee URL isn't set, and the user is running mainnet, then
// we'll return an error to instruct them to set a proper fee
// estimator.
case cfg.FeeURL == "" && cfg.Bitcoin.MainNet &&
homeChainConfig.Node == "neutrino":
case cfg.Fee.URL == "" && cfg.Bitcoin.MainNet &&
cfg.Bitcoin.Node == "neutrino":
return nil, nil, fmt.Errorf("--feeurl parameter required " +
return nil, nil, fmt.Errorf("--fee.url parameter required " +
"when running neutrino on mainnet")
// Override default fee estimator if an external service is specified.
case cfg.FeeURL != "":
case cfg.Fee.URL != "":
// Do not cache fees on regtest to make it easier to execute
// manual or automated test cases.
cacheFees := !cfg.Bitcoin.RegTest
log.Infof("Using external fee estimator %v: cached=%v",
cfg.FeeURL, cacheFees)
log.Infof("Using external fee estimator %v: cached=%v: "+
"min update timeout=%v, max update timeout=%v",
cfg.Fee.URL, cacheFees, cfg.Fee.MinUpdateTimeout,
cfg.Fee.MaxUpdateTimeout)
cc.FeeEstimator = chainfee.NewWebAPIEstimator(
cc.FeeEstimator, err = chainfee.NewWebAPIEstimator(
chainfee.SparseConfFeeSource{
URL: cfg.FeeURL,
URL: cfg.Fee.URL,
},
!cacheFees,
cfg.Fee.MinUpdateTimeout,
cfg.Fee.MaxUpdateTimeout,
)
if err != nil {
return nil, nil, err
}
}
ccCleanup := func() {
@ -804,12 +749,6 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
return nil, nil, err
}
// Select the default channel constraints for the primary chain.
cc.ChannelConstraints = GenDefaultBtcConstraints()
if cfg.PrimaryChain() == LitecoinChain {
cc.ChannelConstraints = DefaultLtcChannelConstraints
}
return cc, ccCleanup, nil
}
@ -842,11 +781,11 @@ func NewChainControl(walletConfig lnwallet.Config,
lnWallet, err := lnwallet.NewLightningWallet(walletConfig)
if err != nil {
return nil, ccCleanup, fmt.Errorf("unable to create wallet: %v",
return nil, ccCleanup, fmt.Errorf("unable to create wallet: %w",
err)
}
if err := lnWallet.Startup(); err != nil {
return nil, ccCleanup, fmt.Errorf("unable to create wallet: %v",
return nil, ccCleanup, fmt.Errorf("unable to create wallet: %w",
err)
}
@ -915,33 +854,6 @@ var (
0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
})
// LitecoinTestnetGenesis is the genesis hash of Litecoin's testnet4
// chain.
LitecoinTestnetGenesis = chainhash.Hash([chainhash.HashSize]byte{
0xa0, 0x29, 0x3e, 0x4e, 0xeb, 0x3d, 0xa6, 0xe6,
0xf5, 0x6f, 0x81, 0xed, 0x59, 0x5f, 0x57, 0x88,
0x0d, 0x1a, 0x21, 0x56, 0x9e, 0x13, 0xee, 0xfd,
0xd9, 0x51, 0x28, 0x4b, 0x5a, 0x62, 0x66, 0x49,
})
// LitecoinMainnetGenesis is the genesis hash of Litecoin's main chain.
LitecoinMainnetGenesis = chainhash.Hash([chainhash.HashSize]byte{
0xe2, 0xbf, 0x04, 0x7e, 0x7e, 0x5a, 0x19, 0x1a,
0xa4, 0xef, 0x34, 0xd3, 0x14, 0x97, 0x9d, 0xc9,
0x98, 0x6e, 0x0f, 0x19, 0x25, 0x1e, 0xda, 0xba,
0x59, 0x40, 0xfd, 0x1f, 0xe3, 0x65, 0xa7, 0x12,
})
// chainMap is a simple index that maps a chain's genesis hash to the
// ChainCode enum for that chain.
chainMap = map[chainhash.Hash]ChainCode{
BitcoinTestnetGenesis: BitcoinChain,
LitecoinTestnetGenesis: LitecoinChain,
BitcoinMainnetGenesis: BitcoinChain,
LitecoinMainnetGenesis: LitecoinChain,
}
// ChainDNSSeeds is a map of a chain's hash to the set of DNS seeds
// that will be use to bootstrap peers upon first startup.
//
@ -977,107 +889,33 @@ var (
"ln.signet.secp.tech",
},
},
LitecoinMainnetGenesis: {
{
"ltc.nodes.lightning.directory",
"soa.nodes.lightning.directory",
},
},
}
)
// ChainRegistry keeps track of the current chains.
type ChainRegistry struct {
sync.RWMutex
activeChains map[ChainCode]*ChainControl
netParams map[ChainCode]*BitcoinNetParams
primaryChain ChainCode
}
// NewChainRegistry creates a new ChainRegistry.
func NewChainRegistry() *ChainRegistry {
return &ChainRegistry{
activeChains: make(map[ChainCode]*ChainControl),
netParams: make(map[ChainCode]*BitcoinNetParams),
}
}
// RegisterChain assigns an active ChainControl instance to a target chain
// identified by its ChainCode.
func (c *ChainRegistry) RegisterChain(newChain ChainCode,
cc *ChainControl) {
c.Lock()
c.activeChains[newChain] = cc
c.Unlock()
}
// LookupChain attempts to lookup an active ChainControl instance for the
// target chain.
func (c *ChainRegistry) LookupChain(targetChain ChainCode) (
*ChainControl, bool) {
c.RLock()
cc, ok := c.activeChains[targetChain]
c.RUnlock()
return cc, ok
}
// LookupChainByHash attempts to look up an active ChainControl which
// corresponds to the passed genesis hash.
func (c *ChainRegistry) LookupChainByHash(
chainHash chainhash.Hash) (*ChainControl, bool) {
c.RLock()
defer c.RUnlock()
targetChain, ok := chainMap[chainHash]
if !ok {
return nil, ok
// checkOutboundPeers checks the number of outbound peers connected to the
// provided RPC client. If the number of outbound peers is below 6, a warning
// is logged. This function is intended to ensure that the chain backend
// maintains a healthy connection to the network.
func checkOutboundPeers(client *rpcclient.Client) error {
peers, err := client.GetPeerInfo()
if err != nil {
return err
}
cc, ok := c.activeChains[targetChain]
return cc, ok
}
// RegisterPrimaryChain sets a target chain as the "home chain" for lnd.
func (c *ChainRegistry) RegisterPrimaryChain(cc ChainCode) {
c.Lock()
defer c.Unlock()
c.primaryChain = cc
}
// PrimaryChain returns the primary chain for this running lnd instance. The
// primary chain is considered the "home base" while the other registered
// chains are treated as secondary chains.
func (c *ChainRegistry) PrimaryChain() ChainCode {
c.RLock()
defer c.RUnlock()
return c.primaryChain
}
// ActiveChains returns a slice containing the active chains.
func (c *ChainRegistry) ActiveChains() []ChainCode {
c.RLock()
defer c.RUnlock()
chains := make([]ChainCode, 0, len(c.activeChains))
for activeChain := range c.activeChains {
chains = append(chains, activeChain)
var outboundPeers int
for _, peer := range peers {
if !peer.Inbound {
outboundPeers++
}
}
return chains
}
if outboundPeers < DefaultMinOutboundPeers {
log.Warnf("The chain backend has an insufficient number "+
"of connected outbound peers (%d connected, expected "+
"minimum is %d) which can be a security issue. "+
"Connect to more trusted nodes manually if necessary.",
outboundPeers, DefaultMinOutboundPeers)
}
// NumActiveChains returns the total number of active chains.
func (c *ChainRegistry) NumActiveChains() uint32 {
c.RLock()
defer c.RUnlock()
return uint32(len(c.activeChains))
return nil
}

View File

@ -4,6 +4,7 @@ import (
"errors"
"time"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
@ -213,4 +214,14 @@ func (n *NoChainSource) BackEnd() string {
return noChainBackendName
}
func (n *NoChainSource) TestMempoolAccept([]*wire.MsgTx,
float64) ([]*btcjson.TestMempoolAcceptResult, error) {
return nil, nil
}
func (n *NoChainSource) MapRPCErr(err error) error {
return err
}
var _ chain.Interface = (*NoChainSource)(nil)

View File

@ -249,6 +249,7 @@ func (r *RPCAcceptor) sendAcceptRequests(errChan chan error,
acceptRequests := make(map[[32]byte]*chanAcceptInfo)
for {
//nolint:lll
select {
// Consume requests passed to us from our Accept() function and
// send them into our stream.
@ -331,6 +332,54 @@ func (r *RPCAcceptor) sendAcceptRequests(errChan chan error,
):
commitmentType = lnrpc.CommitmentType_ANCHORS
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredStaging,
lnwire.ZeroConfRequired,
lnwire.ScidAliasRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredStaging,
lnwire.ZeroConfRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredStaging,
lnwire.ScidAliasRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredStaging,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootOverlayChansRequired,
lnwire.ZeroConfRequired,
lnwire.ScidAliasRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootOverlayChansRequired,
lnwire.ZeroConfRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootOverlayChansRequired,
lnwire.ScidAliasRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootOverlayChansRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY
case channelFeatures.OnlyContains(
lnwire.StaticRemoteKeyRequired,
):

View File

@ -72,7 +72,7 @@ func FetchBackupForChan(chanPoint wire.OutPoint, chanSource LiveChannelSource,
// the source to obtain any extra information that we may need.
staticChanBackup, err := assembleChanBackup(addrSource, targetChan)
if err != nil {
return nil, fmt.Errorf("unable to create chan backup: %v", err)
return nil, fmt.Errorf("unable to create chan backup: %w", err)
}
return staticChanBackup, nil

View File

@ -2,7 +2,6 @@ package chanbackup
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
@ -93,17 +92,18 @@ func (b *MultiFile) UpdateAndSwap(newBackup PackedMulti) error {
var err error
b.tempFile, err = os.Create(b.tempFileName)
if err != nil {
return fmt.Errorf("unable to create temp file: %v", err)
return fmt.Errorf("unable to create temp file: %w", err)
}
// With the file created, we'll write the new packed multi backup and
// remove the temporary file all together once this method exits.
_, err = b.tempFile.Write([]byte(newBackup))
if err != nil {
return fmt.Errorf("unable to write backup to temp file: %v", err)
return fmt.Errorf("unable to write backup to temp file: %w",
err)
}
if err := b.tempFile.Sync(); err != nil {
return fmt.Errorf("unable to sync temp file: %v", err)
return fmt.Errorf("unable to sync temp file: %w", err)
}
defer os.Remove(b.tempFileName)
@ -114,7 +114,7 @@ func (b *MultiFile) UpdateAndSwap(newBackup PackedMulti) error {
// sure to close the current file as some OSes don't support
// renaming a file that's already open (Windows).
if err := b.tempFile.Close(); err != nil {
return fmt.Errorf("unable to close file: %v", err)
return fmt.Errorf("unable to close file: %w", err)
}
// Finally, we'll attempt to atomically rename the temporary file to
@ -137,7 +137,7 @@ func (b *MultiFile) ExtractMulti(keyChain keychain.KeyRing) (*Multi, error) {
// Now that we've confirmed the target file is populated, we'll read
// all the contents of the file. This function ensures that file is
// always closed, even if we can't read the contents.
multiBytes, err := ioutil.ReadFile(b.fileName)
multiBytes, err := os.ReadFile(b.fileName)
if err != nil {
return nil, err
}

View File

@ -3,7 +3,6 @@ package chanbackup
import (
"bytes"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
@ -16,7 +15,7 @@ import (
func makeFakePackedMulti() (PackedMulti, error) {
newPackedMulti := make([]byte, 50)
if _, err := rand.Read(newPackedMulti[:]); err != nil {
return nil, fmt.Errorf("unable to make test backup: %v", err)
return nil, fmt.Errorf("unable to make test backup: %w", err)
}
return PackedMulti(newPackedMulti), nil
@ -27,7 +26,7 @@ func assertBackupMatches(t *testing.T, filePath string,
t.Helper()
packedBackup, err := ioutil.ReadFile(filePath)
packedBackup, err := os.ReadFile(filePath)
require.NoError(t, err, "unable to test file")
if !bytes.Equal(packedBackup, currentBackup) {

View File

@ -27,19 +27,3 @@ func DisableLog() {
func UseLogger(logger btclog.Logger) {
log = logger
}
// logClosure is used to provide a closure over expensive logging operations so
// don't have to be performed when the logging level doesn't warrant it.
type logClosure func() string
// String invokes the underlying function and returns the result.
func (c logClosure) String() string {
return c()
}
// newLogClosure returns a new closure over a function that returns a string
// which itself provides a Stringer interface so that it can be used with the
// logging system.
func newLogClosure(c func() string) logClosure {
return logClosure(c)
}

View File

@ -92,7 +92,7 @@ func (m Multi) PackToWriter(w io.Writer, keyRing keychain.KeyRing) error {
// directly to the passed writer.
e, err := lnencrypt.KeyRingEncrypter(keyRing)
if err != nil {
return fmt.Errorf("unable to generate encrypt key %v", err)
return fmt.Errorf("unable to generate encrypt key %w", err)
}
return e.EncryptPayloadToWriter(multiBackupBuffer.Bytes(), w)
@ -107,7 +107,7 @@ func (m *Multi) UnpackFromReader(r io.Reader, keyRing keychain.KeyRing) error {
// encryption keys.
e, err := lnencrypt.KeyRingEncrypter(keyRing)
if err != nil {
return fmt.Errorf("unable to generate encrypt key %v", err)
return fmt.Errorf("unable to generate encrypt key %w", err)
}
plaintextBackup, err := e.DecryptPayloadFromReader(r)
if err != nil {

View File

@ -10,6 +10,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnutils"
)
// Swapper is an interface that allows the chanbackup.SubSwapper to update the
@ -158,7 +159,8 @@ func (s *SubSwapper) Start() error {
// Stop signals the SubSwapper to being a graceful shutdown.
func (s *SubSwapper) Stop() error {
s.stopped.Do(func() {
log.Infof("Stopping chanbackup.SubSwapper")
log.Infof("chanbackup.SubSwapper shutting down...")
defer log.Debug("chanbackup.SubSwapper shutdown complete")
close(s.quit)
s.wg.Wait()
@ -225,7 +227,7 @@ func (s *SubSwapper) updateBackupFile(closedChans ...wire.OutPoint) error {
var b bytes.Buffer
err = newMulti.PackToWriter(&b, s.keyRing)
if err != nil {
return fmt.Errorf("unable to pack multi backup: %v", err)
return fmt.Errorf("unable to pack multi backup: %w", err)
}
// Finally, we'll swap out the old backup for this new one in a single
@ -233,7 +235,7 @@ func (s *SubSwapper) updateBackupFile(closedChans ...wire.OutPoint) error {
// channels.
err = s.Swapper.UpdateAndSwap(PackedMulti(b.Bytes()))
if err != nil {
return fmt.Errorf("unable to update multi backup: %v", err)
return fmt.Errorf("unable to update multi backup: %w", err)
}
return nil
@ -277,9 +279,8 @@ func (s *SubSwapper) backupUpdater() {
)
for i, closedChan := range chanUpdate.ClosedChans {
log.Debugf("Removing channel %v from backup "+
"state", newLogClosure(func() string {
return chanUpdate.ClosedChans[i].String()
}))
"state", lnutils.NewLogClosure(
chanUpdate.ClosedChans[i].String))
delete(s.backupState, closedChan)

View File

@ -36,7 +36,7 @@ func (m *mockSwapper) UpdateAndSwap(newBackup PackedMulti) error {
swapState, err := newBackup.Unpack(m.keyChain)
if err != nil {
return fmt.Errorf("unable to decode on disk swaps: %v", err)
return fmt.Errorf("unable to decode on disk swaps: %w", err)
}
m.swapState = swapState

View File

@ -4,9 +4,9 @@ import (
"net"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnutils"
)
// ChannelRestorer is an interface that allows the Recover method to map the
@ -63,9 +63,8 @@ func Recover(backups []Single, restorer ChannelRestorer,
log.Infof("Attempting to connect to node=%x (addrs=%v) to "+
"restore ChannelPoint(%v)",
backup.RemoteNodePub.SerializeCompressed(),
newLogClosure(func() string {
return spew.Sdump(backups[i].Addresses)
}), backup.FundingOutpoint)
lnutils.SpewLogClosure(backups[i].Addresses),
backup.FundingOutpoint)
err = peerConnector.ConnectPeer(
backup.RemoteNodePub, backup.Addresses,

View File

@ -48,6 +48,10 @@ const (
// commitment and HTLC outputs that pay directly to the channel
// initiator.
ScriptEnforcedLeaseVersion = 4
// SimpleTaprootVersion is a version that denotes this channel is using
// the musig2 based taproot commitment format.
SimpleTaprootVersion = 5
)
// Single is a static description of an existing channel that can be used for
@ -213,6 +217,9 @@ func NewSingle(channel *channeldb.OpenChannel,
}
switch {
case channel.ChanType.IsTaproot():
single.Version = SimpleTaprootVersion
case channel.ChanType.HasLeaseExpiration():
single.Version = ScriptEnforcedLeaseVersion
single.LeaseExpiry = channel.ThawHeight
@ -244,6 +251,7 @@ func (s *Single) Serialize(w io.Writer) error {
case AnchorsCommitVersion:
case AnchorsZeroFeeHtlcTxCommitVersion:
case ScriptEnforcedLeaseVersion:
case SimpleTaprootVersion:
default:
return fmt.Errorf("unable to serialize w/ unknown "+
"version: %v", s.Version)
@ -354,7 +362,7 @@ func (s *Single) PackToWriter(w io.Writer, keyRing keychain.KeyRing) error {
// nonce that we used to the passed io.Reader.
e, err := lnencrypt.KeyRingEncrypter(keyRing)
if err != nil {
return fmt.Errorf("unable to generate encrypt key %v", err)
return fmt.Errorf("unable to generate encrypt key %w", err)
}
return e.EncryptPayloadToWriter(rawBytes.Bytes(), w)
}
@ -420,6 +428,7 @@ func (s *Single) Deserialize(r io.Reader) error {
case AnchorsCommitVersion:
case AnchorsZeroFeeHtlcTxCommitVersion:
case ScriptEnforcedLeaseVersion:
case SimpleTaprootVersion:
default:
return fmt.Errorf("unable to de-serialize w/ unknown "+
"version: %v", s.Version)
@ -535,7 +544,7 @@ func (s *Single) Deserialize(r io.Reader) error {
func (s *Single) UnpackFromReader(r io.Reader, keyRing keychain.KeyRing) error {
e, err := lnencrypt.KeyRingEncrypter(keyRing)
if err != nil {
return fmt.Errorf("unable to generate key decrypter %v", err)
return fmt.Errorf("unable to generate key decrypter %w", err)
}
plaintext, err := e.DecryptPayloadFromReader(r)
if err != nil {

View File

@ -126,6 +126,64 @@ func genRandomOpenChannelShell() (*channeldb.OpenChannel, error) {
chanType := channeldb.ChannelType(rand.Intn(8))
localCfg := channeldb.ChannelConfig{
ChannelStateBounds: channeldb.ChannelStateBounds{},
CommitmentParams: channeldb.CommitmentParams{
CsvDelay: uint16(rand.Int63()),
},
MultiSigKey: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
RevocationBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
PaymentBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
DelayBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
HtlcBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
}
remoteCfg := channeldb.ChannelConfig{
CommitmentParams: channeldb.CommitmentParams{
CsvDelay: uint16(rand.Int63()),
},
MultiSigKey: keychain.KeyDescriptor{
PubKey: pub,
},
RevocationBasePoint: keychain.KeyDescriptor{
PubKey: pub,
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: pub,
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: pub,
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: pub,
},
}
return &channeldb.OpenChannel{
ChainHash: chainHash,
ChanType: chanType,
@ -134,63 +192,10 @@ func genRandomOpenChannelShell() (*channeldb.OpenChannel, error) {
ShortChannelID: lnwire.NewShortChanIDFromInt(
uint64(rand.Int63()),
),
ThawHeight: rand.Uint32(),
IdentityPub: pub,
LocalChanCfg: channeldb.ChannelConfig{
ChannelConstraints: channeldb.ChannelConstraints{
CsvDelay: uint16(rand.Int63()),
},
MultiSigKey: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
RevocationBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
PaymentBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
DelayBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
HtlcBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
Index: uint32(rand.Int63()),
},
},
},
RemoteChanCfg: channeldb.ChannelConfig{
ChannelConstraints: channeldb.ChannelConstraints{
CsvDelay: uint16(rand.Int63()),
},
MultiSigKey: keychain.KeyDescriptor{
PubKey: pub,
},
RevocationBasePoint: keychain.KeyDescriptor{
PubKey: pub,
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: pub,
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: pub,
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: pub,
},
},
ThawHeight: rand.Uint32(),
IdentityPub: pub,
LocalChanCfg: localCfg,
RemoteChanCfg: remoteCfg,
RevocationProducer: shaChainProducer,
}, nil
}

View File

@ -12,7 +12,9 @@ package chanfitness
import (
"errors"
"fmt"
"sync"
"sync/atomic"
"time"
"github.com/btcsuite/btcd/wire"
@ -48,6 +50,9 @@ var (
// ChannelEventStore maintains a set of event logs for the node's channels to
// provide insight into the performance and health of channels.
type ChannelEventStore struct {
started atomic.Bool
stopped atomic.Bool
cfg *Config
// peers tracks all of our currently monitored peers and their channels.
@ -85,7 +90,7 @@ type Config struct {
// for ease of testing.
Clock clock.Clock
// WriteFlapCounts records the flap count for a set of peers on disk.
// WriteFlapCount records the flap count for a set of peers on disk.
WriteFlapCount func(map[route.Vertex]*channeldb.FlapCount) error
// ReadFlapCount gets the flap count for a peer on disk.
@ -142,7 +147,11 @@ func NewChannelEventStore(config *Config) *ChannelEventStore {
// information from the store. If this function fails, it cancels its existing
// subscriptions and returns an error.
func (c *ChannelEventStore) Start() error {
log.Info("ChannelEventStore starting")
log.Info("ChannelEventStore starting...")
if c.started.Swap(true) {
return fmt.Errorf("ChannelEventStore started more than once")
}
// Create a subscription to channel events.
channelClient, err := c.cfg.SubscribeChannelEvents()
@ -198,12 +207,18 @@ func (c *ChannelEventStore) Start() error {
cancel: cancel,
})
log.Debug("ChannelEventStore started")
return nil
}
// Stop terminates all goroutines started by the event store.
func (c *ChannelEventStore) Stop() {
log.Info("Stopping event store")
func (c *ChannelEventStore) Stop() error {
log.Info("ChannelEventStore shutting down...")
if c.stopped.Swap(true) {
return fmt.Errorf("ChannelEventStore stopped more than once")
}
// Stop the consume goroutine.
close(c.quit)
@ -211,7 +226,17 @@ func (c *ChannelEventStore) Stop() {
// Stop the ticker after the goroutine reading from it has exited, to
// avoid a race.
c.cfg.FlapCountTicker.Stop()
var err error
if c.cfg.FlapCountTicker == nil {
err = fmt.Errorf("ChannelEventStore FlapCountTicker not " +
"initialized")
} else {
c.cfg.FlapCountTicker.Stop()
}
log.Debugf("ChannelEventStore shutdown complete")
return err
}
// addChannel checks whether we are already tracking a channel's peer, creates a

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,8 @@ package channeldb
import (
"reflect"
"testing"
"github.com/lightningnetwork/lnd/channeldb/models"
)
// TestChannelCache checks the behavior of the channelCache with respect to
@ -98,7 +100,7 @@ func assertHasChanEntries(t *testing.T, c *channelCache, start, end uint64) {
// channelForInt generates a unique ChannelEdge given an integer.
func channelForInt(i uint64) ChannelEdge {
return ChannelEdge{
Info: &ChannelEdgeInfo{
Info: &models.ChannelEdgeInfo{
ChannelID: i,
},
}

View File

@ -17,11 +17,15 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnmock"
"github.com/lightningnetwork/lnd/lntest/channels"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain"
"github.com/lightningnetwork/lnd/tlv"
"github.com/stretchr/testify/require"
)
@ -170,7 +174,7 @@ func fundingPointOption(chanPoint wire.OutPoint) testChannelOption {
}
// channelIDOption is an option which sets the short channel ID of the channel.
var channelIDOption = func(chanID lnwire.ShortChannelID) testChannelOption {
func channelIDOption(chanID lnwire.ShortChannelID) testChannelOption {
return func(params *testChannelParams) {
params.channel.ShortChannelID = chanID
}
@ -232,15 +236,21 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
}
}
localStateBounds := ChannelStateBounds{
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
ChanReserve: btcutil.Amount(rand.Int63()),
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()),
}
localRenderingParams := CommitmentParams{
DustLimit: btcutil.Amount(rand.Int63()),
CsvDelay: uint16(rand.Int31()),
}
localCfg := ChannelConfig{
ChannelConstraints: ChannelConstraints{
DustLimit: btcutil.Amount(rand.Int63()),
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
ChanReserve: btcutil.Amount(rand.Int63()),
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()),
CsvDelay: uint16(rand.Int31()),
},
ChannelStateBounds: localStateBounds,
CommitmentParams: localRenderingParams,
MultiSigKey: keychain.KeyDescriptor{
PubKey: privKey.PubKey(),
},
@ -257,15 +267,22 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
PubKey: privKey.PubKey(),
},
}
remoteStateBounds := ChannelStateBounds{
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
ChanReserve: btcutil.Amount(rand.Int63()),
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()),
}
remoteRenderingParams := CommitmentParams{
DustLimit: btcutil.Amount(rand.Int63()),
CsvDelay: uint16(rand.Int31()),
}
remoteCfg := ChannelConfig{
ChannelConstraints: ChannelConstraints{
DustLimit: btcutil.Amount(rand.Int63()),
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
ChanReserve: btcutil.Amount(rand.Int63()),
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()),
CsvDelay: uint16(rand.Int31()),
},
ChannelStateBounds: remoteStateBounds,
CommitmentParams: remoteRenderingParams,
MultiSigKey: keychain.KeyDescriptor{
PubKey: privKey.PubKey(),
KeyLocator: keychain.KeyLocator{
@ -310,6 +327,9 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
uniqueOutputIndex.Add(1)
op := wire.OutPoint{Hash: key, Index: uniqueOutputIndex.Load()}
var tapscriptRoot chainhash.Hash
copy(tapscriptRoot[:], bytes.Repeat([]byte{1}, 32))
return &OpenChannel{
ChanType: SingleFunderBit | FrozenBit,
ChainHash: key,
@ -331,6 +351,7 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
FeePerKw: btcutil.Amount(5000),
CommitTx: channels.TestFundingTx,
CommitSig: bytes.Repeat([]byte{1}, 71),
CustomBlob: fn.Some([]byte{1, 2, 3}),
},
RemoteCommitment: ChannelCommitment{
CommitHeight: 0,
@ -340,6 +361,7 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
FeePerKw: btcutil.Amount(5000),
CommitTx: channels.TestFundingTx,
CommitSig: bytes.Repeat([]byte{1}, 71),
CustomBlob: fn.Some([]byte{4, 5, 6}),
},
NumConfsRequired: 4,
RemoteCurrentRevocation: privKey.PubKey(),
@ -352,6 +374,9 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
ThawHeight: uint32(defaultPendingHeight),
InitialLocalBalance: lnwire.MilliSatoshi(9000),
InitialRemoteBalance: lnwire.MilliSatoshi(3000),
Memo: []byte("test"),
TapscriptRoot: fn.Some(tapscriptRoot),
CustomBlob: fn.Some([]byte{1, 2, 3}),
}
}
@ -366,12 +391,13 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
// Create the test channel state, with additional htlcs on the local
// and remote commitment.
localHtlcs := []HTLC{
{Signature: testSig.Serialize(),
{
Signature: testSig.Serialize(),
Incoming: true,
Amt: 10,
RHash: key,
RefundTimeout: 1,
OnionBlob: []byte("onionblob"),
OnionBlob: lnmock.MockOnion(),
},
}
@ -382,7 +408,7 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
Amt: 10,
RHash: key,
RefundTimeout: 1,
OnionBlob: []byte("onionblob"),
OnionBlob: lnmock.MockOnion(),
},
}
@ -558,24 +584,32 @@ func assertCommitmentEqual(t *testing.T, a, b *ChannelCommitment) {
func assertRevocationLogEntryEqual(t *testing.T, c *ChannelCommitment,
r *RevocationLog) {
t.Helper()
// Check the common fields.
require.EqualValues(
t, r.CommitTxHash, c.CommitTx.TxHash(), "CommitTx mismatch",
t, r.CommitTxHash.Val, c.CommitTx.TxHash(), "CommitTx mismatch",
)
// Now check the common fields from the HTLCs.
require.Equal(t, len(r.HTLCEntries), len(c.Htlcs), "HTLCs len mismatch")
for i, rHtlc := range r.HTLCEntries {
cHtlc := c.Htlcs[i]
require.Equal(t, rHtlc.RHash, cHtlc.RHash, "RHash mismatch")
require.Equal(t, rHtlc.Amt, cHtlc.Amt.ToSatoshis(),
"Amt mismatch")
require.Equal(t, rHtlc.RefundTimeout, cHtlc.RefundTimeout,
"RefundTimeout mismatch")
require.EqualValues(t, rHtlc.OutputIndex, cHtlc.OutputIndex,
"OutputIndex mismatch")
require.Equal(t, rHtlc.Incoming, cHtlc.Incoming,
"Incoming mismatch")
require.Equal(t, rHtlc.RHash.Val[:], cHtlc.RHash[:], "RHash")
require.Equal(
t, rHtlc.Amt.Val.Int(), cHtlc.Amt.ToSatoshis(), "Amt",
)
require.Equal(
t, rHtlc.RefundTimeout.Val, cHtlc.RefundTimeout,
"RefundTimeout",
)
require.EqualValues(
t, rHtlc.OutputIndex.Val, cHtlc.OutputIndex,
"OutputIndex",
)
require.Equal(
t, rHtlc.Incoming.Val, cHtlc.Incoming, "Incoming",
)
}
}
@ -612,8 +646,10 @@ func TestChannelStateTransition(t *testing.T) {
LogIndex: uint64(i * 2),
HtlcIndex: uint64(i),
}
htlc.OnionBlob = make([]byte, 10)
copy(htlc.OnionBlob[:], bytes.Repeat([]byte{2}, 10))
copy(
htlc.OnionBlob[:],
bytes.Repeat([]byte{2}, lnwire.OnionPacketSize),
)
htlcs = append(htlcs, htlc)
htlcAmt += htlc.Amt
}
@ -638,6 +674,7 @@ func TestChannelStateTransition(t *testing.T) {
CommitTx: newTx,
CommitSig: newSig,
Htlcs: htlcs,
CustomBlob: fn.Some([]byte{4, 5, 6}),
}
// First update the local node's broadcastable state and also add a
@ -647,8 +684,7 @@ func TestChannelStateTransition(t *testing.T) {
{
LogIndex: 2,
UpdateMsg: &lnwire.UpdateAddHTLC{
ChanID: lnwire.ChannelID{1, 2, 3},
ExtraData: make([]byte, 0),
ChanID: lnwire.ChannelID{1, 2, 3},
},
},
}
@ -676,9 +712,14 @@ func TestChannelStateTransition(t *testing.T) {
// have been updated.
updatedChannel, err := cdb.FetchOpenChannels(channel.IdentityPub)
require.NoError(t, err, "unable to fetch updated channel")
assertCommitmentEqual(t, &commitment, &updatedChannel[0].LocalCommitment)
assertCommitmentEqual(
t, &commitment, &updatedChannel[0].LocalCommitment,
)
numDiskUpdates, err := updatedChannel[0].CommitmentHeight()
require.NoError(t, err, "unable to read commitment height from disk")
if numDiskUpdates != uint64(commitment.CommitHeight) {
t.Fatalf("num disk updates doesn't match: %v vs %v",
numDiskUpdates, commitment.CommitHeight)
@ -706,25 +747,22 @@ func TestChannelStateTransition(t *testing.T) {
wireSig,
wireSig,
},
ExtraData: make([]byte, 0),
},
LogUpdates: []LogUpdate{
{
LogIndex: 1,
UpdateMsg: &lnwire.UpdateAddHTLC{
ID: 1,
Amount: lnwire.NewMSatFromSatoshis(100),
Expiry: 25,
ExtraData: make([]byte, 0),
ID: 1,
Amount: lnwire.NewMSatFromSatoshis(100),
Expiry: 25,
},
},
{
LogIndex: 2,
UpdateMsg: &lnwire.UpdateAddHTLC{
ID: 2,
Amount: lnwire.NewMSatFromSatoshis(200),
Expiry: 50,
ExtraData: make([]byte, 0),
ID: 2,
Amount: lnwire.NewMSatFromSatoshis(200),
Expiry: 50,
},
},
},
@ -784,10 +822,10 @@ func TestChannelStateTransition(t *testing.T) {
// Check the output indexes are saved as expected.
require.EqualValues(
t, dummyLocalOutputIndex, diskPrevCommit.OurOutputIndex,
t, dummyLocalOutputIndex, diskPrevCommit.OurOutputIndex.Val,
)
require.EqualValues(
t, dummyRemoteOutIndex, diskPrevCommit.TheirOutputIndex,
t, dummyRemoteOutIndex, diskPrevCommit.TheirOutputIndex.Val,
)
// The two deltas (the original vs the on-disk version) should
@ -829,10 +867,10 @@ func TestChannelStateTransition(t *testing.T) {
// Check the output indexes are saved as expected.
require.EqualValues(
t, dummyLocalOutputIndex, diskPrevCommit.OurOutputIndex,
t, dummyLocalOutputIndex, diskPrevCommit.OurOutputIndex.Val,
)
require.EqualValues(
t, dummyRemoteOutIndex, diskPrevCommit.TheirOutputIndex,
t, dummyRemoteOutIndex, diskPrevCommit.TheirOutputIndex.Val,
)
assertRevocationLogEntryEqual(t, &oldRemoteCommit, prevCommit)
@ -1083,13 +1121,17 @@ func TestFetchWaitingCloseChannels(t *testing.T) {
},
)
if err := channel.MarkCommitmentBroadcasted(closeTx, true); err != nil {
if err := channel.MarkCommitmentBroadcasted(
closeTx, lntypes.Local,
); err != nil {
t.Fatalf("unable to mark commitment broadcast: %v", err)
}
// Now try to marking a coop close with a nil tx. This should
// succeed, but it shouldn't exit when queried.
if err = channel.MarkCoopBroadcasted(nil, true); err != nil {
if err = channel.MarkCoopBroadcasted(
nil, lntypes.Local,
); err != nil {
t.Fatalf("unable to mark nil coop broadcast: %v", err)
}
_, err := channel.BroadcastedCooperative()
@ -1101,7 +1143,9 @@ func TestFetchWaitingCloseChannels(t *testing.T) {
// it as coop closed. Later we will test that distinct
// transactions are returned for both coop and force closes.
closeTx.TxIn[0].PreviousOutPoint.Index ^= 1
if err := channel.MarkCoopBroadcasted(closeTx, true); err != nil {
if err := channel.MarkCoopBroadcasted(
closeTx, lntypes.Local,
); err != nil {
t.Fatalf("unable to mark coop broadcast: %v", err)
}
}
@ -1154,6 +1198,70 @@ func TestFetchWaitingCloseChannels(t *testing.T) {
}
}
// TestShutdownInfo tests that a channel's shutdown info can correctly be
// persisted and retrieved.
func TestShutdownInfo(t *testing.T) {
t.Parallel()
tests := []struct {
name string
localInit bool
}{
{
name: "local node initiated",
localInit: true,
},
{
name: "remote node initiated",
localInit: false,
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
testShutdownInfo(t, test.localInit)
})
}
}
func testShutdownInfo(t *testing.T, locallyInitiated bool) {
fullDB, err := MakeTestDB(t)
require.NoError(t, err, "unable to make test database")
cdb := fullDB.ChannelStateDB()
// First a test channel.
channel := createTestChannel(t, cdb)
// We haven't persisted any shutdown info for this channel yet.
_, err = channel.ShutdownInfo()
require.Error(t, err, ErrNoShutdownInfo)
// Construct a new delivery script and create a new ShutdownInfo object.
script := []byte{1, 3, 4, 5}
// Create a ShutdownInfo struct.
shutdownInfo := NewShutdownInfo(script, locallyInitiated)
// Persist the shutdown info.
require.NoError(t, channel.MarkShutdownSent(shutdownInfo))
// We should now be able to retrieve the shutdown info.
info, err := channel.ShutdownInfo()
require.NoError(t, err)
require.True(t, info.IsSome())
// Assert that the decoded values of the shutdown info are correct.
info.WhenSome(func(info ShutdownInfo) {
require.EqualValues(t, script, info.DeliveryScript.Val)
require.Equal(t, locallyInitiated, info.LocalInitiator.Val)
})
}
// TestRefresh asserts that Refresh updates the in-memory state of another
// OpenChannel to reflect a preceding call to MarkOpen on a different
// OpenChannel.
@ -1259,7 +1367,7 @@ func TestCloseInitiator(t *testing.T) {
// by the local party.
updateChannel: func(c *OpenChannel) error {
return c.MarkCoopBroadcasted(
&wire.MsgTx{}, true,
&wire.MsgTx{}, lntypes.Local,
)
},
expectedStatuses: []ChannelStatus{
@ -1273,7 +1381,7 @@ func TestCloseInitiator(t *testing.T) {
// by the remote party.
updateChannel: func(c *OpenChannel) error {
return c.MarkCoopBroadcasted(
&wire.MsgTx{}, false,
&wire.MsgTx{}, lntypes.Remote,
)
},
expectedStatuses: []ChannelStatus{
@ -1287,7 +1395,7 @@ func TestCloseInitiator(t *testing.T) {
// local initiator.
updateChannel: func(c *OpenChannel) error {
return c.MarkCommitmentBroadcasted(
&wire.MsgTx{}, true,
&wire.MsgTx{}, lntypes.Local,
)
},
expectedStatuses: []ChannelStatus{
@ -1527,3 +1635,130 @@ func TestFinalHtlcs(t *testing.T) {
_, err = cdb.LookupFinalHtlc(chanID, unknownHtlcID)
require.ErrorIs(t, err, ErrHtlcUnknown)
}
// TestHTLCsExtraData tests serialization and deserialization of HTLCs
// combined with extra data.
func TestHTLCsExtraData(t *testing.T) {
t.Parallel()
mockHtlc := HTLC{
Signature: testSig.Serialize(),
Incoming: false,
Amt: 10,
RHash: key,
RefundTimeout: 1,
OnionBlob: lnmock.MockOnion(),
}
// Add a blinding point to a htlc.
blindingPointHTLC := HTLC{
Signature: testSig.Serialize(),
Incoming: false,
Amt: 10,
RHash: key,
RefundTimeout: 1,
OnionBlob: lnmock.MockOnion(),
BlindingPoint: tlv.SomeRecordT(
tlv.NewPrimitiveRecord[lnwire.BlindingPointTlvType](
pubKey,
),
),
}
// Custom channel data htlc with a blinding point.
customDataHTLC := HTLC{
Signature: testSig.Serialize(),
Incoming: false,
Amt: 10,
RHash: key,
RefundTimeout: 1,
OnionBlob: lnmock.MockOnion(),
BlindingPoint: tlv.SomeRecordT(
tlv.NewPrimitiveRecord[lnwire.BlindingPointTlvType](
pubKey,
),
),
CustomRecords: map[uint64][]byte{
uint64(lnwire.MinCustomRecordsTlvType + 3): {1, 2, 3},
},
}
testCases := []struct {
name string
htlcs []HTLC
blindingIdx int
}{
{
// Serialize multiple HLTCs with no extra data to
// assert that there is no regression for HTLCs with
// no extra data.
name: "no extra data",
htlcs: []HTLC{
mockHtlc, mockHtlc,
},
},
{
// Some HTLCs with extra data, some without.
name: "mixed extra data",
htlcs: []HTLC{
mockHtlc,
blindingPointHTLC,
mockHtlc,
customDataHTLC,
},
},
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
var b bytes.Buffer
err := SerializeHtlcs(&b, testCase.htlcs...)
require.NoError(t, err)
r := bytes.NewReader(b.Bytes())
htlcs, err := DeserializeHtlcs(r)
require.NoError(t, err)
require.EqualValues(t, len(testCase.htlcs), len(htlcs))
for i, htlc := range htlcs {
// We use the extra data field when we
// serialize, so we set to nil to be able to
// assert on equal for the test.
htlc.ExtraData = nil
require.Equal(t, testCase.htlcs[i], htlc)
}
})
}
}
// TestOnionBlobIncorrectLength tests HTLC deserialization in the case where
// the OnionBlob saved on disk is of an unexpected length. This error case is
// only expected in the case of database corruption (or some severe protocol
// breakdown/bug). A HTLC is manually serialized because we cannot force a
// case where we write an onion blob of incorrect length.
func TestOnionBlobIncorrectLength(t *testing.T) {
t.Parallel()
var b bytes.Buffer
var numHtlcs uint16 = 1
require.NoError(t, WriteElement(&b, numHtlcs))
require.NoError(t, WriteElements(
&b,
// Number of HTLCs.
numHtlcs,
// Signature, incoming, amount, Rhash, Timeout.
testSig.Serialize(), false, lnwire.MilliSatoshi(10), key,
uint32(1),
// Write an onion blob that is half of our expected size.
bytes.Repeat([]byte{1}, lnwire.OnionPacketSize/2),
))
_, err := DeserializeHtlcs(&b)
require.ErrorIs(t, err, ErrOnionBlobLength)
}

View File

@ -78,7 +78,8 @@ func WriteElement(w io.Writer, element interface{}) error {
if e.PubKey != nil {
if err := binary.Write(w, byteOrder, true); err != nil {
return fmt.Errorf("error writing serialized element: %s", err)
return fmt.Errorf("error writing serialized "+
"element: %w", err)
}
return WriteElement(w, e.PubKey)

View File

@ -10,6 +10,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/walletdb"
"github.com/go-errors/errors"
mig "github.com/lightningnetwork/lnd/channeldb/migration"
"github.com/lightningnetwork/lnd/channeldb/migration12"
@ -24,8 +25,10 @@ import (
"github.com/lightningnetwork/lnd/channeldb/migration27"
"github.com/lightningnetwork/lnd/channeldb/migration29"
"github.com/lightningnetwork/lnd/channeldb/migration30"
"github.com/lightningnetwork/lnd/channeldb/migration31"
"github.com/lightningnetwork/lnd/channeldb/migration_01_to_11"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
@ -275,6 +278,14 @@ var (
number: 29,
migration: migration29.MigrateChanID,
},
{
// Removes the "sweeper-last-tx" bucket. Although we
// do not have a mandatory version 30 we skip this
// version because its naming is already used for the
// first optional migration.
number: 31,
migration: migration31.DeleteLastPublishedTxTLB,
},
}
// optionalVersions stores all optional migrations that are applied
@ -302,11 +313,6 @@ var (
// channelOpeningState for each channel that is currently in the process
// of being opened.
channelOpeningStateBucket = []byte("channelOpeningState")
// initialChannelFwdingPolicyBucket is the database bucket used to store
// the forwarding policy for each permanent channel that is currently
// in the process of being opened.
initialChannelFwdingPolicyBucket = []byte("initialChannelFwdingPolicy")
)
// DB is the primary datastore for the lnd daemon. The database stores
@ -491,7 +497,7 @@ func initChannelDB(db kvdb.Backend) error {
return putMeta(meta, tx)
}, func() {})
if err != nil {
return fmt.Errorf("unable to create new channeldb: %v", err)
return fmt.Errorf("unable to create new channeldb: %w", err)
}
return nil
@ -637,7 +643,7 @@ func (c *ChannelStateDB) fetchNodeChannels(chainBucket kvdb.RBucket) (
oChannel, err := fetchOpenChannel(chanBucket, &outPoint)
if err != nil {
return fmt.Errorf("unable to read channel data for "+
"chan_point=%v: %v", outPoint, err)
"chan_point=%v: %w", outPoint, err)
}
oChannel.Db = c
@ -654,20 +660,94 @@ func (c *ChannelStateDB) fetchNodeChannels(chainBucket kvdb.RBucket) (
// FetchChannel attempts to locate a channel specified by the passed channel
// point. If the channel cannot be found, then an error will be returned.
// Optionally an existing db tx can be supplied. Optionally an existing db tx
// can be supplied.
// Optionally an existing db tx can be supplied.
func (c *ChannelStateDB) FetchChannel(tx kvdb.RTx, chanPoint wire.OutPoint) (
*OpenChannel, error) {
var (
targetChan *OpenChannel
targetChanPoint bytes.Buffer
)
var targetChanPoint bytes.Buffer
if err := writeOutpoint(&targetChanPoint, &chanPoint); err != nil {
return nil, err
}
targetChanPointBytes := targetChanPoint.Bytes()
selector := func(chainBkt walletdb.ReadBucket) ([]byte, *wire.OutPoint,
error) {
return targetChanPointBytes, &chanPoint, nil
}
return c.channelScanner(tx, selector)
}
// FetchChannelByID attempts to locate a channel specified by the passed channel
// ID. If the channel cannot be found, then an error will be returned.
// Optionally an existing db tx can be supplied.
func (c *ChannelStateDB) FetchChannelByID(tx kvdb.RTx, id lnwire.ChannelID) (
*OpenChannel, error) {
selector := func(chainBkt walletdb.ReadBucket) ([]byte, *wire.OutPoint,
error) {
var (
targetChanPointBytes []byte
targetChanPoint *wire.OutPoint
// errChanFound is used to signal that the channel has
// been found so that iteration through the DB buckets
// can stop.
errChanFound = errors.New("channel found")
)
err := chainBkt.ForEach(func(k, _ []byte) error {
var outPoint wire.OutPoint
err := readOutpoint(bytes.NewReader(k), &outPoint)
if err != nil {
return err
}
chanID := lnwire.NewChanIDFromOutPoint(outPoint)
if chanID != id {
return nil
}
targetChanPoint = &outPoint
targetChanPointBytes = k
return errChanFound
})
if err != nil && !errors.Is(err, errChanFound) {
return nil, nil, err
}
if targetChanPoint == nil {
return nil, nil, ErrChannelNotFound
}
return targetChanPointBytes, targetChanPoint, nil
}
return c.channelScanner(tx, selector)
}
// channelSelector describes a function that takes a chain-hash bucket from
// within the open-channel DB and returns the wanted channel point bytes, and
// channel point. It must return the ErrChannelNotFound error if the wanted
// channel is not in the given bucket.
type channelSelector func(chainBkt walletdb.ReadBucket) ([]byte, *wire.OutPoint,
error)
// channelScanner will traverse the DB to each chain-hash bucket of each node
// pub-key bucket in the open-channel-bucket. The chanSelector will then be used
// to fetch the wanted channel outpoint from the chain bucket.
func (c *ChannelStateDB) channelScanner(tx kvdb.RTx,
chanSelect channelSelector) (*OpenChannel, error) {
var (
targetChan *OpenChannel
// errChanFound is used to signal that the channel has been
// found so that iteration through the DB buckets can stop.
errChanFound = errors.New("channel found")
)
// chanScan will traverse the following bucket structure:
// * nodePub => chainHash => chanPoint
//
@ -685,8 +765,8 @@ func (c *ChannelStateDB) FetchChannel(tx kvdb.RTx, chanPoint wire.OutPoint) (
}
// Within the node channel bucket, are the set of node pubkeys
// we have channels with, we don't know the entire set, so
// we'll check them all.
// we have channels with, we don't know the entire set, so we'll
// check them all.
return openChanBucket.ForEach(func(nodePub, v []byte) error {
// Ensure that this is a key the same size as a pubkey,
// and also that it leads directly to a bucket.
@ -694,7 +774,9 @@ func (c *ChannelStateDB) FetchChannel(tx kvdb.RTx, chanPoint wire.OutPoint) (
return nil
}
nodeChanBucket := openChanBucket.NestedReadBucket(nodePub)
nodeChanBucket := openChanBucket.NestedReadBucket(
nodePub,
)
if nodeChanBucket == nil {
return nil
}
@ -715,20 +797,30 @@ func (c *ChannelStateDB) FetchChannel(tx kvdb.RTx, chanPoint wire.OutPoint) (
)
if chainBucket == nil {
return fmt.Errorf("unable to read "+
"bucket for chain=%x", chainHash[:])
"bucket for chain=%x",
chainHash)
}
// Finally we reach the leaf bucket that stores
// Finally, we reach the leaf bucket that stores
// all the chanPoints for this node.
targetChanBytes, chanPoint, err := chanSelect(
chainBucket,
)
if errors.Is(err, ErrChannelNotFound) {
return nil
} else if err != nil {
return err
}
chanBucket := chainBucket.NestedReadBucket(
targetChanPoint.Bytes(),
targetChanBytes,
)
if chanBucket == nil {
return nil
}
channel, err := fetchOpenChannel(
chanBucket, &chanPoint,
chanBucket, chanPoint,
)
if err != nil {
return err
@ -737,7 +829,7 @@ func (c *ChannelStateDB) FetchChannel(tx kvdb.RTx, chanPoint wire.OutPoint) (
targetChan = channel
targetChan.Db = c
return nil
return errChanFound
})
})
}
@ -748,7 +840,7 @@ func (c *ChannelStateDB) FetchChannel(tx kvdb.RTx, chanPoint wire.OutPoint) (
} else {
err = chanScan(tx)
}
if err != nil {
if err != nil && !errors.Is(err, errChanFound) {
return nil, err
}
@ -757,7 +849,7 @@ func (c *ChannelStateDB) FetchChannel(tx kvdb.RTx, chanPoint wire.OutPoint) (
}
// If we can't find the channel, then we return with an error, as we
// have nothing to backup.
// have nothing to back up.
return nil, ErrChannelNotFound
}
@ -1337,64 +1429,6 @@ func (c *ChannelStateDB) AbandonChannel(chanPoint *wire.OutPoint,
return dbChan.CloseChannel(summary, ChanStatusLocalCloseInitiator)
}
// SaveInitialFwdingPolicy saves the serialized forwarding policy for the
// provided permanent channel id to the initialChannelFwdingPolicyBucket.
func (c *ChannelStateDB) SaveInitialFwdingPolicy(chanID,
forwardingPolicy []byte) error {
return kvdb.Update(c.backend, func(tx kvdb.RwTx) error {
bucket, err := tx.CreateTopLevelBucket(
initialChannelFwdingPolicyBucket,
)
if err != nil {
return err
}
return bucket.Put(chanID, forwardingPolicy)
}, func() {})
}
// GetInitialFwdingPolicy fetches the serialized forwarding policy for the
// provided channel id from the database, or returns ErrChannelNotFound if
// a forwarding policy for this channel id is not found.
func (c *ChannelStateDB) GetInitialFwdingPolicy(chanID []byte) ([]byte, error) {
var serializedState []byte
err := kvdb.View(c.backend, func(tx kvdb.RTx) error {
bucket := tx.ReadBucket(initialChannelFwdingPolicyBucket)
if bucket == nil {
// If the bucket does not exist, it means we
// never added a channel fees to the db, so
// return ErrChannelNotFound.
return ErrChannelNotFound
}
stateBytes := bucket.Get(chanID)
if stateBytes == nil {
return ErrChannelNotFound
}
serializedState = append(serializedState, stateBytes...)
return nil
}, func() {
serializedState = nil
})
return serializedState, err
}
// DeleteInitialFwdingPolicy removes the forwarding policy for a given channel
// from the database.
func (c *ChannelStateDB) DeleteInitialFwdingPolicy(chanID []byte) error {
return kvdb.Update(c.backend, func(tx kvdb.RwTx) error {
bucket := tx.ReadWriteBucket(initialChannelFwdingPolicyBucket)
if bucket == nil {
return ErrChannelNotFound
}
return bucket.Delete(chanID)
}, func() {})
}
// SaveChannelOpeningState saves the serialized channel state for the provided
// chanPoint to the channelOpeningStateBucket.
func (c *ChannelStateDB) SaveChannelOpeningState(outPoint,
@ -1791,6 +1825,14 @@ func (c *ChannelStateDB) PutOnchainFinalHtlcOutcome(
}, func() {})
}
// MakeTestInvoiceDB is used to create a test invoice database for testing
// purposes. It simply calls into MakeTestDB so the same modifiers can be used.
func MakeTestInvoiceDB(t *testing.T, modifiers ...OptionModifier) (
invoices.InvoiceDB, error) {
return MakeTestDB(t, modifiers...)
}
// MakeTestDB creates a new instance of the ChannelDB for testing purposes.
// A callback which cleans up the created temporary directories is also
// returned and intended to be executed after the test completes.

View File

@ -12,9 +12,9 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain"
"github.com/stretchr/testify/require"
@ -141,7 +141,7 @@ func TestFetchClosedChannelForID(t *testing.T) {
state.FundingOutpoint.Index = i
// We calculate the ChannelID and use it to fetch the summary.
cid := lnwire.NewChanIDFromOutPoint(&state.FundingOutpoint)
cid := lnwire.NewChanIDFromOutPoint(state.FundingOutpoint)
fetchedSummary, err := cdb.FetchClosedChannelForID(cid)
if err != nil {
t.Fatalf("unable to fetch close summary: %v", err)
@ -159,7 +159,7 @@ func TestFetchClosedChannelForID(t *testing.T) {
// As a final test we make sure that we get ErrClosedChannelNotFound
// for a ChannelID we didn't add to the DB.
state.FundingOutpoint.Index++
cid := lnwire.NewChanIDFromOutPoint(&state.FundingOutpoint)
cid := lnwire.NewChanIDFromOutPoint(state.FundingOutpoint)
_, err = cdb.FetchClosedChannelForID(cid)
if err != ErrClosedChannelNotFound {
t.Fatalf("expected ErrClosedChannelNotFound, instead got: %v", err)
@ -238,10 +238,16 @@ func TestFetchChannel(t *testing.T) {
// The decoded channel state should be identical to what we stored
// above.
if !reflect.DeepEqual(channelState, dbChannel) {
t.Fatalf("channel state doesn't match:: %v vs %v",
spew.Sdump(channelState), spew.Sdump(dbChannel))
}
require.Equal(t, channelState, dbChannel)
// Next, attempt to fetch the channel by its channel ID.
chanID := lnwire.NewChanIDFromOutPoint(channelState.FundingOutpoint)
dbChannel, err = cdb.FetchChannelByID(nil, chanID)
require.NoError(t, err, "unable to fetch channel")
// The decoded channel state should be identical to what we stored
// above.
require.Equal(t, channelState, dbChannel)
// If we attempt to query for a non-existent channel, then we should
// get an error.
@ -252,9 +258,11 @@ func TestFetchChannel(t *testing.T) {
channelState2.FundingOutpoint.Index = uniqueOutputIndex.Load()
_, err = cdb.FetchChannel(nil, channelState2.FundingOutpoint)
if err == nil {
t.Fatalf("expected query to fail")
}
require.ErrorIs(t, err, ErrChannelNotFound)
chanID2 := lnwire.NewChanIDFromOutPoint(channelState2.FundingOutpoint)
_, err = cdb.FetchChannelByID(nil, chanID2)
require.ErrorIs(t, err, ErrChannelNotFound)
}
func genRandomChannelShell() (*ChannelShell, error) {
@ -284,6 +292,10 @@ func genRandomChannelShell() (*ChannelShell, error) {
}
shaChainProducer := shachain.NewRevocationProducer(*revRoot)
commitParams := CommitmentParams{
CsvDelay: uint16(rand.Int63()),
}
return &ChannelShell{
NodeAddrs: []net.Addr{&net.TCPAddr{
IP: net.ParseIP("127.0.0.1"),
@ -298,9 +310,7 @@ func genRandomChannelShell() (*ChannelShell, error) {
),
IdentityPub: pub,
LocalChanCfg: ChannelConfig{
ChannelConstraints: ChannelConstraints{
CsvDelay: uint16(rand.Int63()),
},
CommitmentParams: commitParams,
PaymentBasePoint: keychain.KeyDescriptor{
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(rand.Int63()),
@ -599,7 +609,9 @@ func TestFetchChannels(t *testing.T) {
channelIDOption(pendingWaitingChan),
)
err = pendingClosing.MarkCoopBroadcasted(nil, true)
err = pendingClosing.MarkCoopBroadcasted(
nil, lntypes.Local,
)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@ -619,7 +631,9 @@ func TestFetchChannels(t *testing.T) {
channelIDOption(openWaitingChan),
openChannelOption(),
)
err = openClosing.MarkCoopBroadcasted(nil, true)
err = openClosing.MarkCoopBroadcasted(
nil, lntypes.Local,
)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

View File

@ -59,22 +59,22 @@ type duplicateHTLCAttemptInfo struct {
route route.Route
}
// fetchDuplicatePaymentStatus fetches the payment status of the payment. If the
// payment isn't found, it will default to "StatusUnknown".
func fetchDuplicatePaymentStatus(bucket kvdb.RBucket) PaymentStatus {
// fetchDuplicatePaymentStatus fetches the payment status of the payment. If
// the payment isn't found, it will return error `ErrPaymentNotInitiated`.
func fetchDuplicatePaymentStatus(bucket kvdb.RBucket) (PaymentStatus, error) {
if bucket.Get(duplicatePaymentSettleInfoKey) != nil {
return StatusSucceeded
return StatusSucceeded, nil
}
if bucket.Get(duplicatePaymentFailInfoKey) != nil {
return StatusFailed
return StatusFailed, nil
}
if bucket.Get(duplicatePaymentCreationInfoKey) != nil {
return StatusInFlight
return StatusInFlight, nil
}
return StatusUnknown
return 0, ErrPaymentNotInitiated
}
func deserializeDuplicateHTLCAttemptInfo(r io.Reader) (
@ -138,7 +138,10 @@ func fetchDuplicatePayment(bucket kvdb.RBucket) (*MPPayment, error) {
sequenceNum := binary.BigEndian.Uint64(seqBytes)
// Get the payment status.
paymentStatus := fetchDuplicatePaymentStatus(bucket)
paymentStatus, err := fetchDuplicatePaymentStatus(bucket)
if err != nil {
return nil, err
}
// Get the PaymentCreationInfo.
b := bucket.Get(duplicatePaymentCreationInfoKey)

View File

@ -43,6 +43,10 @@ var (
// created.
ErrMetaNotFound = fmt.Errorf("unable to locate meta information")
// ErrClosedScidsNotFound is returned when the closed scid bucket
// hasn't been created.
ErrClosedScidsNotFound = fmt.Errorf("closed scid bucket doesn't exist")
// ErrGraphNotFound is returned when at least one of the components of
// graph doesn't exist.
ErrGraphNotFound = fmt.Errorf("graph bucket not initialized")
@ -75,6 +79,10 @@ var (
// but it is marked as a zombie within the zombie index.
ErrZombieEdge = errors.New("edge marked as zombie")
// ErrZombieEdgeNotFound is an error returned when we attempt to find an
// edge in the zombie index which is not there.
ErrZombieEdgeNotFound = errors.New("edge not found in zombie index")
// ErrEdgeAlreadyExist is returned when edge with specific
// channel id can't be added because it already exist.
ErrEdgeAlreadyExist = fmt.Errorf("edge already exist")

View File

@ -211,6 +211,11 @@ func (f *PkgFilter) Decode(r io.Reader) error {
return err
}
// String returns a human-readable string.
func (f *PkgFilter) String() string {
return fmt.Sprintf("count=%v, filter=%v", f.count, f.filter)
}
// FwdPkg records all adds, settles, and fails that were locked in as a result
// of the remote peer sending us a revocation. Each package is identified by
// the short chanid and remote commitment height corresponding to the revocation
@ -281,6 +286,27 @@ func NewFwdPkg(source lnwire.ShortChannelID, height uint64,
}
}
// SourceRef is a convenience method that returns an AddRef to this forwarding
// package for the index in the argument. It is the caller's responsibility
// to ensure that the index is in bounds.
func (f *FwdPkg) SourceRef(i uint16) AddRef {
return AddRef{
Height: f.Height,
Index: i,
}
}
// DestRef is a convenience method that returns a SettleFailRef to this
// forwarding package for the index in the argument. It is the caller's
// responsibility to ensure that the index is in bounds.
func (f *FwdPkg) DestRef(i uint16) SettleFailRef {
return SettleFailRef{
Source: f.Source,
Height: f.Height,
Index: i,
}
}
// ID returns an unique identifier for this package, used to ensure that sphinx
// replay processing of this batch is idempotent.
func (f *FwdPkg) ID() []byte {

View File

@ -141,9 +141,32 @@ func checkPkgFilterEncodeDecode(t *testing.T, i uint16, f *channeldb.PkgFilter)
}
var (
chanID = lnwire.NewChanIDFromOutPoint(&wire.OutPoint{})
chanID = lnwire.NewChanIDFromOutPoint(wire.OutPoint{})
)
adds = []channeldb.LogUpdate{
func testSettleFails() []channeldb.LogUpdate {
return []channeldb.LogUpdate{
{
LogIndex: 2,
UpdateMsg: &lnwire.UpdateFulfillHTLC{
ChanID: chanID,
ID: 0,
PaymentPreimage: [32]byte{0},
},
},
{
LogIndex: 3,
UpdateMsg: &lnwire.UpdateFailHTLC{
ChanID: chanID,
ID: 1,
Reason: []byte{},
},
},
}
}
func testAdds() []channeldb.LogUpdate {
return []channeldb.LogUpdate{
{
LogIndex: 0,
UpdateMsg: &lnwire.UpdateAddHTLC{
@ -165,26 +188,7 @@ var (
},
},
}
settleFails = []channeldb.LogUpdate{
{
LogIndex: 2,
UpdateMsg: &lnwire.UpdateFulfillHTLC{
ChanID: chanID,
ID: 0,
PaymentPreimage: [32]byte{0},
},
},
{
LogIndex: 3,
UpdateMsg: &lnwire.UpdateFailHTLC{
ChanID: chanID,
ID: 1,
Reason: []byte{},
},
},
}
)
}
// TestPackagerEmptyFwdPkg checks that the state transitions exhibited by a
// forwarding package that contains no adds, fails or settles. We expect that
@ -273,6 +277,8 @@ func TestPackagerOnlyAdds(t *testing.T) {
t.Fatalf("no forwarding packages should exist, found %d", len(fwdPkgs))
}
adds := testAdds()
// Next, create and write a new forwarding package that only has add
// htlcs.
fwdPkg := channeldb.NewFwdPkg(shortChanID, 0, adds, nil)
@ -377,6 +383,7 @@ func TestPackagerOnlySettleFails(t *testing.T) {
// Next, create and write a new forwarding package that only has add
// htlcs.
settleFails := testSettleFails()
fwdPkg := channeldb.NewFwdPkg(shortChanID, 0, nil, settleFails)
nSettleFails := len(settleFails)
@ -479,8 +486,11 @@ func TestPackagerAddsThenSettleFails(t *testing.T) {
t.Fatalf("no forwarding packages should exist, found %d", len(fwdPkgs))
}
adds := testAdds()
// Next, create and write a new forwarding package that only has add
// htlcs.
settleFails := testSettleFails()
fwdPkg := channeldb.NewFwdPkg(shortChanID, 0, adds, settleFails)
nAdds := len(adds)
@ -612,8 +622,11 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) {
t.Fatalf("no forwarding packages should exist, found %d", len(fwdPkgs))
}
adds := testAdds()
// Next, create and write a new forwarding package that has both add
// and settle/fail htlcs.
settleFails := testSettleFails()
fwdPkg := channeldb.NewFwdPkg(shortChanID, 0, adds, settleFails)
nAdds := len(adds)

View File

@ -0,0 +1,111 @@
package channeldb
import (
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
)
var (
// initialChannelForwardingPolicyBucket is the database bucket used to
// store the forwarding policy for each permanent channel that is
// currently in the process of being opened.
initialChannelForwardingPolicyBucket = []byte(
"initialChannelFwdingPolicy",
)
)
// SaveInitialForwardingPolicy saves the serialized forwarding policy for the
// provided permanent channel id to the initialChannelForwardingPolicyBucket.
func (c *ChannelStateDB) SaveInitialForwardingPolicy(chanID lnwire.ChannelID,
forwardingPolicy *models.ForwardingPolicy) error {
chanIDCopy := make([]byte, 32)
copy(chanIDCopy, chanID[:])
scratch := make([]byte, 36)
byteOrder.PutUint64(scratch[:8], uint64(forwardingPolicy.MinHTLCOut))
byteOrder.PutUint64(scratch[8:16], uint64(forwardingPolicy.MaxHTLC))
byteOrder.PutUint64(scratch[16:24], uint64(forwardingPolicy.BaseFee))
byteOrder.PutUint64(scratch[24:32], uint64(forwardingPolicy.FeeRate))
byteOrder.PutUint32(scratch[32:], forwardingPolicy.TimeLockDelta)
return kvdb.Update(c.backend, func(tx kvdb.RwTx) error {
bucket, err := tx.CreateTopLevelBucket(
initialChannelForwardingPolicyBucket,
)
if err != nil {
return err
}
return bucket.Put(chanIDCopy, scratch)
}, func() {})
}
// GetInitialForwardingPolicy fetches the serialized forwarding policy for the
// provided channel id from the database, or returns ErrChannelNotFound if
// a forwarding policy for this channel id is not found.
func (c *ChannelStateDB) GetInitialForwardingPolicy(
chanID lnwire.ChannelID) (*models.ForwardingPolicy, error) {
chanIDCopy := make([]byte, 32)
copy(chanIDCopy, chanID[:])
var forwardingPolicy *models.ForwardingPolicy
err := kvdb.View(c.backend, func(tx kvdb.RTx) error {
bucket := tx.ReadBucket(initialChannelForwardingPolicyBucket)
if bucket == nil {
// If the bucket does not exist, it means we
// never added a channel fees to the db, so
// return ErrChannelNotFound.
return ErrChannelNotFound
}
stateBytes := bucket.Get(chanIDCopy)
if stateBytes == nil {
return ErrChannelNotFound
}
forwardingPolicy = &models.ForwardingPolicy{
MinHTLCOut: lnwire.MilliSatoshi(
byteOrder.Uint64(stateBytes[:8]),
),
MaxHTLC: lnwire.MilliSatoshi(
byteOrder.Uint64(stateBytes[8:16]),
),
BaseFee: lnwire.MilliSatoshi(
byteOrder.Uint64(stateBytes[16:24]),
),
FeeRate: lnwire.MilliSatoshi(
byteOrder.Uint64(stateBytes[24:32]),
),
TimeLockDelta: byteOrder.Uint32(stateBytes[32:36]),
}
return nil
}, func() {
forwardingPolicy = nil
})
return forwardingPolicy, err
}
// DeleteInitialForwardingPolicy removes the forwarding policy for a given
// channel from the database.
func (c *ChannelStateDB) DeleteInitialForwardingPolicy(
chanID lnwire.ChannelID) error {
chanIDCopy := make([]byte, 32)
copy(chanIDCopy, chanID[:])
return kvdb.Update(c.backend, func(tx kvdb.RwTx) error {
bucket := tx.ReadWriteBucket(
initialChannelForwardingPolicyBucket,
)
if bucket == nil {
return ErrChannelNotFound
}
return bucket.Delete(chanIDCopy)
}, func() {})
}

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@ import (
"sync"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
@ -27,94 +28,9 @@ type GraphCacheNode interface {
// error, then the iteration is halted with the error propagated back up
// to the caller.
ForEachChannel(kvdb.RTx,
func(kvdb.RTx, *ChannelEdgeInfo, *ChannelEdgePolicy,
*ChannelEdgePolicy) error) error
}
// CachedEdgePolicy is a struct that only caches the information of a
// ChannelEdgePolicy that we actually use for pathfinding and therefore need to
// store in the cache.
type CachedEdgePolicy struct {
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
ChannelID uint64
// MessageFlags is a bitfield which indicates the presence of optional
// fields (like max_htlc) in the policy.
MessageFlags lnwire.ChanUpdateMsgFlags
// ChannelFlags is a bitfield which signals the capabilities of the
// channel as well as the directed edge this update applies to.
ChannelFlags lnwire.ChanUpdateChanFlags
// TimeLockDelta is the number of blocks this node will subtract from
// the expiry of an incoming HTLC. This value expresses the time buffer
// the node would like to HTLC exchanges.
TimeLockDelta uint16
// MinHTLC is the smallest value HTLC this node will forward, expressed
// in millisatoshi.
MinHTLC lnwire.MilliSatoshi
// MaxHTLC is the largest value HTLC this node will forward, expressed
// in millisatoshi.
MaxHTLC lnwire.MilliSatoshi
// FeeBaseMSat is the base HTLC fee that will be charged for forwarding
// ANY HTLC, expressed in mSAT's.
FeeBaseMSat lnwire.MilliSatoshi
// FeeProportionalMillionths is the rate that the node will charge for
// HTLCs for each millionth of a satoshi forwarded.
FeeProportionalMillionths lnwire.MilliSatoshi
// ToNodePubKey is a function that returns the to node of a policy.
// Since we only ever store the inbound policy, this is always the node
// that we query the channels for in ForEachChannel(). Therefore, we can
// save a lot of space by not storing this information in the memory and
// instead just set this function when we copy the policy from cache in
// ForEachChannel().
ToNodePubKey func() route.Vertex
// ToNodeFeatures are the to node's features. They are never set while
// the edge is in the cache, only on the copy that is returned in
// ForEachChannel().
ToNodeFeatures *lnwire.FeatureVector
}
// ComputeFee computes the fee to forward an HTLC of `amt` milli-satoshis over
// the passed active payment channel. This value is currently computed as
// specified in BOLT07, but will likely change in the near future.
func (c *CachedEdgePolicy) ComputeFee(
amt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
return c.FeeBaseMSat + (amt*c.FeeProportionalMillionths)/feeRateParts
}
// ComputeFeeFromIncoming computes the fee to forward an HTLC given the incoming
// amount.
func (c *CachedEdgePolicy) ComputeFeeFromIncoming(
incomingAmt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
return incomingAmt - divideCeil(
feeRateParts*(incomingAmt-c.FeeBaseMSat),
feeRateParts+c.FeeProportionalMillionths,
)
}
// NewCachedPolicy turns a full policy into a minimal one that can be cached.
func NewCachedPolicy(policy *ChannelEdgePolicy) *CachedEdgePolicy {
return &CachedEdgePolicy{
ChannelID: policy.ChannelID,
MessageFlags: policy.MessageFlags,
ChannelFlags: policy.ChannelFlags,
TimeLockDelta: policy.TimeLockDelta,
MinHTLC: policy.MinHTLC,
MaxHTLC: policy.MaxHTLC,
FeeBaseMSat: policy.FeeBaseMSat,
FeeProportionalMillionths: policy.FeeProportionalMillionths,
}
func(kvdb.RTx, *models.ChannelEdgeInfo,
*models.ChannelEdgePolicy,
*models.ChannelEdgePolicy) error) error
}
// DirectedChannel is a type that stores the channel information as seen from
@ -142,7 +58,10 @@ type DirectedChannel struct {
// In path finding, we're walking backward from the destination to the
// source, so we're always interested in the edge that arrives to us
// from the other node.
InPolicy *CachedEdgePolicy
InPolicy *models.CachedEdgePolicy
// Inbound fees of this node.
InboundFee lnwire.Fee
}
// DeepCopy creates a deep copy of the channel, including the incoming policy.
@ -223,9 +142,9 @@ func (c *GraphCache) AddNode(tx kvdb.RTx, node GraphCacheNode) error {
c.AddNodeFeatures(node)
return node.ForEachChannel(
tx, func(tx kvdb.RTx, info *ChannelEdgeInfo,
outPolicy *ChannelEdgePolicy,
inPolicy *ChannelEdgePolicy) error {
tx, func(tx kvdb.RTx, info *models.ChannelEdgeInfo,
outPolicy *models.ChannelEdgePolicy,
inPolicy *models.ChannelEdgePolicy) error {
c.AddChannel(info, outPolicy, inPolicy)
@ -238,8 +157,8 @@ func (c *GraphCache) AddNode(tx kvdb.RTx, node GraphCacheNode) error {
// and policy 2 does not matter, the directionality is extracted from the info
// and policy flags automatically. The policy will be set as the outgoing policy
// on one node and the incoming policy on the peer's side.
func (c *GraphCache) AddChannel(info *ChannelEdgeInfo,
policy1 *ChannelEdgePolicy, policy2 *ChannelEdgePolicy) {
func (c *GraphCache) AddChannel(info *models.ChannelEdgeInfo,
policy1 *models.ChannelEdgePolicy, policy2 *models.ChannelEdgePolicy) {
if info == nil {
return
@ -271,7 +190,7 @@ func (c *GraphCache) AddChannel(info *ChannelEdgeInfo,
// of node 2 then we have the policy 1 as seen from node 1.
if policy1 != nil {
fromNode, toNode := info.NodeKey1Bytes, info.NodeKey2Bytes
if policy1.Node.PubKeyBytes != info.NodeKey2Bytes {
if policy1.ToNode != info.NodeKey2Bytes {
fromNode, toNode = toNode, fromNode
}
isEdge1 := policy1.ChannelFlags&lnwire.ChanUpdateDirection == 0
@ -279,7 +198,7 @@ func (c *GraphCache) AddChannel(info *ChannelEdgeInfo,
}
if policy2 != nil {
fromNode, toNode := info.NodeKey2Bytes, info.NodeKey1Bytes
if policy2.Node.PubKeyBytes != info.NodeKey1Bytes {
if policy2.ToNode != info.NodeKey1Bytes {
fromNode, toNode = toNode, fromNode
}
isEdge1 := policy2.ChannelFlags&lnwire.ChanUpdateDirection == 0
@ -301,9 +220,17 @@ func (c *GraphCache) updateOrAddEdge(node route.Vertex, edge *DirectedChannel) {
// of the from and to node is not strictly important. But we assume that a
// channel edge was added beforehand so that the directed channel struct already
// exists in the cache.
func (c *GraphCache) UpdatePolicy(policy *ChannelEdgePolicy, fromNode,
func (c *GraphCache) UpdatePolicy(policy *models.ChannelEdgePolicy, fromNode,
toNode route.Vertex, edge1 bool) {
// Extract inbound fee if possible and available. If there is a decoding
// error, ignore this policy.
var inboundFee lnwire.Fee
_, err := policy.ExtraOpaqueData.ExtractRecords(&inboundFee)
if err != nil {
return
}
c.mtx.Lock()
defer c.mtx.Unlock()
@ -324,16 +251,18 @@ func (c *GraphCache) UpdatePolicy(policy *ChannelEdgePolicy, fromNode,
// policy for node 1.
case channel.IsNode1 && edge1:
channel.OutPolicySet = true
channel.InboundFee = inboundFee
// This is node 2, and it is edge 2, so this is the outgoing
// policy for node 2.
case !channel.IsNode1 && !edge1:
channel.OutPolicySet = true
channel.InboundFee = inboundFee
// The other two cases left mean it's the inbound policy for the
// node.
default:
channel.InPolicy = NewCachedPolicy(policy)
channel.InPolicy = models.NewCachedPolicy(policy)
}
}
@ -380,7 +309,7 @@ func (c *GraphCache) removeChannelIfFound(node route.Vertex, chanID uint64) {
// UpdateChannel updates the channel edge information for a specific edge. We
// expect the edge to already exist and be known. If it does not yet exist, this
// call is a no-op.
func (c *GraphCache) UpdateChannel(info *ChannelEdgeInfo) {
func (c *GraphCache) UpdateChannel(info *models.ChannelEdgeInfo) {
c.mtx.Lock()
defer c.mtx.Unlock()

View File

@ -4,6 +4,7 @@ import (
"encoding/hex"
"testing"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
@ -28,9 +29,9 @@ type node struct {
pubKey route.Vertex
features *lnwire.FeatureVector
edgeInfos []*ChannelEdgeInfo
outPolicies []*ChannelEdgePolicy
inPolicies []*ChannelEdgePolicy
edgeInfos []*models.ChannelEdgeInfo
outPolicies []*models.ChannelEdgePolicy
inPolicies []*models.ChannelEdgePolicy
}
func (n *node) PubKey() route.Vertex {
@ -41,8 +42,8 @@ func (n *node) Features() *lnwire.FeatureVector {
}
func (n *node) ForEachChannel(tx kvdb.RTx,
cb func(kvdb.RTx, *ChannelEdgeInfo, *ChannelEdgePolicy,
*ChannelEdgePolicy) error) error {
cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy) error) error {
for idx := range n.edgeInfos {
err := cb(
@ -70,34 +71,32 @@ func TestGraphCacheAddNode(t *testing.T) {
channelFlagA, channelFlagB = 1, 0
}
outPolicy1 := &ChannelEdgePolicy{
outPolicy1 := &models.ChannelEdgePolicy{
ChannelID: 1000,
ChannelFlags: lnwire.ChanUpdateChanFlags(channelFlagA),
Node: &LightningNode{
PubKeyBytes: nodeB,
Features: lnwire.EmptyFeatureVector(),
ToNode: nodeB,
// Define an inbound fee.
ExtraOpaqueData: []byte{
253, 217, 3, 8, 0, 0, 0, 10, 0, 0, 0, 20,
},
}
inPolicy1 := &ChannelEdgePolicy{
inPolicy1 := &models.ChannelEdgePolicy{
ChannelID: 1000,
ChannelFlags: lnwire.ChanUpdateChanFlags(channelFlagB),
Node: &LightningNode{
PubKeyBytes: nodeA,
Features: lnwire.EmptyFeatureVector(),
},
ToNode: nodeA,
}
node := &node{
pubKey: nodeA,
features: lnwire.EmptyFeatureVector(),
edgeInfos: []*ChannelEdgeInfo{{
edgeInfos: []*models.ChannelEdgeInfo{{
ChannelID: 1000,
// Those are direction independent!
NodeKey1Bytes: pubKey1,
NodeKey2Bytes: pubKey2,
Capacity: 500,
}},
outPolicies: []*ChannelEdgePolicy{outPolicy1},
inPolicies: []*ChannelEdgePolicy{inPolicy1},
outPolicies: []*models.ChannelEdgePolicy{outPolicy1},
inPolicies: []*models.ChannelEdgePolicy{inPolicy1},
}
cache := NewGraphCache(10)
require.NoError(t, cache.AddNode(nil, node))
@ -129,8 +128,18 @@ func TestGraphCacheAddNode(t *testing.T) {
edges map[uint64]*DirectedChannel) error {
nodes[node] = struct{}{}
for chanID := range edges {
for chanID, directedChannel := range edges {
chans[chanID] = struct{}{}
if node == nodeA {
require.NotZero(
t, directedChannel.InboundFee,
)
} else {
require.Zero(
t, directedChannel.InboundFee,
)
}
}
return nil
@ -144,8 +153,8 @@ func TestGraphCacheAddNode(t *testing.T) {
runTest(pubKey2, pubKey1)
}
func assertCachedPolicyEqual(t *testing.T, original *ChannelEdgePolicy,
cached *CachedEdgePolicy) {
func assertCachedPolicyEqual(t *testing.T, original *models.ChannelEdgePolicy,
cached *models.CachedEdgePolicy) {
require.Equal(t, original.ChannelID, cached.ChannelID)
require.Equal(t, original.MessageFlags, cached.MessageFlags)
@ -159,9 +168,6 @@ func assertCachedPolicyEqual(t *testing.T, original *ChannelEdgePolicy,
cached.FeeProportionalMillionths,
)
require.Equal(
t,
route.Vertex(original.Node.PubKeyBytes),
cached.ToNodePubKey(),
t, route.Vertex(original.ToNode), cached.ToNodePubKey(),
)
require.Equal(t, original.Node.Features, cached.ToNodeFeatures)
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,141 @@
package graphsession
import (
"fmt"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing"
"github.com/lightningnetwork/lnd/routing/route"
)
// Factory implements the routing.GraphSessionFactory and can be used to start
// a session with a ReadOnlyGraph.
type Factory struct {
graph ReadOnlyGraph
}
// NewGraphSessionFactory constructs a new Factory which can then be used to
// start a new session.
func NewGraphSessionFactory(graph ReadOnlyGraph) routing.GraphSessionFactory {
return &Factory{
graph: graph,
}
}
// NewGraphSession will produce a new Graph to use for a path-finding session.
// It returns the Graph along with a call-back that must be called once Graph
// access is complete. This call-back will close any read-only transaction that
// was created at Graph construction time.
//
// NOTE: This is part of the routing.GraphSessionFactory interface.
func (g *Factory) NewGraphSession() (routing.Graph, func() error, error) {
tx, err := g.graph.NewPathFindTx()
if err != nil {
return nil, nil, err
}
session := &session{
graph: g.graph,
tx: tx,
}
return session, session.close, nil
}
// A compile-time check to ensure that Factory implements the
// routing.GraphSessionFactory interface.
var _ routing.GraphSessionFactory = (*Factory)(nil)
// session is an implementation of the routing.Graph interface where the same
// read-only transaction is held across calls to the graph and can be used to
// access the backing channel graph.
type session struct {
graph graph
tx kvdb.RTx
}
// NewRoutingGraph constructs a session that which does not first start a
// read-only transaction and so each call on the routing.Graph will create a
// new transaction.
func NewRoutingGraph(graph ReadOnlyGraph) routing.Graph {
return &session{
graph: graph,
}
}
// close closes the read-only transaction being used to access the backing
// graph. If no transaction was started then this is a no-op.
func (g *session) close() error {
if g.tx == nil {
return nil
}
err := g.tx.Rollback()
if err != nil {
return fmt.Errorf("error closing db tx: %w", err)
}
return nil
}
// ForEachNodeChannel calls the callback for every channel of the given node.
//
// NOTE: Part of the routing.Graph interface.
func (g *session) ForEachNodeChannel(nodePub route.Vertex,
cb func(channel *channeldb.DirectedChannel) error) error {
return g.graph.ForEachNodeDirectedChannel(g.tx, nodePub, cb)
}
// FetchNodeFeatures returns the features of the given node. If the node is
// unknown, assume no additional features are supported.
//
// NOTE: Part of the routing.Graph interface.
func (g *session) FetchNodeFeatures(nodePub route.Vertex) (
*lnwire.FeatureVector, error) {
return g.graph.FetchNodeFeatures(nodePub)
}
// A compile-time check to ensure that *session implements the
// routing.Graph interface.
var _ routing.Graph = (*session)(nil)
// ReadOnlyGraph is a graph extended with a call to create a new read-only
// transaction that can then be used to make further queries to the graph.
type ReadOnlyGraph interface {
// NewPathFindTx returns a new read transaction that can be used for a
// single path finding session. Will return nil if the graph cache is
// enabled.
NewPathFindTx() (kvdb.RTx, error)
graph
}
// graph describes the API necessary for a graph source to have access to on a
// database implementation, like channeldb.ChannelGraph, in order to be used by
// the Router for pathfinding.
type graph interface {
// ForEachNodeDirectedChannel iterates through all channels of a given
// node, executing the passed callback on the directed edge representing
// the channel and its incoming policy. If the callback returns an
// error, then the iteration is halted with the error propagated back
// up to the caller.
//
// Unknown policies are passed into the callback as nil values.
//
// NOTE: if a nil tx is provided, then it is expected that the
// implementation create a read only tx.
ForEachNodeDirectedChannel(tx kvdb.RTx, node route.Vertex,
cb func(channel *channeldb.DirectedChannel) error) error
// FetchNodeFeatures returns the features of a given node. If no
// features are known for the node, an empty feature vector is returned.
FetchNodeFeatures(node route.Vertex) (*lnwire.FeatureVector, error)
}
// A compile-time check to ensure that *channeldb.ChannelGraph implements the
// graph interface.
var _ graph = (*channeldb.ChannelGraph)(nil)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@ func deserializeCloseChannelSummaryV6(r io.Reader) (*ChannelCloseSummary, error)
// Finally, we'll attempt to read the next unrevoked commitment point
// for the remote party. If we closed the channel before receiving a
// funding locked message, then this can be nil. As a result, we'll use
// channel_ready message, then this can be nil. As a result, we'll use
// the same technique to read the field, only if there's still data
// left in the buffer.
err = ReadElements(r, &c.RemoteNextRevocation)

View File

@ -9,6 +9,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb/migration16"
"github.com/lightningnetwork/lnd/channeldb/migration24"
"github.com/lightningnetwork/lnd/channeldb/migration30"
"github.com/lightningnetwork/lnd/channeldb/migration31"
"github.com/lightningnetwork/lnd/channeldb/migration_01_to_11"
"github.com/lightningnetwork/lnd/kvdb"
)
@ -40,5 +41,6 @@ func UseLogger(logger btclog.Logger) {
migration16.UseLogger(logger)
migration24.UseLogger(logger)
migration30.UseLogger(logger)
migration31.UseLogger(logger)
kvdb.UseLogger(logger)
}

View File

@ -2,7 +2,6 @@ package lnwire
import (
"io"
"io/ioutil"
)
// AnnounceSignatures is a direct message between two endpoints of a
@ -66,7 +65,7 @@ func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
// we'll collect the remainder into the ExtraOpaqueData field. If there
// aren't any bytes, then we'll snip off the slice to avoid carrying
// around excess capacity.
a.ExtraOpaqueData, err = ioutil.ReadAll(r)
a.ExtraOpaqueData, err = io.ReadAll(r)
if err != nil {
return err
}

View File

@ -3,7 +3,6 @@ package lnwire
import (
"bytes"
"io"
"io/ioutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
)
@ -89,7 +88,7 @@ func (a *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
// we'll collect the remainder into the ExtraOpaqueData field. If there
// aren't any bytes, then we'll snip off the slice to avoid carrying
// around excess capacity.
a.ExtraOpaqueData, err = ioutil.ReadAll(r)
a.ExtraOpaqueData, err = io.ReadAll(r)
if err != nil {
return err
}

View File

@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
)
@ -160,7 +159,7 @@ func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
// we'll collect the remainder into the ExtraOpaqueData field. If there
// aren't any bytes, then we'll snip off the slice to avoid carrying
// around excess capacity.
a.ExtraOpaqueData, err = ioutil.ReadAll(r)
a.ExtraOpaqueData, err = io.ReadAll(r)
if err != nil {
return err
}

View File

@ -5,7 +5,6 @@ import (
"fmt"
"image/color"
"io"
"io/ioutil"
"net"
"unicode/utf8"
)
@ -127,7 +126,7 @@ func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
// we'll collect the remainder into the ExtraOpaqueData field. If there
// aren't any bytes, then we'll snip off the slice to avoid carrying
// around excess capacity.
a.ExtraOpaqueData, err = ioutil.ReadAll(r)
a.ExtraOpaqueData, err = io.ReadAll(r)
if err != nil {
return err
}

View File

@ -1212,7 +1212,7 @@ func DecodeFailure(r io.Reader, pver uint32) (FailureMessage, error) {
// is a 2 byte length followed by the payload itself.
var failureLength uint16
if err := ReadElement(r, &failureLength); err != nil {
return nil, fmt.Errorf("unable to read error len: %v", err)
return nil, fmt.Errorf("unable to read error len: %w", err)
}
if failureLength > FailureMessageLength {
return nil, fmt.Errorf("failure message is too "+
@ -1236,7 +1236,7 @@ func DecodeFailureMessage(r io.Reader, pver uint32) (FailureMessage, error) {
// the first two bytes of the buffer.
var codeBytes [2]byte
if _, err := io.ReadFull(r, codeBytes[:]); err != nil {
return nil, fmt.Errorf("unable to read failure code: %v", err)
return nil, fmt.Errorf("unable to read failure code: %w", err)
}
failCode := FailCode(binary.BigEndian.Uint16(codeBytes[:]))
@ -1244,7 +1244,7 @@ func DecodeFailureMessage(r io.Reader, pver uint32) (FailureMessage, error) {
// additional data if needed.
failure, err := makeEmptyOnionError(failCode)
if err != nil {
return nil, fmt.Errorf("unable to make empty error: %v", err)
return nil, fmt.Errorf("unable to make empty error: %w", err)
}
// Finally, if this failure has a payload, then we'll read that now as

View File

@ -223,7 +223,8 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
N: maxZlibBufSize,
})
if err != nil {
return 0, nil, fmt.Errorf("unable to create zlib reader: %v", err)
return 0, nil, fmt.Errorf("unable to create zlib "+
"reader: %w", err)
}
var (

Some files were not shown because too many files have changed in this diff Show More