From 979a5f49c8f0e7bca50e5225ee80e453750634b0 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Tue, 18 Apr 2023 16:36:04 +0200 Subject: [PATCH] Slight refactoring of contains_a --- bitcoin_client_rs/src/wallet.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bitcoin_client_rs/src/wallet.rs b/bitcoin_client_rs/src/wallet.rs index 9a8fd0b63..04009d266 100644 --- a/bitcoin_client_rs/src/wallet.rs +++ b/bitcoin_client_rs/src/wallet.rs @@ -252,13 +252,13 @@ impl core::fmt::Display for WalletPubKey { } } -/// Returns true iff `descriptor_template` contains a `a:` fragment +/// Returns true if `descriptor_template` contains an 'a:' fragment pub fn contains_a(descriptor_template: &str) -> bool { - let allowed_chars = ['a', 's', 'c', 't', 'd', 'v', 'j', 'n', 'l', 'u']; // miniscript wrappers + const MINISCRIPT_WRAPPERS: &[char] = &['a', 's', 'c', 't', 'd', 'v', 'j', 'n', 'l', 'u']; let mut sequence = String::new(); - for (i, ch) in descriptor_template.chars().enumerate() { - if allowed_chars.contains(&ch) { + for ch in descriptor_template.chars() { + if MINISCRIPT_WRAPPERS.contains(&ch) { sequence.push(ch); } else { if ch == ':' && sequence.contains('a') {