Skip to content

Commit

Permalink
feat: add bitcoin composite queries
Browse files Browse the repository at this point in the history
  • Loading branch information
ielashi committed Aug 10, 2023
1 parent 8981100 commit e131edd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/_attachments/ic.did
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ service ic : {

// bitcoin interface
bitcoin_get_balance: (get_balance_request) -> (satoshi);
bitcoin_get_balance_untrusted: (get_balance_request) -> (satoshi) composite_query;
bitcoin_get_utxos: (get_utxos_request) -> (get_utxos_response);
bitcoin_get_utxos_untrusted: (get_utxos_request) -> (get_utxos_response) composite_query;
bitcoin_send_transaction: (send_transaction_request) -> ();
bitcoin_get_current_fee_percentiles: (get_current_fee_percentiles_request) -> (vec millisatoshi_per_byte);

Expand Down
8 changes: 8 additions & 0 deletions spec/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2081,6 +2081,10 @@ A `get_utxos_request` without the optional `filter` results in a request that co

The recommended workflow is to issue a request with the desired number of confirmations. If the `next_page` field in the response is not empty, there are more UTXOs than in the returned vector. In that case, the `page` field should be set to the `next_page` bytes in the subsequent request to obtain the next batch of UTXOs.

### IC method `bitcoin_get_utxos_untrusted` {#ic-bitcoin_get_utxos_untrusted}

This method is identical to [`bitcoin_get_utxos`](#ic-bitcoin_get_utxos). The only difference is that it is exposed as an uncertified query call, and its results can therefore not be trusted.

### IC method `bitcoin_get_balance` {#ic-bitcoin_get_balance}

Given a `get_balance_request`, which must specify a Bitcoin address and a Bitcoin network (`mainnet` or `testnet`), the function returns the current balance of this address in `Satoshi` (10^8 Satoshi = 1 Bitcoin) in the specified Bitcoin network. The same address formats as for [`bitcoin_get_utxos`](#ic-bitcoin_get_utxos) are supported.
Expand All @@ -2091,6 +2095,10 @@ The optional `min_confirmations` parameter can be used to limit the set of consi

Given an address and the optional `min_confirmations` parameter, `bitcoin_get_balance` iterates over all UTXOs, i.e., the same balance is returned as when calling [`bitcoin_get_utxos`](#ic-bitcoin_get_utxos) for the same address and the same number of confirmations and, if necessary, using pagination to get all UTXOs for the same tip hash.

### IC method `bitcoin_get_balance_untrusted` {#ic-bitcoin_get_balance_untrusted}

This method is identical to [`bitcoin_get_balance`](#ic-bitcoin_get_balance). The only difference is that it is exposed as an uncertified query call, and its results can therefore not be trusted.

### IC method `bitcoin_send_transaction` {#ic-bitcoin_send_transaction}

Given a `send_transaction_request`, which must specify a `blob` of a Bitcoin transaction and a Bitcoin network (`mainnet` or `testnet`), several checks are performed:
Expand Down

0 comments on commit e131edd

Please sign in to comment.