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