Help! ckBTC minting not working local

Afternoon guys,

I’m stumped. I’m trying to get the ckBTC minter working locally. I’ve got a Bitcoin node spun up, all the correct canisters installed (thanks to the OISY repo for pointers here) and I think the config correct, but something must be off and I can’t figure this out.

My test script generates a new BTC deposit address, transfers BTC, and it the transfers show up as ‘Checked’ when I call update_balance on the ckBTC minter… but nothing is being minted in the ckBTC ledger - the balance is not changing.

Am I missing something simple here? Any ideas very highly appreciated!!

Many thanks in advance!
Dave

Minter init_args

(variant {
  Init = record {
    btc_network = variant { Regtest };
    ledger_id = principal "mc6ru-gyaaa-aaaar-qaaaq-cai";
    ecdsa_key_name = "dfx_test_key";
    retrieve_btc_min_amount = 10_000;
    max_time_in_queue_nanos = 420_000_000_000;
    min_confirmations = opt 1;
    mode = variant { GeneralAvailability };
    kyt_fee = opt 1_333;
    kyt_principal = opt principal "pvm5g-xaaaa-aaaar-qaaia-cai";
  }
})

Ledger init_args

(variant {
  Init = record {
    token_symbol = "ckBTC";
    token_name = "Chain key local Bitcoin";
    minting_account = record { owner = principal "ml52i-qqaaa-aaaar-qaaba-cai" };
    transfer_fee = 11_500;
    metadata = vec {};
    initial_balances = vec {record { record { owner = principal "3pkpi-fby6r-fbtp5-6lch6-jiszp-6ne6p-ameal-mfml2-4itpa-2h3r2-7ae"; }; 100_000_000_000; }; };
    archive_options = record {
      num_blocks_to_archive = 10_000;
      trigger_threshold = 20_000;
      controller_id = principal "3pkpi-fby6r-fbtp5-6lch6-jiszp-6ne6p-ameal-mfml2-4itpa-2h3r2-7ae";
      cycles_for_archive_creation = opt 1_000_000_000_000;
      max_message_size_bytes = null;
      node_max_memory_size_bytes = opt 3_221_225_472;
    };
    feature_flags  = opt record { icrc2 = true };
  }
})

dfx.json

{
  "canisters": {
    "icp-ledger": {
      "type": "custom",
      "candid": "https://raw.githubusercontent.com/dfinity/ic/aba60ffbc46acfc8990bf4d5685c1360bd7026b9/rs/ledger_suite/icp/ledger.did",
      "wasm": "https://download.dfinity.systems/ic/aba60ffbc46acfc8990bf4d5685c1360bd7026b9/canisters/ledger-canister.wasm.gz",
      "specified_id": "ryjl3-tyaaa-aaaaa-aaaba-cai",
      "init_arg_file": "ic/icp-ledger-init-args.did"
    },
    "icp-index": {
      "type": "custom",
      "candid": "ic/icp-index.did",
      "wasm": "ic/icp-index.wasm.gz",
      "specified_id": "qhbym-qaaaa-aaaaa-aaafq-cai",
      "init_arg_file": "ic/icp-index-init-args.did"
    },
    "ckbtc-minter": {
      "type": "custom",
      "candid": "ic/ckbtc-minter.did",
      "wasm": "ic/ckbtc-minter.wasm.gz",
      "specified_id": "ml52i-qqaaa-aaaar-qaaba-cai",
      "init_arg_file": "ic/ckbtc-minter-init-args.did"
    },
    "ckbtc-ledger": {
      "type": "custom",
      "candid": "ic/ckbtc-ledger.did",
      "wasm": "ic/ckbtc-ledger.wasm.gz",
      "specified_id": "mc6ru-gyaaa-aaaar-qaaaq-cai",
      "init_arg_file": "ic/ckbtc-ledger-init-args.did"
    },
    "ckbtc-index": {
      "type": "custom",
      "candid": "ic/ckbtc-index.did",
      "wasm": "ic/ckbtc-index.wasm.gz",
      "specified_id": "mm444-5iaaa-aaaar-qaabq-cai",
      "init_arg_file": "ic/ckbtc-index-init-args.did"
    },
    "ckbtc-kyt": {
      "type": "custom",
      "candid": "ic/ckbtc-kyt.did",
      "wasm": "ic/ckbtc-kyt.wasm.gz",
      "specified_id": "pvm5g-xaaaa-aaaar-qaaia-cai",
      "init_arg_file": "ic/ckbtc-kyt-init-args.did"
    },
    "cketh-minter": {
      "type": "custom",
      "candid": "ic/cketh-minter.did",
      "wasm": "ic/cketh-minter.wasm.gz",
      "specified_id": "jzenf-aiaaa-aaaar-qaa7q-cai",
      "init_arg_file": "ic/cketh-minter-init-args.did"
    },
    "cketh-ledger": {
      "type": "custom",
      "candid": "ic/cketh-ledger.did",
      "wasm": "ic/cketh-ledger.wasm.gz",
      "specified_id": "apia6-jaaaa-aaaar-qabma-cai",
      "init_arg_file": "ic/cketh-ledger-init-args.did"
    },
    "cketh-index": {
      "type": "custom",
      "candid": "ic/cketh-index.did",
      "wasm": "ic/cketh-index.wasm.gz",
      "specified_id": "sh5u2-cqaaa-aaaar-qacna-cai",
      "init_arg_file": "ic/cketh-index-init-args.did"
    }
  }
}

