Commit Graph

1602 Commits

Author SHA1 Message Date
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
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 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
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
71753af8ee
multi: fix various typos 2024-02-21 11:35:10 +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
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
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
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
Keagan McClelland
9c2270a5ea lnwallet: remove redundant unused fields 2024-01-24 17:22:35 -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
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
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
Keagan McClelland
64fda6ca65 htlcswitch: implement flush and commit lifecycle hooks for channelLink 2024-01-22 16:08:55 -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
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
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
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
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
ziggie
45a3bf333b
lnwallet: fix logging. 2023-12-22 17:36:41 +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
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
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
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
Orbital
ed373baed0
multi: add tag option to SignMessageSchnorr 2023-10-30 21:39:39 -05: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
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