Skip to content

Commit 64f2dca

Browse files
committed
Merge #285: Take all get_index_info rpc call return values as Option<>
300b3cc Take all get_index_info rpc call return values as Option<> (dev7ba) Pull request description: The values returned by get_index_info are optional depending on whether the values txindex=1, blockfilterindex=1, and coinstatsindex=1 are configured in bitcoin.conf. This causes the library to fail in case any of these indices are not configured. I closed last pull request due to problems with rebase. ACKs for top commit: apoelstra: ACK 300b3cc Tree-SHA512: b027faf3fb2d798eb981f0a52ab8641c4e48d94ba41d39271e83bc4647b74c60fa153e9ba3dc440e3fe781b78ee39089e52b6081bc77f20e97025daebd8f9392
2 parents 4223190 + 300b3cc commit 64f2dca

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

integration_test/src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ fn main() {
215215
test_disconnect_node(&cl);
216216
test_add_ban(&cl);
217217
test_set_network_active(&cl);
218+
test_get_index_info(&cl);
218219
test_stop(cl);
219220
}
220221

@@ -1262,6 +1263,15 @@ fn test_getblocktemplate(cl: &Client) {
12621263
cl.generate_to_address(2, &RANDOM_ADDRESS).unwrap();
12631264
}
12641265

1266+
fn test_get_index_info(cl: &Client) {
1267+
if version() >= 210000 {
1268+
let gii = cl.get_index_info().unwrap();
1269+
assert!(gii.txindex.is_some());
1270+
assert!(gii.coinstatsindex.is_none());
1271+
assert!(gii.basic_block_filter_index.is_some());
1272+
}
1273+
}
1274+
12651275
fn test_stop(cl: Client) {
12661276
println!("Stopping: '{}'", cl.stop().unwrap());
12671277
}

json/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,10 +2125,10 @@ pub struct IndexStatus {
21252125

21262126
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
21272127
pub struct GetIndexInfoResult {
2128-
pub txindex: IndexStatus,
2129-
pub coinstatsindex: IndexStatus,
2128+
pub txindex: Option<IndexStatus>,
2129+
pub coinstatsindex: Option<IndexStatus>,
21302130
#[serde(rename = "basic block filter index")]
2131-
pub basic_block_filter_index: IndexStatus,
2131+
pub basic_block_filter_index: Option<IndexStatus>,
21322132
}
21332133

21342134
impl<'a> serde::Serialize for PubKeyOrAddress<'a> {

0 commit comments

Comments
 (0)