Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FINAL] Adding an endpoint to fetch bitcoin block headers #298

Merged
merged 8 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions spec/_attachments/ic.did
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ type bitcoin_network = variant {

type bitcoin_address = text;

type block_hash = blob;
type bitcoin_block_hash = blob;

type bitcoin_block_header = blob;

type millisatoshi_per_byte = nat64;

type bitcoin_block_height = nat32;

type outpoint = record {
txid : blob;
vout : nat32;
Expand All @@ -104,8 +106,8 @@ type bitcoin_get_utxos_args = record {

type bitcoin_get_utxos_result = record {
utxos : vec utxo;
tip_block_hash : block_hash;
tip_height : nat32;
tip_block_hash : bitcoin_block_hash;
tip_height : bitcoin_block_height;
next_page : opt blob;
};

Expand All @@ -120,8 +122,8 @@ type bitcoin_get_utxos_query_args = record {

type bitcoin_get_utxos_query_result = record {
utxos : vec utxo;
tip_block_hash : block_hash;
tip_height : nat32;
tip_block_hash : bitcoin_block_hash;
tip_height : bitcoin_block_height;
next_page : opt blob;
};

Expand Down Expand Up @@ -153,13 +155,13 @@ type bitcoin_send_transaction_args = record {
};

type bitcoin_get_block_headers_args = record {
THLO marked this conversation as resolved.
Show resolved Hide resolved
start_height : nat32;
end_height : opt nat32;
start_height : bitcoin_block_height;
end_height : opt bitcoin_block_height;
THLO marked this conversation as resolved.
Show resolved Hide resolved
};

type bitcoin_get_block_headers_result = record {
tip_height : nat32;
block_headers : vec bitcoin_block_header;
tip_height : bitcoin_block_height;
block_headers : vec bitcoin_block_header;
ielashi marked this conversation as resolved.
Show resolved Hide resolved
};

type node_metrics = record {
Expand Down
6 changes: 6 additions & 0 deletions spec/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,12 @@ The [standard nearest-rank estimation method](https://en.wikipedia.org/wiki/Perc

### IC method `bitcoin_get_block_headers` {#ic-bitcoin_get_block_headers}
THLO marked this conversation as resolved.
Show resolved Hide resolved

:::note

The node metrics management canister API is considered EXPERIMENTAL. Canister developers must be aware that the API may evolve in a non-backward-compatible way.
THLO marked this conversation as resolved.
Show resolved Hide resolved

:::

Given a start height and an optional end height, the function returns the block headers in the provided range. The range is inclusive, i.e., the block headers at the start and end heights are returned as well.

If no end height is specified, all blocks until the tip height, i.e., the largest available height, are returned. However, if the range from the start height to the end height or the tip height is large, only a prefix of the requested block headers may be returned in order to bound the size of the response.
THLO marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading