Skip to content

Commit e5724a5

Browse files
committed
Deparametrize create_invoice methods to infer Signer from KeysInterface.
1 parent 0914178 commit e5724a5

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ pub async fn process_events_async<
398398
where
399399
CA::Target: 'static + chain::Access,
400400
CF::Target: 'static + chain::Filter,
401-
CW::Target: 'static + chain::Watch<Signer>,
401+
CW::Target: 'static + chain::Watch<<K::Target as KeysInterface>::Signer>,
402402
T::Target: 'static + BroadcasterInterface,
403403
K::Target: 'static + KeysInterface,
404404
F::Target: 'static + FeeEstimator,
@@ -408,7 +408,7 @@ where
408408
OMH::Target: 'static + OnionMessageHandler,
409409
RMH::Target: 'static + RoutingMessageHandler,
410410
UMH::Target: 'static + CustomMessageHandler,
411-
PS::Target: 'static + Persister<'a, <K::Target as KeysInterface>::Signer, CW, T, K, F, L, SC>,
411+
PS::Target: 'static + Persister<'a, CW, T, K, F, L, SC>,
412412
{
413413
let mut should_continue = true;
414414
define_run_body!(persister, event_handler, chain_monitor, channel_manager,

lightning-invoice/src/utils.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bech32::ToBase32;
88
use bitcoin_hashes::{Hash, sha256};
99
use lightning::chain;
1010
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
11-
use lightning::chain::keysinterface::{Recipient, KeysInterface, Sign};
11+
use lightning::chain::keysinterface::{Recipient, KeysInterface};
1212
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
1313
use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, PaymentSendFailure, MIN_FINAL_CLTV_EXPIRY};
1414
#[cfg(feature = "std")]
@@ -54,7 +54,7 @@ use crate::sync::Mutex;
5454
/// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
5555
/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
5656
/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
57-
pub fn create_phantom_invoice<Signer: Sign, K: Deref, L: Deref>(
57+
pub fn create_phantom_invoice<K: Deref, L: Deref>(
5858
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: String,
5959
invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
6060
logger: L, network: Currency,
@@ -65,7 +65,7 @@ where
6565
{
6666
let description = Description::new(description).map_err(SignOrCreationError::CreationError)?;
6767
let description = InvoiceDescription::Direct(&description,);
68-
_create_phantom_invoice::<Signer, K, L>(
68+
_create_phantom_invoice::<K, L>(
6969
amt_msat, payment_hash, description, invoice_expiry_delta_secs, phantom_route_hints,
7070
keys_manager, logger, network,
7171
)
@@ -103,7 +103,7 @@ where
103103
/// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
104104
/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
105105
/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
106-
pub fn create_phantom_invoice_with_description_hash<Signer: Sign, K: Deref, L: Deref>(
106+
pub fn create_phantom_invoice_with_description_hash<K: Deref, L: Deref>(
107107
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, invoice_expiry_delta_secs: u32,
108108
description_hash: Sha256, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
109109
logger: L, network: Currency
@@ -112,14 +112,14 @@ where
112112
K::Target: KeysInterface,
113113
L::Target: Logger,
114114
{
115-
_create_phantom_invoice::<Signer, K, L>(
115+
_create_phantom_invoice::<K, L>(
116116
amt_msat, payment_hash, InvoiceDescription::Hash(&description_hash),
117117
invoice_expiry_delta_secs, phantom_route_hints, keys_manager, logger, network,
118118
)
119119
}
120120

121121
#[cfg(feature = "std")]
122-
fn _create_phantom_invoice<Signer: Sign, K: Deref, L: Deref>(
122+
fn _create_phantom_invoice<K: Deref, L: Deref>(
123123
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: InvoiceDescription,
124124
invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
125125
logger: L, network: Currency,
@@ -1009,7 +1009,7 @@ mod test {
10091009
let non_default_invoice_expiry_secs = 4200;
10101010

10111011
let invoice =
1012-
crate::utils::create_phantom_invoice::<EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger>(
1012+
crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>(
10131013
Some(payment_amt), payment_hash, "test".to_string(), non_default_invoice_expiry_secs,
10141014
route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet
10151015
).unwrap();
@@ -1118,7 +1118,7 @@ mod test {
11181118
nodes[2].node.get_phantom_route_hints(),
11191119
];
11201120

1121-
let invoice = crate::utils::create_phantom_invoice::<EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger>(Some(payment_amt), Some(payment_hash), "test".to_string(), 3600, route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet).unwrap();
1121+
let invoice = crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>(Some(payment_amt), Some(payment_hash), "test".to_string(), 3600, route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet).unwrap();
11221122

11231123
let chan_0_1 = &nodes[1].node.list_usable_channels()[0];
11241124
assert_eq!(invoice.route_hints()[0].0[0].htlc_minimum_msat, chan_0_1.inbound_htlc_minimum_msat);
@@ -1146,7 +1146,7 @@ mod test {
11461146
let description_hash = crate::Sha256(Hash::hash("Description hash phantom invoice".as_bytes()));
11471147
let non_default_invoice_expiry_secs = 4200;
11481148
let invoice = crate::utils::create_phantom_invoice_with_description_hash::<
1149-
EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger,
1149+
&test_utils::TestKeysInterface, &test_utils::TestLogger,
11501150
>(
11511151
Some(payment_amt), None, non_default_invoice_expiry_secs, description_hash,
11521152
route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet
@@ -1461,7 +1461,7 @@ mod test {
14611461
.map(|route_hint| route_hint.phantom_scid)
14621462
.collect::<HashSet<u64>>();
14631463

1464-
let invoice = crate::utils::create_phantom_invoice::<EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger>(invoice_amt, None, "test".to_string(), 3600, phantom_route_hints, &invoice_node.keys_manager, &invoice_node.logger, Currency::BitcoinTestnet).unwrap();
1464+
let invoice = crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>(invoice_amt, None, "test".to_string(), 3600, phantom_route_hints, &invoice_node.keys_manager, &invoice_node.logger, Currency::BitcoinTestnet).unwrap();
14651465

14661466
let invoice_hints = invoice.private_routes();
14671467

0 commit comments

Comments
 (0)