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: add getBalance to BTC package #701

Merged
merged 15 commits into from
Aug 26, 2024

Conversation

AntonioVentilii-DFINITY
Copy link
Contributor

Motivation

Expose function getBalance, used to retrieve the balance of a Bitcoin address given a network and, optionally, a minimum number of confirmations.

Changes

  • Create params types (note that the endpoint returns bigint number identified by the type satoshi).
  • Create util function to parse "string" network type to "candid" network type.
  • Expose get_balance from the canister into new function getBalance of object BitcoinCanister.
  • Add tests.

Tests

Create set of test mirroring the ones used for getUtxos function.

@AntonioVentilii-DFINITY AntonioVentilii-DFINITY changed the title Feature/add get balance to btc package feat: add getBalance to BTC package Aug 25, 2024
Copy link
Contributor

github-actions bot commented Aug 25, 2024

size-limit report 📦

Path Size
@dfinity/ckbtc 7.95 KB (+0.55% 🔺)
@dfinity/cketh 3.45 KB (0%)
@dfinity/cmc 1.29 KB (0%)
@dfinity/ledger-icrc 3.89 KB (0%)
@dfinity/ledger-icp 15.23 KB (0%)
@dfinity/nns 36.62 KB (0%)
@dfinity/nns-proto 140.98 KB (0%)
@dfinity/sns 15.92 KB (0%)
@dfinity/utils 4.5 KB (0%)
@dfinity/ic-management 2.92 KB (0%)

packages/ckbtc/src/utils/btc.utils.ts Outdated Show resolved Hide resolved
packages/ckbtc/src/types/bitcoin.params.ts Outdated Show resolved Hide resolved
packages/ckbtc/src/bitcoin.canister.ts Outdated Show resolved Hide resolved
Copy link
Member

@peterpeterparker peterpeterparker left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

Copy link
Member

@peterpeterparker peterpeterparker left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

Copy link
Member

@peterpeterparker peterpeterparker left a comment

Choose a reason for hiding this comment

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

Can you add an entry in CHANGELOG.md before merging please?

@AntonioVentilii-DFINITY
Copy link
Contributor Author

Can you add an entry in CHANGELOG.md before merging please?

WDYT?

Add function `getBalance` to `BitcoinCanister` object of package `@dfinity/ckbtc`, that implements the `bitcoin_get_balance` method of the IC Bitcoin API.

@peterpeterparker
Copy link
Member

Sounds good

@AntonioVentilii-DFINITY AntonioVentilii-DFINITY merged commit b2f76c9 into main Aug 26, 2024
11 checks passed
@AntonioVentilii-DFINITY AntonioVentilii-DFINITY deleted the feature/add-get-balance-to-btc-package branch August 26, 2024 14:26
peterpeterparker added a commit that referenced this pull request Aug 27, 2024
# Motivation

As discussed in #701, let's rename `min_confirmations` parameter of
`getUtxos` in ckBTC library to `minConfirmations`.

# Changes

- Parameter and mapping updated accordingly.

---------

Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
AntonioVentilii-DFINITY added a commit that referenced this pull request Aug 27, 2024
# Motivation

As discussed in #701, let's rename `min_confirmations` parameter of
`getBalance` in ckBTC library to `minConfirmations`.

# Changes

- Parameter and mapping updated accordingly.
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.

3 participants