Skip to content

Commit

Permalink
f rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
devrandom committed Sep 24, 2024
1 parent ad37be8 commit 0b6fe59
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
5 changes: 1 addition & 4 deletions lightning/src/ln/bolt11_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ mod tests {
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
use lightning_invoice::{Currency, InvoiceBuilder};
use std::time::SystemTime;
use bech32::ToBase32;
use crate::sign::{NodeSigner, Recipient};

#[test]
Expand Down Expand Up @@ -180,8 +179,6 @@ mod tests {
let (payment_hash, payment_secret) =
nodes[1].node.create_inbound_payment(None, 7200, None).unwrap();

let secp_ctx = Secp256k1::new();
let node_secret = nodes[1].keys_manager.backing.get_node_secret_key();
let timestamp = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap();
let invoice = InvoiceBuilder::new(Currency::Bitcoin)
.description("test".into())
Expand All @@ -192,7 +189,7 @@ mod tests {
.amount_milli_satoshis(50_000)
.payment_metadata(payment_metadata.clone())
.build_raw().unwrap();
let sig = nodes[1].keys_manager.backing.sign_invoice(invoice.hrp.to_string().as_bytes(), &invoice.data.to_base32(), Recipient::Node).unwrap();
let sig = nodes[1].keys_manager.backing.sign_invoice(&invoice, Recipient::Node).unwrap();
let invoice = invoice.sign::<_, ()>(|_| Ok(sig)).unwrap();
let invoice = Bolt11Invoice::from_signed(invoice).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::util::errors::APIError;
use crate::util::logger::Logger;
use crate::util::scid_utils;
use crate::util::test_channel_signer::TestChannelSigner;
#[cfg(test)]
#[cfg(any(test, feature = "_test_utils"))]
use crate::util::test_channel_signer::SignerOp;
use crate::util::test_utils;
use crate::util::test_utils::{TestChainMonitor, TestScorer, TestKeysInterface};
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ fn test_channel_resumption_fail_post_funding() {
assert_eq!(nodes[0].node.get_and_clear_pending_msg_events(), Vec::new());
}

#[test]
fn test_insane_channel_opens() {
#[xtest(feature = "_test_utils")]
pub fn test_insane_channel_opens() {
// Stand up a network of 2 nodes
use crate::ln::channel::TOTAL_BITCOIN_SUPPLY_SATOSHIS;
let mut cfg = UserConfig::default();
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/monitor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2251,8 +2251,8 @@ fn do_test_restored_packages_retry(check_old_monitor_retries_after_upgrade: bool
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);

// Reset our RNG counters to mirror the RNG output from when this test was written.
nodes[0].keys_manager.backing.inner.entropy_source.set_counter(0x1_0000_0004);
nodes[1].keys_manager.backing.inner.entropy_source.set_counter(0x1_0000_0004);
nodes[0].keys_manager.backing.inner.set_counter(0x1_0000_0004);
nodes[1].keys_manager.backing.inner.set_counter(0x1_0000_0004);

// Open a channel, lock in an HTLC, and immediately broadcast the commitment transaction. This
// ensures that the HTLC timeout package is held until we reach its expiration height.
Expand Down
35 changes: 16 additions & 19 deletions lightning/src/util/dyn_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ use crate::sign::taproot::TaprootChannelSigner;
use crate::sign::ChannelSigner;
use crate::sign::InMemorySigner;
use crate::sign::{
ecdsa::WriteableEcdsaChannelSigner, KeyMaterial, NodeSigner, Recipient, SignerProvider,
KeyMaterial, NodeSigner, Recipient, SignerProvider,
SpendableOutputDescriptor,
};
use crate::sign::{EntropySource, HTLCDescriptor, OutputSpender, PhantomKeysManager};
use crate::util::ser::{Readable, ReadableArgs};
use crate::util::ser::{Writeable, Writer};
#[cfg(any(test, feature = "_test_utils"))]
use crate::util::test_utils::OnlyReadsKeysInterface;
use lightning_invoice::RawBolt11Invoice;
use bitcoin;
use bitcoin::absolute::LockTime;
use bitcoin::bech32::u5;
use bitcoin::secp256k1::All;
use bitcoin::{secp256k1, ScriptBuf, Transaction, TxOut};
#[cfg(taproot)]
Expand Down Expand Up @@ -72,8 +72,6 @@ impl DynSigner {
}
}

impl WriteableEcdsaChannelSigner for DynSigner {}

#[cfg(taproot)]
#[allow(unused_variables)]
impl TaprootChannelSigner for DynSigner {
Expand Down Expand Up @@ -265,11 +263,11 @@ impl ChannelSigner for DynSigner {
&self,
idx: u64,
secp_ctx: &Secp256k1<secp256k1::All>,
) -> PublicKey;
) -> Result<PublicKey, ()>;
fn counterparty_pubkeys(&self) -> Option<&ChannelPublicKeys>;
fn funding_outpoint(&self) -> Option<&OutPoint>;
fn get_channel_parameters(&self) -> Option<&ChannelTransactionParameters>;
fn release_commitment_secret(&self, idx: u64) -> [u8; 32];
fn release_commitment_secret(&self, idx: u64) -> Result<[u8; 32], ()>;

fn validate_holder_commitment(
&self,
Expand Down Expand Up @@ -333,12 +331,7 @@ impl NodeSigner for DynKeysInterface {
fn sign_gossip_message(&self, msg: UnsignedGossipMessage) -> Result<Signature, ()>;
fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&Scalar>) -> Result<SharedSecret, ()>;

fn sign_invoice(
&self,
hrp_bytes: &[u8],
invoice_data: &[u5],
recipient: Recipient,
) -> Result<RecoverableSignature, ()>;
fn sign_invoice(&self, invoice: &RawBolt11Invoice, recipient: Recipient) -> Result<RecoverableSignature, ()>;

fn sign_bolt12_invoice(
&self, invoice: &crate::offers::invoice::UnsignedBolt12Invoice
Expand Down Expand Up @@ -398,6 +391,10 @@ impl OutputSpender for DynKeysInterface {
pub trait DynKeysInterfaceTrait:
NodeSigner + OutputSpender + SignerProvider<EcdsaSigner = DynSigner> + EntropySource + Send + Sync
{
#[cfg(test)]
fn set_counter(&self, _count: u64) {
}

}

#[cfg(taproot)]
Expand Down Expand Up @@ -431,12 +428,7 @@ impl NodeSigner for DynPhantomKeysInterface {
fn sign_gossip_message(&self, msg: UnsignedGossipMessage) -> Result<Signature, ()>;
fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&Scalar>) -> Result<SharedSecret, ()>;

fn sign_invoice(
&self,
hrp_bytes: &[u8],
invoice_data: &[u5],
recipient: Recipient,
) -> Result<RecoverableSignature, ()>;
fn sign_invoice(&self, invoice: &RawBolt11Invoice, recipient: Recipient) -> Result<RecoverableSignature, ()>;

fn sign_bolt12_invoice(
&self, invoice: &crate::offers::invoice::UnsignedBolt12Invoice
Expand Down Expand Up @@ -498,7 +490,12 @@ impl OutputSpender for DynPhantomKeysInterface {
}
}

impl DynKeysInterfaceTrait for DynPhantomKeysInterface {}
impl DynKeysInterfaceTrait for DynPhantomKeysInterface {
#[cfg(test)]
fn set_counter(&self, count: u64) {
self.inner.inner.entropy_source.set_counter(count);
}
}

impl ReadableArgs<&DynKeysInterface> for DynSigner {
fn read<R: Read>(_reader: &mut R, _params: &DynKeysInterface) -> Result<Self, DecodeError> {
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/util/test_channel_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ impl TestChannelSigner {
self.state.lock().unwrap()
}

#[cfg(test)]
#[cfg(any(test, feature = "_test_utils"))]
pub fn enable_op(&self, signer_op: SignerOp) {
self.get_enforcement_state().disabled_signer_ops.remove(&signer_op);
}

#[cfg(test)]
#[cfg(any(test, feature = "_test_utils"))]
pub fn disable_op(&self, signer_op: SignerOp) {
self.get_enforcement_state().disabled_signer_ops.insert(signer_op);
}
Expand Down

0 comments on commit 0b6fe59

Please sign in to comment.