|
10 | 10 | use crate::utils::test_logger;
|
11 | 11 | use bitcoin::secp256k1::{self, Keypair, Parity, PublicKey, Secp256k1, SecretKey};
|
12 | 12 | use core::convert::TryFrom;
|
13 |
| -use lightning::blinded_path::message::{ForwardNode, MessageContext, OffersContext}; |
| 13 | +use lightning::blinded_path::payment::{Bolt12OfferContext, ForwardNode, ForwardTlvs, PaymentConstraints, PaymentContext, PaymentRelay, ReceiveTlvs}; |
14 | 14 | use lightning::blinded_path::BlindedPath;
|
| 15 | +use lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA; |
15 | 16 | use lightning::ln::features::BlindedHopFeatures;
|
| 17 | +use lightning::ln::types::PaymentSecret; |
16 | 18 | use lightning::ln::PaymentHash;
|
17 |
| -use lightning::offers::invoice::{BlindedPayInfo, UnsignedBolt12Invoice}; |
18 |
| -use lightning::offers::invoice_request::InvoiceRequest; |
| 19 | +use lightning::offers::invoice::UnsignedBolt12Invoice; |
| 20 | +use lightning::offers::invoice_request::{InvoiceRequest, InvoiceRequestFields}; |
| 21 | +use lightning::offers::offer::OfferId; |
19 | 22 | use lightning::offers::parse::Bolt12SemanticError;
|
20 | 23 | use lightning::sign::EntropySource;
|
21 | 24 | use lightning::util::ser::Writeable;
|
| 25 | +use lightning::util::string::UntrustedString; |
22 | 26 |
|
23 | 27 | #[inline]
|
24 | 28 | pub fn do_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
|
@@ -76,57 +80,48 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
|
76 | 80 | invoice_request: &InvoiceRequest, secp_ctx: &Secp256k1<T>,
|
77 | 81 | ) -> Result<UnsignedBolt12Invoice, Bolt12SemanticError> {
|
78 | 82 | let entropy_source = Randomness {};
|
79 |
| - let intermediate_nodes = [ |
80 |
| - [ |
81 |
| - ForwardNode { node_id: pubkey(43), short_channel_id: None }, |
82 |
| - ForwardNode { node_id: pubkey(44), short_channel_id: None }, |
83 |
| - ], |
84 |
| - [ |
85 |
| - ForwardNode { node_id: pubkey(45), short_channel_id: None }, |
86 |
| - ForwardNode { node_id: pubkey(46), short_channel_id: None }, |
87 |
| - ], |
88 |
| - ]; |
89 |
| - let paths = vec![ |
90 |
| - BlindedPath::new_for_message( |
91 |
| - &intermediate_nodes[0], |
92 |
| - pubkey(42), |
93 |
| - MessageContext::Offers(OffersContext::Unknown {}), |
94 |
| - &entropy_source, |
95 |
| - secp_ctx, |
96 |
| - ) |
97 |
| - .unwrap(), |
98 |
| - BlindedPath::new_for_message( |
99 |
| - &intermediate_nodes[1], |
100 |
| - pubkey(42), |
101 |
| - MessageContext::Offers(OffersContext::Unknown {}), |
102 |
| - &entropy_source, |
103 |
| - secp_ctx, |
104 |
| - ) |
105 |
| - .unwrap(), |
106 |
| - ]; |
107 |
| - |
108 |
| - let payinfo = vec![ |
109 |
| - BlindedPayInfo { |
110 |
| - fee_base_msat: 1, |
111 |
| - fee_proportional_millionths: 1_000, |
112 |
| - cltv_expiry_delta: 42, |
113 |
| - htlc_minimum_msat: 100, |
114 |
| - htlc_maximum_msat: 1_000_000_000_000, |
115 |
| - features: BlindedHopFeatures::empty(), |
| 83 | + let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext { |
| 84 | + offer_id: OfferId([42; 32]), |
| 85 | + invoice_request: InvoiceRequestFields { |
| 86 | + payer_id: invoice_request.payer_id(), |
| 87 | + quantity: invoice_request.quantity(), |
| 88 | + payer_note_truncated: invoice_request.payer_note().map(|s| UntrustedString(s.to_string())), |
| 89 | + }, |
| 90 | + }); |
| 91 | + let payee_tlvs = ReceiveTlvs { |
| 92 | + payment_secret: PaymentSecret([42; 32]), |
| 93 | + payment_constraints: PaymentConstraints { |
| 94 | + max_cltv_expiry: 1_000_000, |
| 95 | + htlc_minimum_msat: 1, |
116 | 96 | },
|
117 |
| - BlindedPayInfo { |
118 |
| - fee_base_msat: 1, |
119 |
| - fee_proportional_millionths: 1_000, |
120 |
| - cltv_expiry_delta: 42, |
121 |
| - htlc_minimum_msat: 100, |
| 97 | + payment_context, |
| 98 | + }; |
| 99 | + let intermediate_nodes = [ |
| 100 | + ForwardNode { |
| 101 | + tlvs: ForwardTlvs { |
| 102 | + short_channel_id: 43, |
| 103 | + payment_relay: PaymentRelay { |
| 104 | + cltv_expiry_delta: 40, |
| 105 | + fee_proportional_millionths: 1_000, |
| 106 | + fee_base_msat: 1, |
| 107 | + }, |
| 108 | + payment_constraints: PaymentConstraints { |
| 109 | + max_cltv_expiry: payee_tlvs.payment_constraints.max_cltv_expiry + 40, |
| 110 | + htlc_minimum_msat: 100, |
| 111 | + }, |
| 112 | + features: BlindedHopFeatures::empty(), |
| 113 | + }, |
| 114 | + node_id: pubkey(43), |
122 | 115 | htlc_maximum_msat: 1_000_000_000_000,
|
123 |
| - features: BlindedHopFeatures::empty(), |
124 | 116 | },
|
125 | 117 | ];
|
| 118 | + let payment_path = BlindedPath::new_for_payment( |
| 119 | + &intermediate_nodes, pubkey(42), payee_tlvs, u64::MAX, MIN_FINAL_CLTV_EXPIRY_DELTA, |
| 120 | + &entropy_source, secp_ctx, |
| 121 | + ).unwrap(); |
126 | 122 |
|
127 |
| - let payment_paths = payinfo.into_iter().zip(paths.into_iter()).collect(); |
128 | 123 | let payment_hash = PaymentHash([42; 32]);
|
129 |
| - invoice_request.respond_with(payment_paths, payment_hash)?.build() |
| 124 | + invoice_request.respond_with(vec![payment_path], payment_hash)?.build() |
130 | 125 | }
|
131 | 126 |
|
132 | 127 | pub fn invoice_request_deser_test<Out: test_logger::Output>(data: &[u8], out: Out) {
|
|
0 commit comments