@@ -23,12 +23,20 @@ use bitcoin::sighash;
23
23
use bitcoin:: sighash:: EcdsaSighashType ;
24
24
25
25
use bitcoin:: secp256k1;
26
+ #[ cfg( taproot) ]
27
+ use bitcoin:: secp256k1:: All ;
26
28
use bitcoin:: secp256k1:: { SecretKey , PublicKey } ;
27
29
use bitcoin:: secp256k1:: { Secp256k1 , ecdsa:: Signature } ;
30
+ #[ cfg( taproot) ]
31
+ use musig2:: types:: { PartialSignature , PublicNonce , SecretNonce } ;
28
32
use crate :: sign:: HTLCDescriptor ;
29
33
use crate :: util:: ser:: { Writeable , Writer } ;
30
34
use crate :: io:: Error ;
31
35
use crate :: ln:: features:: ChannelTypeFeatures ;
36
+ #[ cfg( taproot) ]
37
+ use crate :: ln:: msgs:: PartialSignatureWithNonce ;
38
+ #[ cfg( taproot) ]
39
+ use crate :: sign:: taproot:: TaprootChannelSigner ;
32
40
33
41
/// Initial value for revoked commitment downward counter
34
42
pub const INITIAL_REVOKED_COMMITMENT_NUMBER : u64 = 1 << 48 ;
@@ -200,11 +208,11 @@ impl EcdsaChannelSigner for TestChannelSigner {
200
208
}
201
209
202
210
fn sign_justice_revoked_output ( & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > {
203
- Ok ( self . inner . sign_justice_revoked_output ( justice_tx, input, amount, per_commitment_key, secp_ctx) . unwrap ( ) )
211
+ Ok ( EcdsaChannelSigner :: sign_justice_revoked_output ( & self . inner , justice_tx, input, amount, per_commitment_key, secp_ctx) . unwrap ( ) )
204
212
}
205
213
206
214
fn sign_justice_revoked_htlc ( & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey , htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > {
207
- Ok ( self . inner . sign_justice_revoked_htlc ( justice_tx, input, amount, per_commitment_key, htlc, secp_ctx) . unwrap ( ) )
215
+ Ok ( EcdsaChannelSigner :: sign_justice_revoked_htlc ( & self . inner , justice_tx, input, amount, per_commitment_key, htlc, secp_ctx) . unwrap ( ) )
208
216
}
209
217
210
218
fn sign_holder_htlc_transaction (
@@ -239,11 +247,11 @@ impl EcdsaChannelSigner for TestChannelSigner {
239
247
& hash_to_message ! ( sighash. as_byte_array( ) ) , & htlc_descriptor. counterparty_sig , & countersignatory_htlc_key
240
248
) . unwrap ( ) ;
241
249
}
242
- Ok ( self . inner . sign_holder_htlc_transaction ( htlc_tx, input, htlc_descriptor, secp_ctx) . unwrap ( ) )
250
+ Ok ( EcdsaChannelSigner :: sign_holder_htlc_transaction ( & self . inner , htlc_tx, input, htlc_descriptor, secp_ctx) . unwrap ( ) )
243
251
}
244
252
245
253
fn sign_counterparty_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey , htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > {
246
- Ok ( self . inner . sign_counterparty_htlc_transaction ( htlc_tx, input, amount, per_commitment_point, htlc, secp_ctx) . unwrap ( ) )
254
+ Ok ( EcdsaChannelSigner :: sign_counterparty_htlc_transaction ( & self . inner , htlc_tx, input, amount, per_commitment_point, htlc, secp_ctx) . unwrap ( ) )
247
255
}
248
256
249
257
fn sign_closing_transaction ( & self , closing_tx : & ClosingTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > {
@@ -259,7 +267,7 @@ impl EcdsaChannelSigner for TestChannelSigner {
259
267
// As long as our minimum dust limit is enforced and is greater than our anchor output
260
268
// value, an anchor output can only have an index within [0, 1].
261
269
assert ! ( anchor_tx. input[ input] . previous_output. vout == 0 || anchor_tx. input[ input] . previous_output. vout == 1 ) ;
262
- self . inner . sign_holder_anchor_input ( anchor_tx, input, secp_ctx)
270
+ EcdsaChannelSigner :: sign_holder_anchor_input ( & self . inner , anchor_tx, input, secp_ctx)
263
271
}
264
272
265
273
fn sign_channel_announcement_with_funding_key (
@@ -271,6 +279,45 @@ impl EcdsaChannelSigner for TestChannelSigner {
271
279
272
280
impl WriteableEcdsaChannelSigner for TestChannelSigner { }
273
281
282
+ #[ cfg( taproot) ]
283
+ impl TaprootChannelSigner for TestChannelSigner {
284
+ fn generate_local_nonce_pair ( & self , commitment_number : u64 , secp_ctx : & Secp256k1 < All > ) -> PublicNonce {
285
+ todo ! ( )
286
+ }
287
+
288
+ fn partially_sign_counterparty_commitment ( & self , counterparty_nonce : PublicNonce , commitment_tx : & CommitmentTransaction , preimages : Vec < PaymentPreimage > , secp_ctx : & Secp256k1 < All > ) -> Result < ( PartialSignatureWithNonce , Vec < secp256k1:: schnorr:: Signature > ) , ( ) > {
289
+ todo ! ( )
290
+ }
291
+
292
+ fn finalize_holder_commitment ( & self , commitment_number : u64 , commitment_tx : & HolderCommitmentTransaction , counterparty_partial_signature : PartialSignatureWithNonce , secp_ctx : & Secp256k1 < All > ) -> Result < PartialSignature , ( ) > {
293
+ todo ! ( )
294
+ }
295
+
296
+ fn sign_justice_revoked_output ( & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey , secp_ctx : & Secp256k1 < All > ) -> Result < secp256k1:: schnorr:: Signature , ( ) > {
297
+ todo ! ( )
298
+ }
299
+
300
+ fn sign_justice_revoked_htlc ( & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey , htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < All > ) -> Result < secp256k1:: schnorr:: Signature , ( ) > {
301
+ todo ! ( )
302
+ }
303
+
304
+ fn sign_holder_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize , htlc_descriptor : & HTLCDescriptor , secp_ctx : & Secp256k1 < All > ) -> Result < secp256k1:: schnorr:: Signature , ( ) > {
305
+ todo ! ( )
306
+ }
307
+
308
+ fn sign_counterparty_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey , htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < All > ) -> Result < secp256k1:: schnorr:: Signature , ( ) > {
309
+ todo ! ( )
310
+ }
311
+
312
+ fn partially_sign_closing_transaction ( & self , closing_tx : & ClosingTransaction , secp_ctx : & Secp256k1 < All > ) -> Result < PartialSignature , ( ) > {
313
+ todo ! ( )
314
+ }
315
+
316
+ fn sign_holder_anchor_input ( & self , anchor_tx : & Transaction , input : usize , secp_ctx : & Secp256k1 < All > ) -> Result < secp256k1:: schnorr:: Signature , ( ) > {
317
+ todo ! ( )
318
+ }
319
+ }
320
+
274
321
impl Writeable for TestChannelSigner {
275
322
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , Error > {
276
323
// TestChannelSigner has two fields - `inner` ([`InMemorySigner`]) and `state`
0 commit comments