Commit graph

16209 commits

Author SHA1 Message Date
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