Commit Graph

1485 Commits

Author SHA1 Message Date
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
1ed6439c3a
lnwallet: add initial unit test coverage for musig chan session 2023-08-22 16:30:49 -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
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
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
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
ziggie
54bacec422
lnwallet: add new ErrMempoolFee error. 2023-07-25 01:12:39 +02:00
Slyghtning
baa1419187
chanfunding: fix typo 2023-07-24 13:07:01 +02:00
Slyghtning
d327c92188
lnwallet: adds selected Outpoints for funding 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
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
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
56dba2df03
multi: update linter, fix new issues 2023-06-13 11:58:33 +02: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
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
Bjarne Magnussen
8c1cf21707 chanfunding: allow to set a reserved amount not used for funding 2023-04-05 23:10:03 +02:00
Slyghtning
5d88693852 lnd+lnwallet: fundmax flag for openchannel 2023-04-05 23:09:11 +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
ziggie
4da26fb65a
btcwallet+rpcwallet: verify input data for psbt package
Use the new method in the psbt package InputsReadyToSign which
makes sure that each input has either nonWitness Utxo or
witness Utxo data specified.
2023-03-31 08:43:02 +02:00
Oliver Gugger
ec5b95c9a9
Merge pull request #7517 from yyforyongyu/fix-funding-locked
Replace `FundingLocked` with `ChannelReady`
2023-03-30 17:22:17 +02:00
yyforyongyu
00fa2cb34a
lnwallet: add verbose test logs for TestWebAPIFeeEstimator 2023-03-22 23:55:11 +07:00
yyforyongyu
6b9217acfc
multi: replace FundingLocked related docs
This commit replaces `FundingLocked` found in docs using the following
command,
```shell
find . -name "*.go" -exec sed -i '' 's/FundingLocked/ChannelReady/g' {} \;
find . -name "*.go" -exec sed -i '' 's/FundingLock/ChannelReady/g' {} \;
```
2023-03-17 18:21:59 +08:00
Elle Mouton
b607db30f9
lnwallet: add zero-fee-htlc-tx test vectors 2023-03-16 17:27:05 +02:00
Elle Mouton
6774b72913
lnwallet: add same amount and preimage anchors test vector 2023-03-16 17:27:05 +02:00
Elle Mouton
a41f6d5a73
lnwallet: add same amount and preimage legacy test vector 2023-03-16 17:27:04 +02:00
Elle Mouton
4f14193ca9
lnwallet: add new htlc set for test vectors
Add a new test htlc set comprised of htlc 1 from the original set and
two new htlcs, 5 and 6, that use the same preimage and have the same
output value (in sats). This htlc set is used in tests that assert the
ordering of htlcs  that have the same preimage and output value.
2023-03-16 17:27:04 +02:00
Elle Mouton
dbc19b24e5
lnwallet: add funding amount assertion to tests
In this commit, an assertion is added to the bolt 3 commitment tx tests
that ensures that the local and remote balances add up to the expected
funding amount. Adding this assertion uncovered a borked test vector
which is also fixed in this commit.
2023-03-16 17:27:04 +02:00
Elle Mouton
09ff853b9c
lnwallet: lint bolt 3 test vectors func 2023-03-16 17:27:04 +02:00
Elle Mouton
15da50df10
lnwallet: remove dead code 2023-03-16 17:27:04 +02:00
Elle Mouton
b5d281dca8
lnwallet: run commitment tx tests in parallel 2023-03-16 17:27:03 +02:00
positiveblue
4a0a15586b
multi: make linter happy
Fix all the linter problems for the `v0.16.0-beta.rc3`.
2023-03-11 23:29:41 -08:00
Olaoluwa Osuntokun
8754547ded
lnwallet: add tests for the new rebroadcaster logic
We needed to copy some mocks from elsewhere in the codebase, as
otherwise we'd run into an import cycle.
2023-03-10 19:07:50 -08:00
Olaoluwa Osuntokun
10929d80cc
lnwallet: add new rebroadcaster interface, use for background tx publish
In this commit, we add a new Rebroadcaster interface to be used for
publishing transactions passively in the background until they've been
confirmed on chain. This is useful if a tx drops out of the mempool, but
then the pool clears down and has more space available to accept the tx
at the current fee level.
2023-03-10 19:07:35 -08:00
yyforyongyu
edba938996
multi: add new build tag integration
This commit adds a new build tag `integration` and removes the old tag
`rpctest` for clarity. Multiple unnecessary usages of `build !rpctest`
is also removed.
2023-02-23 21:56:09 +08:00
Oliver Gugger
d44823f6e8
Merge pull request #7431 from Crypt-iQ/remove_res_ids
lnwallet: remove from reservationIDs
2023-02-21 12:36:10 +01:00
eugene
2c7f118d4e
lnwallet: remove from reservationIDs 2023-02-20 12:47:45 -05:00
Elle Mouton
91a2cd45d8
lnwallet: make spendTx param in NewBreachRetribution optional
In this commit, the NewBreachRetribution function is adjusted so that a
caller can optionally set the spendTx parameter to nil. In this case,
the function will check the revocation log to see if the local and
remote amount fields are available there and use them if they are.
If the fields are not present, which they might not be given a previous
migration that removed the fields, then an error is returned.
2023-02-16 20:47:35 +02:00
Oliver Gugger
f245591e4b
Merge pull request #7386 from guggero/remote-signer-p2tr-inputs
remote signer: fix channel funding with mixed funding input types
2023-02-14 12:34:11 +01:00
Torakushi
cdb015223b
walletrpc+lnwallet: possibility to define an address type for changes in FundPsbt
By default, P2TR addresses are used for changes. However, some users
might encounter some problems with this change. We add the possibility
to define a custom address type in FundPsbt for default/imported accounts
(only P2TR for now). If no address type is specified for these accounts,
we will use P2WKH by default.
2023-02-08 12:35:44 +01:00
Oliver Gugger
df1ea46d9e
rpcwallet: fix p2tr inputs in remote signing
The SendOutputs method isn't used very often in our code so the missing
Taproot sighash type wasn't detected before.
Also, a P2TR input will never have a sigScript, so we can explicitly set
that parameter to nil instead of relying on it being nil anyway.
2023-02-07 22:15:13 +01:00