Skip to content

Commit

Permalink
Slight refactoring of contains_a
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Apr 18, 2023
1 parent 4e0ffda commit 979a5f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bitcoin_client_rs/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 979a5f4

Please sign in to comment.