Test script

#!/bin/bash

dfx deploy
dfx canister call ckbtc-kyt set_api_key '(record { api_key = "" })'

BTC_CONF=$(pwd)/bitcoin-core/bitcoin.conf
WALLET="daemoney"
PRINCIPAL="3pkpi-fby6r-fbtp5-6lch6-jiszp-6ne6p-ameal-mfml2-4itpa-2h3r2-7ae"
TRANSFER_AMOUNT=7

BTC_MINING_ADDRESS=$(bitcoin-cli -conf=$BTC_CONF -rpcwallet="$WALLET" getnewaddress)
echo "BTC mining address: $BTC_MINING_ADDRESS"

BTC_DEPOSIT_ADDRESS=$(dfx canister call ckbtc-minter get_btc_address "(record { owner = opt principal \"${PRINCIPAL}\"; subaccount=null })"| sed -E 's/^\("([^"]+)"\)$/\1/')
echo "BTC deposit address: $BTC_DEPOSIT_ADDRESS"

echo "Sending $AMOUNT BTC TO $BTC_DEPOSIT_ADDRESS"
bitcoin-cli -conf=$BTC_CONF -rpcwallet="$WALLET" sendtoaddress "${BTC_DEPOSIT_ADDRESS}" "${TRANSFER_AMOUNT}"

echo "Mining 20 blocks"
bitcoin-cli -conf=$BTC_CONF generatetoaddress 20 ${BTC_MINING_ADDRESS}

echo "Waiting for canister sync"
sleep 10

echo "This should be minting $TRANSFER_AMOUNT ckBTC..."
dfx canister call ckbtc-minter update_balance "(record { owner = opt principal \"${PRINCIPAL}\"; subaccount=null})"

echo "...but the balance does not change"
dfx canister call ckbtc-ledger icrc1_balance_of "(record { owner = principal \"${PRINCIPAL}\"; subaccount=null})"
1 Like

Here’s the output from my script:

Deploying all canisters.
ckbtc-index canister created with canister id: mm444-5iaaa-aaaar-qaabq-cai
ckbtc-kyt canister created with canister id: pvm5g-xaaaa-aaaar-qaaia-cai
ckbtc-ledger canister created with canister id: mc6ru-gyaaa-aaaar-qaaaq-cai
ckbtc-minter canister created with canister id: ml52i-qqaaa-aaaar-qaaba-cai
cketh-index canister created with canister id: sh5u2-cqaaa-aaaar-qacna-cai
cketh-ledger canister created with canister id: apia6-jaaaa-aaaar-qabma-cai
cketh-minter canister created with canister id: jzenf-aiaaa-aaaar-qaa7q-cai
icp-index canister created with canister id: qhbym-qaaaa-aaaaa-aaafq-cai
icp-ledger canister created with canister id: ryjl3-tyaaa-aaaaa-aaaba-cai
Installed code for canister ckbtc-index, with canister ID mm444-5iaaa-aaaar-qaabq-cai
Installed code for canister ckbtc-kyt, with canister ID pvm5g-xaaaa-aaaar-qaaia-cai
Installed code for canister ckbtc-ledger, with canister ID mc6ru-gyaaa-aaaar-qaaaq-cai
Installed code for canister ckbtc-minter, with canister ID ml52i-qqaaa-aaaar-qaaba-cai
Installed code for canister cketh-index, with canister ID sh5u2-cqaaa-aaaar-qacna-cai
Installed code for canister cketh-ledger, with canister ID apia6-jaaaa-aaaar-qabma-cai
Installed code for canister cketh-minter, with canister ID jzenf-aiaaa-aaaar-qaa7q-cai
Installed code for canister icp-index, with canister ID qhbym-qaaaa-aaaaa-aaafq-cai
Installed code for canister icp-ledger, with canister ID ryjl3-tyaaa-aaaaa-aaaba-cai
Deployed canisters.
URLs:
  Backend canister via Candid interface:
    ckbtc-index: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=mm444-5iaaa-aaaar-qaabq-cai
    ckbtc-kyt: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=pvm5g-xaaaa-aaaar-qaaia-cai
    ckbtc-ledger: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=mc6ru-gyaaa-aaaar-qaaaq-cai
    ckbtc-minter: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=ml52i-qqaaa-aaaar-qaaba-cai
    cketh-index: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=sh5u2-cqaaa-aaaar-qacna-cai
    cketh-ledger: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=apia6-jaaaa-aaaar-qabma-cai
    cketh-minter: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=jzenf-aiaaa-aaaar-qaa7q-cai
    icp-index: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=qhbym-qaaaa-aaaaa-aaafq-cai
    icp-ledger: http://127.0.0.1:4943/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=ryjl3-tyaaa-aaaaa-aaaba-cai
()
BTC mining address: bcrt1qsq5fvw0tegt0zavd4llpg44ypgzwhplxf54nhx
BTC deposit address: bcrt1qev3sylqm9c4qyghvqya3yns8v9fh0dv6tex2f8
Sending  BTC TO bcrt1qev3sylqm9c4qyghvqya3yns8v9fh0dv6tex2f8
63dfd62eff1a4fe13520f3a027dbf97af35d2de370a9385f4a303a711a274cc7
Mining 20 blocks
[
  "499e6686a69b6784687c7a0abd0070cc129d0b21fe4e85e610403b4161f58231",
  "21844394d71085cee5ced5c2eed607c7eb6a90c440bb59032cd5e7f8a882a4ee",
  "0c6185eda4f6454bb0b11dcd786f3eec4c4beeba15ef15826fb625441cddb649",
  "541f788dbb0aba9d6ddc285ae12377a59f784694776c9713bd18a790a01629b5",
  "377d8a0a4bdc20fb15ddefd4f97fb640b9537f09b522d9bd09c82ec06a32c6f4",
  "4b14fcc57c6dfdadea67cf587533f145c6f2ae870072daff3a2c1e7017842a64",
  "657966e13d73986771b47cde40022771117790880df0393711ff96b3e1f0bf2f",
  "7b499e774172b2e17903fd01cc248ead580e4b87fccb99fb66af12175b650f43",
  "3ba0ff94138c80d4d45c7b11debea6917d2260d7afb008a28a580401060b6054",
  "6acbc495a26ea643f70bdaf17921bd6cc269a177492d480cf7f352d5222dea03",
  "0e357e275a13fa8e954a6551aaeeb0fd154f217e1e98f8ce2b667cddf912be0f",
  "00f7c64fa7389e6aea7aadfbca2e38cae86a976c343d92ed1d8ab24ec4a298c1",
  "5388626757370b3b84d0a0fb8448e670390719ca1e87f720f5d37d5d90c8fb9d",
  "0fc919058c9ec955350841fcbd94cc12685590d2cbff5bd4c3c3b1957921b3c2",
  "2e1c88ce9da0ad4d51a49b65724ab0178d6c3137f5a4ededb963a47c93dffcfe",
  "645ac49e5547bd062f2fed60fe2b42e79e25d5affc4a5ee9f2a9fe883b96c49a",
  "384911ebe21b1875257594d6e89995d8912fdd5d0d39afab11f20eeb74d0bcbd",
  "0d81b412b96d54351a18aae0fa2e30d0d48cd32a811c6dc3120ba26e8b27b146",
  "30e4c867ff7921cc184ced5015415c4b5bcd250ec25f988d4ab38f626c43c8c6",
  "79a1e10b065394f86bcb0f2e06346f529d051472186b84312c4f0d49034acbf5"
]
Waiting for canister sync
This should be minting 7 ckBTC...
(
  variant {
    Ok = vec {
      variant {
        Checked = record {
          height = 364 : nat32;
          value = 700_000_000 : nat64;
          outpoint = record {
            txid = blob "\c7\4c\27\1a\71\3a\30\4a\5f\38\a9\70\e3\2d\5d\f3\7a\f9\db\27\a0\f3\20\35\e1\4f\1a\ff\2e\d6\df\63";
            vout = 1 : nat32;
          };
        }
      };
    }
  },
)
...but the balance does not change
(100_000_000_000 : nat)

In case this helps anyone, I found the solution in this thread.

Add max_memo_length = opt 80 to the ckbtc_ledger init_args and it now works and mints ckBTC as expected.

1 Like