Commit Graph

37 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
92da6b1d44
multi: fix linter warnings with updated linter 2023-08-22 16:34:47 -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
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
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
Oliver Gugger
8bc16b4fb2
rpcwallet: fix np2wkh inputs in remote signing
There is a one byte difference between the sigScript and the
witnessScript in case of a np2wkh input. The remote signer actually
needs the witness script and not the sig script to produce a valid
signature.
2023-02-07 22:15:12 +01:00
Oliver Gugger
13252aec1d
lnrpc+rpcwallet: add version to MuSig2 RPC calls 2023-02-06 10:50:29 +01:00
Oliver Gugger
ce5fa2e043
multi: add version to MuSig2 API, bump btcd/btcec to v2.3.2
With this commit we bump the github.com/btcd/btcec/v2 library to v2.3.2
which implements the MuSig2 BIP version v1.0.0rc2. With this the
github.com/btcsuite/btcd/btcec/v2/schnorr/musig2 package becomes
v1.0.0rc2 and the github.com/lightningnetwork/lnd/internal/musig2v040
stays at the old v0.4.0 version.
2023-02-03 18:30:10 +01:00
Oliver Gugger
5bd3e91750
rpcwallet: pass prev output fetcher into ComputeInputScript
This commit fixes signing of Taproot inputs when some of the other
inputs of the transaction are not known to the wallet (such as a Pool
account for example).
If we want to sign for a Taproot (change) input when depositing into a
Pool account the wallet won't know the Pool account input. So we need to
make sure we pass it along inside the PrevOutputFetcher (which contains
the UTXO information extracted from the PSBT).
2022-11-11 10:20:09 +01:00
Oliver Gugger
ed2e542515
rpcwallet: don't re-use sign desc in loop
This commit fixes an issue with signing for mixed inputs in a remote
signing setup where the re-use of the sign descriptor would lead to the
sign method not being reset correctly if a p2wkh input is following a
p2tr input.
2022-11-11 10:20:09 +01:00
yyforyongyu
0735522194
multi: fix make fmt 2022-08-23 22:10:24 +08:00
Slyghtning
b2e624cd52 psbt: Indicate which psbt inputs were signed 2022-08-16 19:31:06 -04:00
ErikEk
b5af0ce327
signrpc: add schnorr sig to sign and validate msg 2022-07-14 10:29:29 +02:00
Oliver Gugger
427702dbe6
rpcwallet: use PSBT prev out fetcher 2022-06-10 22:03:45 +02:00
Oliver Gugger
9f4f0e94f5
multi: avoid direct use of dcrec/secp256k1 library
Because the original dcrec secp256k1 library that is used for the
Schnorr signature primitives uses different hash algorithms than the
btcd secp256k1 library. Therefore pulling in the wrong library can lead
to weird and unexpected errors. We try to make it harder to make the
mistake by not using the library directly in lnd in the first place.
Note that it is still indirectly needed by the btcd secp256k1 library,
therefore the module dependency is still expected to be there, just
moved to the indirect section.
2022-05-11 10:07:52 +02:00
Oliver Gugger
d1a151010a
lntest+rpcwallet: support remote p2tr script spend signing 2022-05-11 10:07:51 +02:00
Oliver Gugger
7f4e977073
lntest+rpcwallet: support remote p2tr key spend signing 2022-05-11 10:07:50 +02:00
Oliver Gugger
5395a0fe6b
rpcwallet: attempt to locate UTXO information in prev output fetcher
Since we might now be given a whole list of UTXOs in the PrevOutputs
field of the SignOutputRaw RPC, the previous output fetcher might
contain the information we require for the remote signing case. So
instead of failing if our wallet doesn't know each input that's being
spent, we fall back to the UTXO information contained in the previous
outputs.
2022-05-11 10:07:48 +02:00
Oliver Gugger
7e11f64650
rpcwallet: only shut down on RPC error 2022-05-04 19:23:58 +02:00
Oliver Gugger
95ff670c0e
multi: add MuSig2Cleanup method to MuSig2 signer 2022-05-04 19:23:58 +02:00
Oliver Gugger
f7275c7fc4
multi: implement MuSig2 RPCs and remote signing 2022-04-29 11:41:09 +02:00
Oliver Gugger
f130eddb92
multi: use prev output fetcher where possible 2022-03-24 18:02:37 +01:00
Oliver Gugger
72c9582b85
multi: bump btcd to taproot aware version 2022-03-24 15:00:25 +01:00
Oliver Gugger
8c44da225a
rpcwallet: fix RPC wallet health check connection leak
Fixes #6329.
This commit fixes a connection leak in the RPC wallet's health check. By
not closing the test connection the watch-only node would slowly stack
up connections and eventually hit the ulimit.
2022-03-24 14:13:06 +01:00
Oliver Gugger
42b0aa9a8e
rpcwallet+itest: fix incomplete key info problem
Fixes an issue with SignOutputRaw in remote signing mode where we
weren't able to sign on the remote signer if we only provided the public
key or only the family/index (and not both).

Fixes part of an issue detected in lightninglabs/loop#457.
2022-03-24 14:13:05 +01:00
Oliver Gugger
5bf9b710fc
config_builder+rpcwallet: add full net params
As a preparation for parsing addresses, we need the full network
parameters and not just the coin type in the RPC wallet.
2022-03-24 14:13:05 +01:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Oliver Gugger
75016a176c
rpcwallet: disallow empty UTXO pk script [skip ci]
If we're signing for an UTXO that isn't known to the wallet, then the
UTXO's pk script _must_ be set in the sign descriptor. Otherwise we run
into a generic PSBT serialization error when running in a remote signing
setup.
2022-02-03 17:34:14 +01:00
Oliver Gugger
da59c1fa62
multi: add health check for remote signer 2022-01-06 14:35:25 +01:00
Oliver Gugger
9601a9ab84
multi: make remote signer RPC timeout configurable 2022-01-06 14:35:25 +01:00
Oliver Gugger
f3cd383d1f
rpcwallet: add critical log to remote signer errors 2022-01-06 14:35:24 +01:00
Oliver Gugger
3d353a9879
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-06 14:35:24 +01:00
Oliver Gugger
c24763b3da
lnd+lnwallet: add logger for btcwallet+rpcwallet 2022-01-06 13:24:32 +01:00
Oliver Gugger
6d339f31c0
rpcwallet: forward FinalizePsbt call over RPC 2021-10-14 15:42:53 +02:00
Oliver Gugger
a3addcc927
multi: forward SendCoins call over RPC 2021-10-14 15:42:52 +02:00
Oliver Gugger
19db382e24
multi: forward address and import calls over RPC
In order to support the full range of on-chain functionality, including
importing watch-only accounts in the watch-only instance, we need to
forward some calls like creating new addresses or importing accounts to
the remote signing instance.
2021-10-14 15:42:51 +02:00
Oliver Gugger
9cae7ad3c2
multi: add remote RPC signing wallet implementation 2021-10-14 15:42:49 +02:00