Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 21 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
ubuntu:
name: Build and Test on Ubuntu
name: Build, Test, and Lint on Ubuntu
runs-on: ubuntu-latest

steps:
Expand All @@ -31,6 +31,11 @@ jobs:
- name: Run tests
run: make test

- name: Run linter
uses: golangci/golangci-lint-action@v9
with:
version: v2.6.1

macos:
name: Build and Test on macOS
runs-on: macos-latest
Expand Down Expand Up @@ -59,31 +64,30 @@ jobs:
windows:
name: Build and Test on Windows
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}

steps:
- uses: actions/checkout@v4

- name: Set up MSYS2 with MinGW
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
path-type: inherit
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-boost
make

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.3'

- name: Install Boost library
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg install boost-multi-index:x64-windows boost-headers:x64-windows

- name: Set environment variables
run: |
echo "BOOST_ROOT=$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "BOOST_INCLUDEDIR=$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows\include" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "$env:GITHUB_WORKSPACE\depend\bitcoin\build\bin\RelWithDebInfo" | Out-File -FilePath $env:GITHUB_PATH -Append

- name: Install make
run: choco install make

- name: Build Kernel
run: make build-kernel

Expand All @@ -92,20 +96,3 @@ jobs:

- name: Run tests
run: make test

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.3'

- name: Run linter
uses: golangci/golangci-lint-action@v9
with:
version: v2.6.1
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build-kernel:
cd depend/bitcoin && \
cmake -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_KERNEL_LIB=ON \
-DBUILD_KERNEL_TEST=OFF \
-DBUILD_TESTS=OFF \
Expand All @@ -21,8 +21,11 @@ build-kernel:
-DBUILD_DAEMON=OFF \
-DBUILD_UTIL_CHAINSTATE=OFF \
-DBUILD_CLI=OFF \
-DENABLE_IPC=OFF && \
cmake --build build --config RelWithDebInfo --parallel$(if $(NUM_JOBS),=$(NUM_JOBS)) # Use NUM_JOBS variable if set (e.g., make build-kernel NUM_JOBS=8), otherwise auto-detect CPU cores
-DENABLE_IPC=OFF \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=$$PWD/install && \
cmake --build build --config RelWithDebInfo --parallel$(if $(NUM_JOBS),=$(NUM_JOBS)) && \
cmake --install build --config RelWithDebInfo

build:
go build ./...
Expand All @@ -32,6 +35,7 @@ test:

clean:
rm -rf depend/bitcoin/build
rm -rf depend/bitcoin/install
go clean ./...
go clean -testcache

Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ cd go-bitcoinkernel
make build-kernel
```

This command will configure Bitcoin Core's CMake build system and build only the `libbitcoinkernel` shared library. Refer to Bitcoin Core's build documentation to for the minimum requirements to compile `libbitcoinkernel` from source:
This command will configure Bitcoin Core's CMake build system and statically compile the `libbitcoinkernel` library. Building requires CMake, a C++ compiler, Boost library, and Make. For platform-specific setup instructions, consult Bitcoin Core's build documentation:
([Unix](./depend/bitcoin/doc/build-unix.md),
[macOS](./depend/bitcoin/doc/build-osx.md),
[Windows](./depend/bitcoin/doc/build-windows.md))

**Addtional note for Windows:** MinGW toolchain is required. CGo uses GCC on Windows, so static linking requires the library to be compiled with GCC/MinGW rather than MSVC for ABI compatibility.

### Step 3: Run Tests

```bash
Expand Down Expand Up @@ -92,8 +94,4 @@ call `Destroy()` methods when you're done with owned objects to free resources i

### Error Handling

The library uses structured error types for better error handling (see [errors.go](./kernel/errors.go)).

### Runtime Dependencies

Your Go application will have a runtime dependency on the shared `libbitcoinkernel` library produced by `make build-kernel` in `/path/to/go-bitcoinkernel/depend/bitcoin/build`. Do not delete or move these built library files as your application needs them to run.
The library uses structured error types for better error handling (see [errors.go](./kernel/errors.go)).
2 changes: 1 addition & 1 deletion kernel/block.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/block_hash.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/block_spent_outputs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/block_tree_entry.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"

Expand Down
2 changes: 1 addition & 1 deletion kernel/block_validation_state.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"

Expand Down
5 changes: 3 additions & 2 deletions kernel/cgo_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
package kernel

/*
#cgo CFLAGS: -I../depend/bitcoin/src
#cgo LDFLAGS: -L../depend/bitcoin/build/lib -lbitcoinkernel -Wl,-rpath,${SRCDIR}/../depend/bitcoin/build/lib
#cgo CFLAGS: -I../depend/bitcoin/install/include -DBITCOINKERNEL_STATIC
#cgo darwin LDFLAGS: -L../depend/bitcoin/install/lib -lbitcoinkernel -lc++
#cgo !darwin LDFLAGS: -L../depend/bitcoin/install/lib -lbitcoinkernel -lstdc++ -lm
*/
import "C"
4 changes: 2 additions & 2 deletions kernel/cgo_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package kernel

/*
#cgo CFLAGS: -I../depend/bitcoin/src
#cgo LDFLAGS: -L../depend/bitcoin/build/bin/RelWithDebInfo -lbitcoinkernel -lbcrypt -lshell32
#cgo CFLAGS: -I../depend/bitcoin/install/include -DBITCOINKERNEL_STATIC
#cgo LDFLAGS: -L../depend/bitcoin/install/lib -lbitcoinkernel -lstdc++ -lbcrypt -lshell32
*/
import "C"
2 changes: 1 addition & 1 deletion kernel/chain.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"

Expand Down
2 changes: 1 addition & 1 deletion kernel/chain_parameters.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/chainstate_manager.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
#include <stdlib.h>
*/
import "C"
Expand Down
2 changes: 1 addition & 1 deletion kernel/chainstate_manager_options.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
#include <stdlib.h>
*/
import "C"
Expand Down
2 changes: 1 addition & 1 deletion kernel/coin.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/context_options.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
#include <stdlib.h>
#include <stdint.h>

Expand Down
2 changes: 1 addition & 1 deletion kernel/logging_connection.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
#include <stdlib.h>
#include <stdint.h>

Expand Down
2 changes: 1 addition & 1 deletion kernel/notification_callbacks.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/script_pubkey.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/transaction.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/transaction_input.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/transaction_out_point.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/transaction_output.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/transaction_spent_outputs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/txid.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/validation_interface_callbacks.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
*/
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion kernel/writer_helper.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kernel

/*
#include "kernel/bitcoinkernel.h"
#include "bitcoinkernel.h"
#include <stdlib.h>
#include <string.h>

Expand Down
Loading