Skip to content

Commit 2996180

Browse files
f don't use deprecated invreq creation interface
1 parent cfe9449 commit 2996180

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,26 +2268,28 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
22682268

22692269
#[cfg(test)]
22702270
mod tests {
2271-
use bitcoin::hex::FromHex;
22722271
use bitcoin::network::Network;
2273-
use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey};
2272+
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
22742273

22752274
use core::time::Duration;
22762275

22772276
use crate::blinded_path::EmptyNodeIdLookUp;
22782277
use crate::events::{Event, PathFailure, PaymentFailureReason};
22792278
use crate::types::payment::{PaymentHash, PaymentPreimage};
22802279
use crate::ln::channelmanager::{PaymentId, RecipientOnionFields};
2280+
use crate::ln::inbound_payment::ExpandedKey;
22812281
use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, NodeFeatures};
22822282
use crate::ln::msgs::{ErrorAction, LightningError};
22832283
use crate::ln::outbound_payment::{Bolt12PaymentError, OutboundPayments, PendingOutboundPayment, Retry, RetryableSendFailure, StaleExpiration};
22842284
#[cfg(feature = "std")]
22852285
use crate::offers::invoice::DEFAULT_RELATIVE_EXPIRY;
2286-
use crate::offers::invoice_request::{InvoiceRequest, UnsignedInvoiceRequest};
2286+
use crate::offers::invoice_request::InvoiceRequest;
2287+
use crate::offers::nonce::Nonce;
22872288
use crate::offers::offer::OfferBuilder;
22882289
use crate::offers::test_utils::*;
22892290
use crate::routing::gossip::NetworkGraph;
22902291
use crate::routing::router::{InFlightHtlcs, Path, PaymentParameters, Route, RouteHop, RouteParameters};
2292+
use crate::sign::KeyMaterial;
22912293
use crate::sync::{Arc, Mutex, RwLock};
22922294
use crate::util::errors::APIError;
22932295
use crate::util::hash_tables::new_hash_map;
@@ -2833,26 +2835,18 @@ mod tests {
28332835
}
28342836

28352837
fn dummy_invoice_request() -> InvoiceRequest {
2838+
let expanded_key = ExpandedKey::new(&KeyMaterial([42; 32]));
2839+
let entropy = FixedEntropy {};
2840+
let nonce = Nonce::from_entropy_source(&entropy);
28362841
let secp_ctx = Secp256k1::new();
2837-
let recipient_pubkey = {
2838-
let secret_key = SecretKey::from_slice(&<Vec<u8>>::from_hex("4141414141414141414141414141414141414141414141414141414141414141").unwrap()).unwrap();
2839-
Keypair::from_secret_key(&secp_ctx, &secret_key).public_key()
2840-
};
2841-
let payer_keys = {
2842-
let secret_key = SecretKey::from_slice(&<Vec<u8>>::from_hex("4242424242424242424242424242424242424242424242424242424242424242").unwrap()).unwrap();
2843-
Keypair::from_secret_key(&secp_ctx, &secret_key)
2844-
};
2845-
OfferBuilder::new(recipient_pubkey)
2846-
.description("test".into())
2842+
let payment_id = PaymentId([1; 32]);
2843+
2844+
OfferBuilder::new(recipient_pubkey())
28472845
.amount_msats(1000)
2848-
.build()
2849-
.unwrap()
2850-
.request_invoice(vec![0; 8], payer_keys.public_key()).unwrap()
2851-
.build()
2846+
.build().unwrap()
2847+
.request_invoice_deriving_signing_pubkey(&expanded_key, nonce, &secp_ctx, payment_id)
28522848
.unwrap()
2853-
.sign(|message: &UnsignedInvoiceRequest|
2854-
Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &payer_keys))
2855-
)
2849+
.build_and_sign()
28562850
.unwrap()
28572851
}
28582852

0 commit comments

Comments
 (0)