Skip to content

Conversation

@Fletch153
Copy link
Collaborator

@Fletch153 Fletch153 commented Dec 10, 2025

Closes #DS-990

Description

Adds a new CBTC Bitcoin Proof of Reserves adapter that queries Bitcoin blockchain UTXOs directly to verify BTC reserves across configured vault addresses.

Changes

  • Add new @chainlink/dlc-cbtc-btc-por-adapter package
  • Implement Bitcoin UTXO querying via Electrs-compatible API
  • Add confirmation threshold check (configurable, default 6 blocks)
  • Implement iBTC-style pending withdrawal handling to prevent temporary reserve dips during unconfirmed spends
  • Add unit tests for reserve calculation logic
  • Add integration tests with mocked Bitcoin API responses

Steps to Test

  1. Build the adapter:

    cd packages/sources/dlc-cbtc-btc-por && yarn build
  2. Run unit tests:

    yarn jest packages/sources/dlc-cbtc-btc-por/test/unit/reserves.test.ts --no-coverage
  3. Start the adapter locally:

    BITCOIN_RPC_ENDPOINT="https://mainnet.dlc.link/electrs" \
    VAULT_ADDRESSES="bc1pckcdqraqg7gy83w4ddvvc3hks8wvcjvldw2kchlvyre5v9fw37jqse4kn0,bc1p90eyryydrg2w3pswwp0qa2p9elgp09jte34ykxqn0uk6g7dnzqks9n3342" \
    EA_PORT=8080 \
    yarn start
  4. Query the reserves endpoint:

    curl -X POST http://localhost:8080 -H "Content-Type: application/json" -d '{"endpoint": "reserves"}'
  5. Verify the response returns total reserves in satoshis:

    {
      "result": 301089400,
      "data": { "result": 301089400 },
      "statusCode": 200
    }

Quality Assurance

  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant infra-k8s configuration file.

  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant adapter-secrets configuration file.

  • If a new adapter was made, or a new endpoint was added, update the test-payload.json file with relevant requests.

  • The branch naming follows git flow (feature/x, chore/x, release/x, hotfix/x, fix/x) or is created from Jira.

  • This is related to a maximum of one Jira story or GitHub issue.

  • Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).

  • All code changes have 100% unit and integration test coverage. If testing is not applicable or too difficult to justify doing, the reasoning should be documented explicitly in the PR.

@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2025

🦋 Changeset detected

Latest commit: 9f1120e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@chainlink/dlc-cbtc-btc-por-adapter Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant