Skip to content

Commit 73bb025

Browse files
committed
Reparametrize ChannelSignerType by SignerProvider.
1 parent fddbd59 commit 73bb025

File tree

2 files changed

+44
-19
lines changed

2 files changed

+44
-19
lines changed

lightning/src/ln/channel.rs

+25-9
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
658658

659659
latest_monitor_update_id: u64,
660660

661-
holder_signer: ChannelSignerType<<SP::Target as SignerProvider>::EcdsaSigner>,
661+
holder_signer: ChannelSignerType<SP>,
662662
shutdown_scriptpubkey: Option<ShutdownScript>,
663663
destination_script: Script,
664664

@@ -3249,7 +3249,9 @@ impl<SP: Deref> Channel<SP> where
32493249
self.context.cur_counterparty_commitment_transaction_number + 1,
32503250
&secret
32513251
).map_err(|_| ChannelError::Close("Failed to validate revocation from peer".to_owned()))?;
3252-
}
3252+
},
3253+
// TODO (taproot|arik)
3254+
_ => todo!()
32533255
};
32543256

32553257
self.context.commitment_secrets.provide_secret(self.context.cur_counterparty_commitment_transaction_number + 1, msg.per_commitment_secret)
@@ -4140,7 +4142,9 @@ impl<SP: Deref> Channel<SP> where
41404142
max_fee_satoshis: our_max_fee,
41414143
}),
41424144
}), None))
4143-
}
4145+
},
4146+
// TODO (taproot|arik)
4147+
_ => todo!()
41444148
}
41454149
}
41464150

@@ -4380,7 +4384,9 @@ impl<SP: Deref> Channel<SP> where
43804384
max_fee_satoshis: our_max_fee,
43814385
}),
43824386
}), signed_tx))
4383-
}
4387+
},
4388+
// TODO (taproot|arik)
4389+
_ => todo!()
43844390
}
43854391
}
43864392
}
@@ -4492,7 +4498,7 @@ impl<SP: Deref> Channel<SP> where
44924498
}
44934499

44944500
#[cfg(test)]
4495-
pub fn get_signer(&self) -> &ChannelSignerType<<SP::Target as SignerProvider>::EcdsaSigner> {
4501+
pub fn get_signer(&self) -> &ChannelSignerType<SP> {
44964502
&self.context.holder_signer
44974503
}
44984504

@@ -4993,7 +4999,9 @@ impl<SP: Deref> Channel<SP> where
49934999
node_signature: our_node_sig,
49945000
bitcoin_signature: our_bitcoin_sig,
49955001
})
4996-
}
5002+
},
5003+
// TODO (taproot|arik)
5004+
_ => todo!()
49975005
}
49985006
}
49995007

@@ -5020,7 +5028,9 @@ impl<SP: Deref> Channel<SP> where
50205028
bitcoin_signature_2: if were_node_one { their_bitcoin_sig } else { our_bitcoin_sig },
50215029
contents: announcement,
50225030
})
5023-
}
5031+
},
5032+
// TODO (taproot|arik)
5033+
_ => todo!()
50245034
}
50255035
} else {
50265036
Err(ChannelError::Ignore("Attempted to sign channel announcement before we'd received announcement_signatures".to_string()))
@@ -5384,7 +5394,9 @@ impl<SP: Deref> Channel<SP> where
53845394
#[cfg(taproot)]
53855395
partial_signature_with_nonce: None,
53865396
}, (counterparty_commitment_txid, commitment_stats.htlcs_included)))
5387-
}
5397+
},
5398+
// TODO (taproot|arik)
5399+
_ => todo!()
53885400
}
53895401
}
53905402

@@ -5760,7 +5772,9 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
57605772
ChannelSignerType::Ecdsa(ecdsa) => {
57615773
Ok(ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.context.secp_ctx)
57625774
.map_err(|_| ChannelError::Close("Failed to get signatures for new commitment_signed".to_owned()))?.0)
5763-
}
5775+
},
5776+
// TODO (taproot|arik)
5777+
_ => todo!()
57645778
}
57655779
}
57665780

@@ -6490,6 +6504,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
64906504
// We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
64916505
Ok((counterparty_initial_bitcoin_tx.txid, initial_commitment_tx, counterparty_signature))
64926506
}
6507+
// TODO (taproot|arik)
6508+
_ => todo!()
64936509
}
64946510
}
64956511

lightning/src/sign/type_resolver.rs

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1-
use crate::sign::{ChannelSigner, EcdsaChannelSigner};
1+
use std::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)