Skip to content

Commit 4ae8dad

Browse files
committed
Reparametrize ChannelSignerType by SignerProvider.
1 parent 7dd7fa8 commit 4ae8dad

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

lightning/src/ln/channel.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
661661

662662
latest_monitor_update_id: u64,
663663

664-
holder_signer: ChannelSignerType<<SP::Target as SignerProvider>::EcdsaSigner>,
664+
holder_signer: ChannelSignerType<SP>,
665665
shutdown_scriptpubkey: Option<ShutdownScript>,
666666
destination_script: Script,
667667

@@ -3258,7 +3258,9 @@ impl<SP: Deref> Channel<SP> where
32583258
self.context.cur_counterparty_commitment_transaction_number + 1,
32593259
&secret
32603260
).map_err(|_| ChannelError::Close("Failed to validate revocation from peer".to_owned()))?;
3261-
}
3261+
},
3262+
// TODO (taproot|arik)
3263+
_ => todo!()
32623264
};
32633265

32643266
self.context.commitment_secrets.provide_secret(self.context.cur_counterparty_commitment_transaction_number + 1, msg.per_commitment_secret)
@@ -4149,7 +4151,9 @@ impl<SP: Deref> Channel<SP> where
41494151
max_fee_satoshis: our_max_fee,
41504152
}),
41514153
}), None))
4152-
}
4154+
},
4155+
// TODO (taproot|arik)
4156+
_ => todo!()
41534157
}
41544158
}
41554159

@@ -4389,7 +4393,9 @@ impl<SP: Deref> Channel<SP> where
43894393
max_fee_satoshis: our_max_fee,
43904394
}),
43914395
}), signed_tx))
4392-
}
4396+
},
4397+
// TODO (taproot|arik)
4398+
_ => todo!()
43934399
}
43944400
}
43954401
}
@@ -4501,7 +4507,7 @@ impl<SP: Deref> Channel<SP> where
45014507
}
45024508

45034509
#[cfg(test)]
4504-
pub fn get_signer(&self) -> &ChannelSignerType<<SP::Target as SignerProvider>::EcdsaSigner> {
4510+
pub fn get_signer(&self) -> &ChannelSignerType<SP> {
45054511
&self.context.holder_signer
45064512
}
45074513

@@ -5002,7 +5008,9 @@ impl<SP: Deref> Channel<SP> where
50025008
node_signature: our_node_sig,
50035009
bitcoin_signature: our_bitcoin_sig,
50045010
})
5005-
}
5011+
},
5012+
// TODO (taproot|arik)
5013+
_ => todo!()
50065014
}
50075015
}
50085016

@@ -5029,7 +5037,9 @@ impl<SP: Deref> Channel<SP> where
50295037
bitcoin_signature_2: if were_node_one { their_bitcoin_sig } else { our_bitcoin_sig },
50305038
contents: announcement,
50315039
})
5032-
}
5040+
},
5041+
// TODO (taproot|arik)
5042+
_ => todo!()
50335043
}
50345044
} else {
50355045
Err(ChannelError::Ignore("Attempted to sign channel announcement before we'd received announcement_signatures".to_string()))
@@ -5402,7 +5412,9 @@ impl<SP: Deref> Channel<SP> where
54025412
#[cfg(taproot)]
54035413
partial_signature_with_nonce: None,
54045414
}, (counterparty_commitment_txid, commitment_stats.htlcs_included)))
5405-
}
5415+
},
5416+
// TODO (taproot|arik)
5417+
_ => todo!()
54065418
}
54075419
}
54085420

@@ -5778,7 +5790,9 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
57785790
ChannelSignerType::Ecdsa(ecdsa) => {
57795791
Ok(ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.context.secp_ctx)
57805792
.map_err(|_| ChannelError::Close("Failed to get signatures for new commitment_signed".to_owned()))?.0)
5781-
}
5793+
},
5794+
// TODO (taproot|arik)
5795+
_ => todo!()
57825796
}
57835797
}
57845798

@@ -6508,6 +6522,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
65086522
// We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
65096523
Ok((counterparty_initial_commitment_tx, initial_commitment_tx, counterparty_signature))
65106524
}
6525+
// TODO (taproot|arik)
6526+
_ => todo!()
65116527
}
65126528
}
65136529

lightning/src/sign/taproot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Defines a Taproot-specific signer type.
22
3+
use alloc::vec::Vec;
34
use bitcoin::blockdata::transaction::Transaction;
45
use bitcoin::secp256k1;
56
use bitcoin::secp256k1::{PublicKey, schnorr::Signature, Secp256k1, SecretKey};

lightning/src/sign/type_resolver.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1-
use crate::sign::{ChannelSigner, EcdsaChannelSigner};
1+
use core::ops::Deref;
2+
use crate::sign::{ChannelSigner, SignerProvider};
23

3-
pub(crate) enum ChannelSignerType<ECS: EcdsaChannelSigner> {
4+
pub(crate) enum ChannelSignerType<SP: Deref> where SP::Target: SignerProvider {
45
// in practice, this will only ever be an EcdsaChannelSigner (specifically, Writeable)
5-
Ecdsa(ECS)
6+
Ecdsa(<SP::Target as SignerProvider>::EcdsaSigner),
7+
#[cfg(taproot)]
8+
Taproot(<SP::Target as SignerProvider>::TaprootSigner),
69
}
710

8-
impl<ECS: EcdsaChannelSigner> ChannelSignerType<ECS>{
11+
impl<SP: Deref> ChannelSignerType<SP> where SP::Target: SignerProvider {
912
pub(crate) fn as_ref(&self) -> &dyn ChannelSigner {
1013
match self {
11-
ChannelSignerType::Ecdsa(ecs) => ecs
14+
ChannelSignerType::Ecdsa(ecs) => ecs,
15+
#[cfg(taproot)]
16+
ChannelSignerType::Taproot(tcs) => tcs,
1217
}
1318
}
1419

1520
pub(crate) fn as_mut(&mut self) -> &mut dyn ChannelSigner {
1621
match self {
17-
ChannelSignerType::Ecdsa(ecs) => ecs
22+
ChannelSignerType::Ecdsa(ecs) => ecs,
23+
#[cfg(taproot)]
24+
ChannelSignerType::Taproot(tcs) => tcs,
1825
}
1926
}
2027

21-
pub(crate) fn as_ecdsa(&self) -> Option<&ECS> {
28+
pub(crate) fn as_ecdsa(&self) -> Option<&<SP::Target as SignerProvider>::EcdsaSigner> {
2229
match self {
23-
ChannelSignerType::Ecdsa(ecs) => Some(ecs)
30+
ChannelSignerType::Ecdsa(ecs) => Some(ecs),
31+
_ => None
2432
}
2533
}
2634

27-
pub(crate) fn as_mut_ecdsa(&mut self) -> Option<&mut ECS> {
35+
pub(crate) fn as_mut_ecdsa(&mut self) -> Option<&mut <SP::Target as SignerProvider>::EcdsaSigner> {
2836
match self {
29-
ChannelSignerType::Ecdsa(ecs) => Some(ecs)
37+
ChannelSignerType::Ecdsa(ecs) => Some(ecs),
38+
_ => None
3039
}
3140
}
3241
}

0 commit comments

Comments
 (0)