Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6a40344
chore: migrate motoko/basic_bitcoin to icp-cli
marc0olo Jun 10, 2026
4b26bae
chore: complete basic_bitcoin icp-cli migration with Docker/bitcoind …
marc0olo Jun 11, 2026
e12ef51
fix: correct network-launcher image tag; remove redundant persistent …
marc0olo Jun 11, 2026
63c37b9
fix: correct network-launcher tag (no v prefix)
marc0olo Jun 11, 2026
1cffa4d
chore: use latest tag for network-launcher base image
marc0olo Jun 11, 2026
da1a9d1
fix: install Bitcoin Core from official release with SHA256 verification
marc0olo Jun 11, 2026
3d8c560
fix: run basic_bitcoin CI on host runner, not in container
marc0olo Jun 11, 2026
26147c2
fix: install ic-mops — required by @dfinity/motoko recipe for mops build
marc0olo Jun 11, 2026
fc2d90b
fix: use init_args (plural) at environment level, not init_arg in set…
marc0olo Jun 11, 2026
125409e
fix: use inline actor type for Bitcoin API to support #regtest network
marc0olo Jun 11, 2026
6391a58
refactor: use mo:bitcoin and mo:ic types; reduce custom type definitions
marc0olo Jun 11, 2026
b042c52
refactor: clean up Types.mo — use package types, Blob, accurate naming
marc0olo Jun 11, 2026
619e928
fix: bind bitcoind RPC to 0.0.0.0 so host can reach it via mapped port
marc0olo Jun 11, 2026
2f785e8
fix: use docker exec for bitcoin mining instead of curl over mapped port
marc0olo Jun 11, 2026
dd429a8
fix: rename image to icp-cli-network-launcher-bitcoin; fix test 6 grep
marc0olo Jun 11, 2026
ff7ce57
fix: update image name in icp.yaml
marc0olo Jun 11, 2026
13119ca
feat: add P2WPKH address, get_block_headers; rename mock signers
marc0olo Jun 11, 2026
bf09e6c
feat: add get_blockchain_info; remove P2WPKH (send not yet implementa…
marc0olo Jun 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/basic_bitcoin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: basic_bitcoin

on:
push:
branches: [master]
pull_request:
paths:
- motoko/basic_bitcoin/**
- .github/workflows/basic_bitcoin.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
motoko-basic_bitcoin:
# Run directly on the host (no container:) so that icp-cli can bind-mount
# the status directory into our custom Docker image. When icp-cli runs inside
# a container, the tmpdir it creates is invisible to the host Docker daemon.
runs-on: ubuntu-24.04
env:
ICP_CLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Install icp-cli, ic-wasm and mops
run: npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm ic-mops
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- name: Build network launcher image
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
with:
context: motoko/basic_bitcoin
push: false
load: true
tags: icp-cli-network-launcher-bitcoin:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy and test
working-directory: motoko/basic_bitcoin
run: |
icp network start -d
icp deploy --cycles 30t
make test
20 changes: 0 additions & 20 deletions motoko/basic_bitcoin/.devcontainer/devcontainer.json

This file was deleted.

113 changes: 0 additions & 113 deletions motoko/basic_bitcoin/BUILD.md

This file was deleted.

20 changes: 20 additions & 0 deletions motoko/basic_bitcoin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ghcr.io/dfinity/icp-cli-network-launcher:latest

ARG BITCOIN_VERSION=27.2
ARG BITCOIN_SHA256=acc223af46c178064c132b235392476f66d486453ddbd6bca6f1f8411547da78

RUN apt-get update && apt-get install -y --no-install-recommends curl && \
curl -fsSL "https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz" \
-o /tmp/bitcoin.tar.gz && \
echo "${BITCOIN_SHA256} /tmp/bitcoin.tar.gz" | sha256sum -c && \
tar xzf /tmp/bitcoin.tar.gz --strip-components=2 \
-C /usr/local/bin \
"bitcoin-${BITCOIN_VERSION}/bin/bitcoind" \
"bitcoin-${BITCOIN_VERSION}/bin/bitcoin-cli" && \
rm /tmp/bitcoin.tar.gz && \
apt-get purge -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*

COPY docker/start.sh /app/start.sh
RUN chmod +x /app/start.sh

ENTRYPOINT ["/app/start.sh"]
59 changes: 59 additions & 0 deletions motoko/basic_bitcoin/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
IMAGE_NAME = icp-cli-network-launcher-bitcoin
# Find the running container built from our custom image
BITCOIN_CONTAINER = $(shell docker ps --filter "ancestor=$(IMAGE_NAME)" --format "{{.ID}}" | head -1)

.PHONY: build-image test topup

build-image:
docker build -t $(IMAGE_NAME) .

topup:
icp canister top-up --amount 30t backend

test:
@echo "=== Test 1: get_p2pkh_address returns a valid Bitcoin address ==="
@result=$$(icp canister call backend get_p2pkh_address '()') && \
echo "$$result" && \
echo "$$result" | grep -q '"' && \
echo "PASS" || (echo "FAIL" && exit 1)

@echo "=== Test 2: get_p2tr_key_only_address returns a valid Bitcoin address ==="
@result=$$(icp canister call backend get_p2tr_key_only_address '()') && \
echo "$$result" && \
echo "$$result" | grep -q '"' && \
echo "PASS" || (echo "FAIL" && exit 1)

@echo "=== Test 3: get_p2tr_address returns a valid Bitcoin address ==="
@result=$$(icp canister call backend get_p2tr_address '()') && \
echo "$$result" && \
echo "$$result" | grep -q '"' && \
echo "PASS" || (echo "FAIL" && exit 1)

@echo "=== Test 4: get_current_fee_percentiles returns a vec ==="
@result=$$(icp canister call backend get_current_fee_percentiles '()') && \
echo "$$result" && \
echo "PASS" || (echo "FAIL" && exit 1)

@echo "=== Mining 101 blocks to fund test address ==="
@addr=$$(icp canister call backend get_p2pkh_address '()' | grep -o '"[^"]*"' | tr -d '"') && \
docker exec $(BITCOIN_CONTAINER) bitcoin-cli -regtest \
-rpcuser=ic-btc-integration -rpcpassword=ic-btc-integration \
generatetoaddress 101 "$$addr" > /dev/null && \
echo "mined 101 blocks to $$addr"

@echo "=== Waiting for IC to sync Bitcoin blocks ==="
@sleep 5

@echo "=== Test 5: get_balance returns non-zero after mining ==="
@addr=$$(icp canister call backend get_p2pkh_address '()' | grep -o '"[^"]*"' | tr -d '"') && \
result=$$(icp canister call backend get_balance "(\"$$addr\")") && \
echo "$$result" && \
echo "$$result" | grep -qE '[1-9]' && \
echo "PASS" || (echo "FAIL" && exit 1)

@echo "=== Test 6: get_utxos returns synced chain state after mining ==="
@addr=$$(icp canister call backend get_p2pkh_address '()' | grep -o '"[^"]*"' | tr -d '"') && \
result=$$(icp canister call backend get_utxos "(\"$$addr\")") && \
echo "$$result" && \
echo "$$result" | grep -q 'tip_height = 101' && \
echo "PASS" || (echo "FAIL" && exit 1)
Loading
Loading