BTC testnet not connecting on local development

I am following the basic bitcoin canister example here. And i wanted to run testnet network , on my local machine because i didn’t want to run the bitcoin regtest software . But now i am getting this error.

Request ID: 38d7259cee2e9c9f6aad81f264a881d06e284993ed8a0a7e3e027a3e186fda5b
Reject code: 5
Reject text: Canister bkyz2-fmaaa-aaaaa-qaaaq-cai trapped explicitly: Panicked at 'called `Result::unwrap()` on an `Err` value: (DestinationInvalid, "Canister g4xu7-jiaaa-aaaan-aaaaq-cai not found")', src/bridge_bitcoin/bitcoin_api.rs:32:17``

Here’s a few resources to try poking it:

I think the key line is dfx_start "--bitcoin-node" "127.0.0.1:18444" which you have to adapt to your own setup

I am getting the same error trying basic_bitcoin, is there a current fix to this?

@Severin

You also get (DestinationInvalid, "Canister g4xu7-jiaaa-aaaan-aaaaq-cai not found")? How are you starting your replica? It doesn’t install the BTC canister by default

I did a trial and error until it finally worked,

I was working with the Rust basic_bitcoin, and when I did dfx start --clean --background it wasn’t creating and installing the bitcoin integration canister.

But the motoko one did the process well like this:

} Creating canister: g4xu7-jiaaa-aaaan-aaaaq-cai (bitcoin integration) Installing canister: bitcoin integration 2024-11-07 09:09:03.201384790 UTC: [Canister g4xu7-jiaaa-aaaan-aaaaq-cai] Starting heartbeat... 2024-11-07 09:09:03.201384790 UTC: [Canister g4xu7-jiaaa-aaaan-aaaaq-cai] Running ingest_block_continue...

I’m still trying to understand why the rust basic example is not doing the same but the motoko one is, the dfx.json are both similar.

For Rust.

{
  "version": 1,
  "canisters": {
    "basic_bitcoin": {
      "type": "custom",
      "package": "basic_bitcoin",
      "candid": "src/basic_bitcoin/basic_bitcoin.did",
      "wasm": "target/wasm32-unknown-unknown/release/basic_bitcoin.wasm",
      "build": "src/basic_bitcoin/build.sh",
      "metadata": [
        {
          "name": "candid:service"
        }
      ]
    }
  },
  "defaults": {
    "bitcoin": {
      "enabled": true,
      "nodes": [
        "127.0.0.1:18444"
      ],
      "log_level": "info"
    },
    "build": {
      "packtool": "",
      "args": ""
    }
  }
}

For motoko:

{
  "version": 1,
  "canisters": {
    "basic_bitcoin": {
      "main": "src/basic_bitcoin/src/Main.mo"
    }
  },
  "defaults": {
    "bitcoin": {
      "enabled": true,
      "nodes": [
        "127.0.0.1:18444"
      ],
      "log_level": "info"
    },
    "build": {
      "packtool": "mops sources",
      "args": ""
    }
  },
  "networks": {
    "local": {
      "bind": "127.0.0.1:4943"
    }
  }
}

It’s because of dfx nonsense. If you don’t specify the local network in dfx.json then the configuration in defaults will not apply. If you copy this section over to your Rust project dfx.json then it should work:

  "networks": {
    "local": {
      "bind": "127.0.0.1:4943"
    }
  }

The example dfx.json was updated last month to include the networks section. You probably cloned it earlier than that

2 Likes

Okay I see, it’s working now! thank you!