Merge pull request #916 from TheBlueMatt/2021-05-fix-disabled-announcements
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Sat, 15 May 2021 00:44:40 +0000 (00:44 +0000)
committerGitHub <noreply@github.com>
Sat, 15 May 2021 00:44:40 +0000 (00:44 +0000)
Avoid persisting a ChannelManager after each timer tick and send update_channel re-enable messages

fuzz/src/chanmon_consistency.rs
lightning-block-sync/src/http.rs
lightning-invoice/src/utils.rs
lightning/src/ln/channelmanager.rs

index 3fd6515fdbc469a26fbe5491c56bfc65d1f80097..be4a0ef4401caeaf478f9e6d3911c345f327d372 100644 (file)
@@ -272,7 +272,7 @@ fn get_payment_secret_hash(dest: &ChanMan, payment_id: &mut u8) -> Option<(Payme
        let mut payment_hash;
        for _ in 0..256 {
                payment_hash = PaymentHash(Sha256::hash(&[*payment_id; 1]).into_inner());
-               if let Ok(payment_secret) = dest.create_inbound_payment_for_hash(payment_hash, None, 7200, 0) {
+               if let Ok(payment_secret) = dest.create_inbound_payment_for_hash(payment_hash, None, 3600, 0) {
                        return Some((payment_secret, payment_hash));
                }
                *payment_id = payment_id.wrapping_add(1);
index 154afa4889c7b7b9e263eac22cf6f5e5aff0bfd2..2e70e18659936e2746638ba684b36ce20c3095ca 100644 (file)
@@ -348,9 +348,11 @@ impl HttpClient {
 
                if !status.is_ok() {
                        // TODO: Handle 3xx redirection responses.
-                       let error_details = match contents.is_ascii() {
-                               true => String::from_utf8_lossy(&contents).to_string(),
-                               false => "binary".to_string()
+                       let error_details = match String::from_utf8(contents) {
+                               // Check that the string is all-ASCII with no control characters before returning
+                               // it.
+                               Ok(s) if s.as_bytes().iter().all(|c| c.is_ascii() && !c.is_ascii_control()) => s,
+                               _ => "binary".to_string()
                        };
                        let error_msg = format!("Errored with status: {} and contents: {}",
                                                status.code, error_details);
index 3b97a8bb81a8c97d7058cf2027b8a06620cbe453..b75a215ee430341b64ca62bacfe4d278e86c02d0 100644 (file)
@@ -1,5 +1,5 @@
 //! Convenient utilities to create an invoice.
-use {Currency, Invoice, InvoiceBuilder, SignOrCreationError, RawInvoice};
+use {Currency, DEFAULT_EXPIRY_TIME, Invoice, InvoiceBuilder, SignOrCreationError, RawInvoice};
 use bech32::ToBase32;
 use bitcoin_hashes::Hash;
 use lightning::chain;
@@ -9,6 +9,7 @@ use lightning::ln::channelmanager::{ChannelManager, MIN_FINAL_CLTV_EXPIRY};
 use lightning::routing::network_graph::RoutingFees;
 use lightning::routing::router::RouteHintHop;
 use lightning::util::logger::Logger;
+use std::convert::TryInto;
 use std::ops::Deref;
 
 /// Utility to construct an invoice. Generally, unless you want to do something like a custom
@@ -54,7 +55,7 @@ where
 
        let (payment_hash, payment_secret) = channelmanager.create_inbound_payment(
                amt_msat,
-               7200, // default invoice expiry is 2 hours
+               DEFAULT_EXPIRY_TIME.try_into().unwrap(),
                0,
        );
        let our_node_pubkey = channelmanager.get_our_node_id();
index 922912932e7c6df71a21f78ef459c80e06a34ccf..54bd3c89ff3f9d94789d576623ab6373f76b7821 100644 (file)
@@ -3517,7 +3517,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
        /// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
        /// in excess of the current time. This should roughly match the expiry time set in the invoice.
        /// After this many seconds, we will remove the inbound payment, resulting in any attempts to
-       /// pay the invoice failing. The BOLT spec suggests 7,200 secs as a default validity time for
+       /// pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
        /// invoices when no timeout is set.
        ///
        /// Note that we use block header time to time-out pending inbound payments (with some margin