Skip to content

Commit fb4907a

Browse files
committed
Rename is_ranged to is_wildcard, to match rust-bitcoin's terminology
1 parent 52e9d3a commit fb4907a

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ You can associate the wallets to their parent xpub using the `bip32_origins` fie
318318

319319
- `desc` - the output script descriptor tracked by this wallet
320320
- `network` - the network this wallet belongs to (`bitcoin`, `testnet` or `regtest`)
321-
- `is_ranged` - a boolean indicating whether the descriptor is ranged
321+
- `is_wildcard` - a boolean indicating whether the descriptor includes wildcard keys (`xpub../*`)
322322
- `bip32_origins` - bip32 origin information for the keys contained in the descriptor
323323
- `gap_limit` - the gap limited configured for this wallet
324324
- `initial_import_size` - the gap limit used during the initial import
@@ -344,28 +344,28 @@ $ curl localhost:3060/wallets
344344
"xjm8w0el": {
345345
"desc": "wpkh(xpub661MyMwAqRbcEhsxS9g2qyYKSGA3seqWVNhmVhU27ddQx952PaZ6G4V26msGKrqYBjoBRwFyzaucPUkhw7DNaeMVUYJV1bqosxzVxToJdcy/0/*)#xjm8w0el",
346346
"network": "bitcoin",
347-
"is_ranged": true,
347+
"is_wildcard": true,
348348
"bip32_origins": [ "80e042a9/0" ],
349349
...
350350
},
351351
"k38panl4": {
352352
"desc": "wsh(multi(2,xpub661MyMwAqRbcEuy9nKLTbGCi2NhqTWeQPT3gd2QdfmeaieDHLHiwTnSnw1GrP2xdaJwEDQJLasfw6LNK7hVADcCN9d1M1RtxitrR3CwvtjV/0/*,[16eabcf7/2]xpub684GUXwH4bY8Pf3fgSunTGz3hwJZhJzaNwgT55aWGWQM7KsiUFEXWLYPy1Q19gAEvc9LG5TN5PdmGPoyocmkkpKCCMV27ugL7XqHeHRwJzH/1/*))#k38panl4",
353353
"network": "bitcoin",
354-
"is_ranged": true,
354+
"is_wildcard": true,
355355
"bip32_origins": [ "367e5b47/0", "16eabcf7/2/1" ],
356356
...
357357
},
358358
"cletf5fc": {
359359
"desc": "pkh(xpub661MyMwAqRbcEoHAdGB6AaGRhLmHVemxe6acQikhJgfV3sr1SmapjQv8ZfBwWa1YKmFbyR6ta96TKiCNTctvZix58hAR7mDtjdWK2E18PjR/0/*)#cletf5fc",
360360
"network": "bitcoin",
361-
"is_ranged": true,
361+
"is_wildcard": true,
362362
"bip32_origins": [ "7a32efaa/0" ],
363363
...
364364
},
365365
"ftu25peq": {
366366
"desc": "pkh(xpub661MyMwAqRbcEoHAdGB6AaGRhLmHVemxe6acQikhJgfV3sr1SmapjQv8ZfBwWa1YKmFbyR6ta96TKiCNTctvZix58hAR7mDtjdWK2E18PjR/1/*)#ftu25peq",
367367
"network": "bitcoin",
368-
"is_ranged": true,
368+
"is_wildcard": true,
369369
"bip32_origins": [ "7a32efaa/1" ],
370370
...
371371
}
@@ -393,7 +393,7 @@ $ curl localhost:3060/wallet/xjm8w0el
393393
{
394394
"desc": "wpkh(xpub661MyMwAqRbcEhsxS9g2qyYKSGA3seqWVNhmVhU27ddQx952PaZ6G4V26msGKrqYBjoBRwFyzaucPUkhw7DNaeMVUYJV1bqosxzVxToJdcy/0/*)#xjm8w0el",
395395
"network": "bitcoin",
396-
"is_ranged": true,
396+
"is_wildcard": true,
397397
"bip32_origins": [ "80e042a9/0" ],
398398
"rescan_policy": "now",
399399
"done_initial_import": true,
@@ -452,7 +452,7 @@ Issues a 307 redirection to the url of the next derivation index (`/wallet/:chec
452452
Note that the returned address is not marked as used until receiving funds; If you wish to skip it and generate a different
453453
address without receiving funds to it, you can specify an explicit derivation index instead.
454454

455-
Non-ranged descriptors always return `0` as the next index.
455+
Non-wildcard descriptors always return `0` as their next index.
456456

457457
Examples:
458458
```

src/util/descriptor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn derive_desc_str(desc: &ExtendedDescriptor, index: u32) -> String {
3737
#[derive(Debug, Clone)]
3838
pub struct DescKeyInfo {
3939
pub bip32_origin: Bip32Origin,
40-
pub is_ranged: bool,
40+
pub is_wildcard: bool,
4141
}
4242

4343
impl From<&ExtendedDescriptor> for Checksum {
@@ -77,7 +77,7 @@ impl DescKeyInfo {
7777

7878
keys_info.push(DescKeyInfo {
7979
bip32_origin,
80-
is_ranged: desc_xpub.is_wildcard,
80+
is_wildcard: desc_xpub.is_wildcard,
8181
});
8282

8383
valid_networks = valid_networks && xpub_matches_network(&desc_xpub.xkey, network);
@@ -86,7 +86,7 @@ impl DescKeyInfo {
8686
if let Some(bip32_origin) = &desc_single.origin {
8787
keys_info.push(DescKeyInfo {
8888
bip32_origin: bip32_origin.into(),
89-
is_ranged: false,
89+
is_wildcard: false,
9090
});
9191
}
9292
}

src/wallet.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl WalletWatcher {
189189
#[derive(Debug, Clone)]
190190
pub struct Wallet {
191191
desc: ExtendedDescriptor,
192-
is_ranged: bool,
192+
is_wildcard: bool,
193193
checksum: Checksum,
194194
keys_info: Vec<DescKeyInfo>,
195195
network: Network,
@@ -218,13 +218,13 @@ impl Wallet {
218218

219219
let checksum = Checksum::from(&desc);
220220
let keys_info = DescKeyInfo::extract(&desc, network)?;
221-
let is_ranged = keys_info.iter().any(|x| x.is_ranged);
221+
let is_wildcard = keys_info.iter().any(|x| x.is_wildcard);
222222

223223
Ok(Self {
224224
desc,
225225
checksum,
226226
keys_info,
227-
is_ranged,
227+
is_wildcard,
228228
network,
229229
gap_limit,
230230
// setting initial_import_size < gap_limit makes no sense, the user probably meant to increase both
@@ -281,7 +281,7 @@ impl Wallet {
281281

282282
/// Returns the maximum index that needs to be watched
283283
fn watch_index(&self) -> u32 {
284-
if !self.is_ranged {
284+
if !self.is_wildcard {
285285
return 0;
286286
}
287287

@@ -326,7 +326,7 @@ impl Wallet {
326326
}
327327

328328
pub fn get_next_index(&self) -> u32 {
329-
if self.is_ranged {
329+
if self.is_wildcard {
330330
self.max_funded_index
331331
.map_or(0, |max_funded_index| max_funded_index + 1)
332332
} else {
@@ -335,7 +335,7 @@ impl Wallet {
335335
}
336336

337337
pub fn is_valid_index(&self, index: u32) -> bool {
338-
if self.is_ranged {
338+
if self.is_wildcard {
339339
// non-hardended derivation only
340340
index & (1 << 31) == 0
341341
} else {
@@ -347,7 +347,7 @@ impl Wallet {
347347
// return None if this wallet has no history at all
348348
let max_funded_index = self.max_funded_index?;
349349

350-
Some(if self.is_ranged {
350+
Some(if self.is_wildcard {
351351
(0..=max_funded_index)
352352
.map(|derivation_index| self.derive_address(derivation_index))
353353
.fold((0, 0), |(curr_gap, max_gap), address| {
@@ -368,7 +368,7 @@ impl Wallet {
368368
self.keys_info
369369
.iter()
370370
.map(|i| {
371-
if i.is_ranged {
371+
if i.is_wildcard {
372372
i.bip32_origin.child(index.into())
373373
} else {
374374
i.bip32_origin.clone()
@@ -485,7 +485,7 @@ impl Serialize for Wallet {
485485

486486
rgb.serialize_field("desc", &desc_str)?;
487487
rgb.serialize_field("network", &self.network)?;
488-
rgb.serialize_field("is_ranged", &self.is_ranged)?;
488+
rgb.serialize_field("is_wildcard", &self.is_wildcard)?;
489489
rgb.serialize_field("bip32_origins", &bip32_origins)?;
490490
rgb.serialize_field("rescan_since", &self.rescan_since)?;
491491
rgb.serialize_field("done_initial_import", &self.done_initial_import)?;
@@ -496,7 +496,7 @@ impl Serialize for Wallet {
496496
&self.desc.max_satisfaction_weight(*DESC_CTX),
497497
)?;
498498

499-
if self.is_ranged {
499+
if self.is_wildcard {
500500
rgb.serialize_field("gap_limit", &self.gap_limit)?;
501501
rgb.serialize_field("initial_import_size", &self.initial_import_size)?;
502502
}

0 commit comments

Comments
 (0)