Skip to content

Commit 1215707

Browse files
committed
Move InMemorySigner Taproot implementation to sign module.
1 parent e72d67c commit 1215707

File tree

2 files changed

+43
-38
lines changed

2 files changed

+43
-38
lines changed

lightning/src/sign/mod.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ use bitcoin::hashes::sha256::Hash as Sha256;
2626
use bitcoin::hashes::sha256d::Hash as Sha256dHash;
2727
use bitcoin::hash_types::WPubkeyHash;
2828

29+
#[cfg(taproot)]
30+
use bitcoin::secp256k1::All;
2931
use bitcoin::secp256k1::{KeyPair, PublicKey, Scalar, Secp256k1, SecretKey, Signing};
3032
use bitcoin::secp256k1::ecdh::SharedSecret;
3133
use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
@@ -49,6 +51,8 @@ use crate::prelude::*;
4951
use core::convert::TryInto;
5052
use core::ops::Deref;
5153
use core::sync::atomic::{AtomicUsize, Ordering};
54+
#[cfg(taproot)]
55+
use musig2::types::{PartialSignature, PublicNonce};
5256
use crate::io::{self, Error};
5357
use crate::ln::features::ChannelTypeFeatures;
5458
use crate::ln::msgs::{DecodeError, MAX_VALUE_MSAT};
@@ -1117,6 +1121,45 @@ impl EcdsaChannelSigner for InMemorySigner {
11171121
}
11181122
}
11191123

1124+
#[cfg(taproot)]
1125+
impl TaprootChannelSigner for InMemorySigner {
1126+
fn generate_local_nonce_pair(&self, secp_ctx: &Secp256k1<All>) -> PublicNonce {
1127+
todo!()
1128+
}
1129+
1130+
fn partially_sign_counterparty_commitment(&self, commitment_tx: &CommitmentTransaction, preimages: Vec<PaymentPreimage>, secp_ctx: &Secp256k1<All>) -> Result<(PartialSignature, Vec<Signature>), ()> {
1131+
todo!()
1132+
}
1133+
1134+
fn partially_sign_holder_commitment_and_htlcs(&self, commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<All>) -> Result<(PartialSignature, Vec<Signature>), ()> {
1135+
todo!()
1136+
}
1137+
1138+
fn sign_justice_revoked_output(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
1139+
todo!()
1140+
}
1141+
1142+
fn sign_justice_revoked_htlc(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
1143+
todo!()
1144+
}
1145+
1146+
fn sign_holder_htlc_transaction(&self, htlc_tx: &Transaction, input: usize, htlc_descriptor: &HTLCDescriptor, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
1147+
todo!()
1148+
}
1149+
1150+
fn sign_counterparty_htlc_transaction(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
1151+
todo!()
1152+
}
1153+
1154+
fn partially_sign_closing_transaction(&self, closing_tx: &ClosingTransaction, secp_ctx: &Secp256k1<All>) -> Result<PartialSignature, ()> {
1155+
todo!()
1156+
}
1157+
1158+
fn sign_holder_anchor_input(&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
1159+
todo!()
1160+
}
1161+
}
1162+
11201163
const SERIALIZATION_VERSION: u8 = 1;
11211164

11221165
const MIN_SERIALIZATION_VERSION: u8 = 1;

lightning/src/sign/taproot.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -151,41 +151,3 @@ pub trait TaprootChannelSigner: ChannelSigner {
151151

152152
// TODO: sign channel announcement
153153
}
154-
155-
impl TaprootChannelSigner for super::InMemorySigner {
156-
fn generate_local_nonce_pair(&self, secp_ctx: &Secp256k1<All>) -> PublicNonce {
157-
todo!()
158-
}
159-
160-
fn partially_sign_counterparty_commitment(&self, commitment_tx: &CommitmentTransaction, preimages: Vec<PaymentPreimage>, secp_ctx: &Secp256k1<All>) -> Result<(PartialSignature, Vec<Signature>), ()> {
161-
todo!()
162-
}
163-
164-
fn partially_sign_holder_commitment_and_htlcs(&self, commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<All>) -> Result<(PartialSignature, Vec<Signature>), ()> {
165-
todo!()
166-
}
167-
168-
fn sign_justice_revoked_output(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
169-
todo!()
170-
}
171-
172-
fn sign_justice_revoked_htlc(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
173-
todo!()
174-
}
175-
176-
fn sign_holder_htlc_transaction(&self, htlc_tx: &Transaction, input: usize, htlc_descriptor: &HTLCDescriptor, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
177-
todo!()
178-
}
179-
180-
fn sign_counterparty_htlc_transaction(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
181-
todo!()
182-
}
183-
184-
fn partially_sign_closing_transaction(&self, closing_tx: &ClosingTransaction, secp_ctx: &Secp256k1<All>) -> Result<PartialSignature, ()> {
185-
todo!()
186-
}
187-
188-
fn sign_holder_anchor_input(&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()> {
189-
todo!()
190-
}
191-
}

0 commit comments

Comments
 (0)