From: Steve Myers Date: Mon, 4 Sep 2023 05:25:38 +0000 (-0500) Subject: fix(esplora): use saturating_add in update_tx_graph() X-Git-Tag: v1.0.0-alpha.2~11^2~3 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.EncoderStringWriter.html?a=commitdiff_plain;h=6a5c9d7a00bfddbdf6bd279d003fefe3958dccc1;p=bdk fix(esplora): use saturating_add in update_tx_graph() This fixes overflow error when calling update_tx_graph() from update_tx_graph_without_keychain(). --- diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index 98c47253..279c8e96 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -261,7 +261,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { } } - if last_index > last_active_index.map(|i| i + stop_gap as u32) { + if last_index > last_active_index.map(|i| i.saturating_add(stop_gap as u32)) { break; } } diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 5220cf07..17c364ca 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -252,7 +252,7 @@ impl EsploraExt for esplora_client::BlockingClient { } } - if last_index > last_active_index.map(|i| i + stop_gap as u32) { + if last_index > last_active_index.map(|i| i.saturating_add(stop_gap as u32)) { break; } }