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

feat: call bitcoin canisters #569

Merged
merged 14 commits into from
Mar 5, 2025
Merged

feat: call bitcoin canisters #569

merged 14 commits into from
Mar 5, 2025

Conversation

lwshang
Copy link
Contributor

@lwshang lwshang commented Mar 5, 2025

Description

The Bitcoin API has been migrated from management canister to calling the Bitcoin Canisters directly.
This PR implements the types and functions in bitcoin_canister.rs module.

This module follows a similar approach in the management_canister.rs module. Please note:

  • The types are defined in this module which is translated consistently from the spec. I chose not to depend on the ic-btc-interface crate because it contains some implementation specific details that harm the user experiences. E.g. the NetworkInRequest type would make users confused.
  • The *_query methods are not included because they cannot be called in replicated mode (inter-canister calls).
  • The *_config methods are not included because they are for the maintainers of the Bitcoin Canisters
  • The API fee (cycle cost) are hardcoded because they are unlikely to change.

How Has This Been Tested?

Added:

  • e2e bitcoin_canister.rs
  • candid equiality test

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@lwshang lwshang requested a review from THLO March 5, 2025 02:27
disable_api_if_not_fully_synced = variant { enabled };
},
)"#;
test_one_network(Network::Mainnet, mainnet_id, mainnet_init_args);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Why not simply call it test_network?

}

fn test_one_network(network: Network, btc_id: Principal, init_args: &str) {
// The Bitcoin Canisters can still function without connecting to a `bitcoind` node.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The Bitcoin Canisters can still function without connecting to a `bitcoind` node.
// The Bitcoin canisters can still function without connecting to a `bitcoind` node.

@@ -8,3 +8,340 @@
//! [2]: https://github.com/dfinity/bitcoin-canister/blob/master/INTERFACE_SPECIFICATION.md

// TODO: Implementation of the Bitcoin Canister API
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still needed?

@lwshang lwshang marked this pull request as ready for review March 5, 2025 14:12
@lwshang lwshang requested a review from a team as a code owner March 5, 2025 14:12
@lwshang lwshang merged commit 4a1fe68 into next Mar 5, 2025
11 checks passed
@lwshang lwshang deleted the lwshang/SDK-1970-bitcoin branch March 5, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants