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
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab

[*.{yml,yaml,json}]
indent_style = space
indent_size = 2
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Bug report
description: Report a reproducible defect in libtxms
body:
- type: textarea
id: environment
attributes:
label: Environment
description: Commit, OS, compiler, dependency versions, and build options.
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Reproduction
description: Minimal synthetic input and commands. Remove credentials and private transaction data.
validations:
required: true
- type: textarea
id: result
attributes:
label: Expected and actual results
validations:
required: true
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Feature request
description: Propose a specific improvement
body:
- type: textarea
id: usecase
attributes:
label: Use case and expected behavior
validations:
required: true
- type: textarea
id: compatibility
attributes:
label: Protocol evidence and compatibility considerations
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Change

Describe the concrete problem and resulting behavior.

## Validation

Commands run, results, and any remaining limitations.
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: C library CI
on:
push:
branches: ["**"]
pull_request:
workflow_dispatch:
workflow_call:
permissions:
contents: read
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: cmake -S . -B build -DTXMS_SANITIZE=ON -DCMAKE_C_COMPILER=clang
- run: cmake --build build -j2
- run: ctest --test-dir build --output-on-failure
- uses: actions/setup-node@v4
with:
node-version: '24.2.0'
- uses: actions/checkout@v4
with:
repository: bchainhub/txms.js
ref: 53de2be00f10a9439781f90d6a92db418ef2fdef
path: reference-js
- run: npm install && npm test
working-directory: reference-js
- run: node tests/compatibility.mjs build/txms_oracle "$PWD/reference-js/dist/index.js"
flutter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: bchainhub/flutter_txms
ref: 3a593f0c3021007ee21b74932d2d640bc6fff2a3
path: reference-dart
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- run: cmake -S . -B build && cmake --build build -j2
- run: flutter test
working-directory: reference-dart
- run: python3 tests/flutter_compatibility.py build/txms_oracle reference-dart
fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cmake -S . -B build -DCMAKE_C_COMPILER=clang -DTXMS_SANITIZE=ON -DTXMS_FUZZ=ON
- run: cmake --build build -j2
- run: build/txms_fuzz tests/corpus -runs=20000 -max_len=2048
conan:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
shared: ['False', 'True']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install 'conan>=2.12,<3'
- run: conan profile detect --force
- run: conan create . --build=missing --no-remote -o "libtxms/*:shared=${{ matrix.shared }}"
release-tooling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install pyyaml
- run: python tests/test_release.py
59 changes: 59 additions & 0 deletions .github/workflows/conan-center.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Submit libtxms to ConanCenter
on:
workflow_call:
inputs:
tag:
required: true
type: string
secrets:
CONAN_CENTER_TOKEN:
required: true
workflow_dispatch:
inputs:
tag:
description: Published stable release tag, for example 0.1.0
required: true
type: string
permissions:
contents: read
concurrency:
group: conan-center-libtxms
cancel-in-progress: false
jobs:
submit:
if: vars.CONAN_CENTER_FORK != ''
runs-on: ubuntu-latest
env:
TAG: ${{ inputs.tag }}
FORK: ${{ vars.CONAN_CENTER_FORK }}
steps:
- name: Validate release tag
shell: bash
run: '[[ "$TAG" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]'
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install 'conan>=2.12,<3'
- run: conan profile detect --force
- name: Download and verify published sources
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
gh release view "$TAG" --json isDraft,isPrerelease --jq 'if .isDraft or .isPrerelease then error("A stable published release is required") else true end'
gh release download "$TAG" --dir dist --pattern "libtxms-${TAG}.tar.gz" --pattern SHA256SUMS --pattern release.json
python tools/verify_release.py --tag "$TAG" --directory dist
- name: Prepare and test recipe
run: |
version="${TAG}"
python tools/prepare_conan_center.py --version "$version" --archive "dist/libtxms-$version.tar.gz"
python tools/check_conan_center.py --version "$version" --archive "dist/libtxms-$version.tar.gz" --recipe release-stage/recipes/libtxms/all
- name: Open or update ConanCenter pull request
env:
GH_TOKEN: ${{ secrets.CONAN_CENTER_TOKEN }}
run: python tools/submit_conan_center.py --fork "$FORK" --version "${TAG}" --stage release-stage
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release
on:
release:
types: [published]
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
tests:
if: ${{ !github.event.release.prerelease }}
uses: ./.github/workflows/ci.yml
assets:
needs: tests
runs-on: ubuntu-latest
env:
TAG: ${{ github.event.release.tag_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install 'conan>=2.12,<3'
- run: conan profile detect --force
- name: Verify version and archive the tested commit
run: python tools/release.py --project libtxms --tag "$TAG"
- name: Prepare and test the ConanCenter download recipe
run: |
version="${TAG}"
python tools/prepare_conan_center.py --version "$version" --archive "dist/libtxms-$version.tar.gz"
python tools/check_conan_center.py --version "$version" --archive "dist/libtxms-$version.tar.gz" --recipe release-stage/recipes/libtxms/all
tar -czf "dist/libtxms-$version-conan-center.tar.gz" -C release-stage LICENSE recipes
- name: Checksum all release assets
run: |
cd dist
sha256sum -- *.tar.gz release.json > SHA256SUMS
- uses: actions/upload-artifact@v4
with:
name: release-assets
path: dist/*
if-no-files-found: error
publish:
needs: [tests, assets]
runs-on: ubuntu-latest
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.event.release.tag_name }}
steps:
- uses: actions/download-artifact@v4
with:
name: release-assets
path: dist
- name: Verify downloaded assets
run: cd dist && sha256sum --check SHA256SUMS
- name: Attach tested assets to the published release
run: gh release upload "$TAG" dist/*
conan-center:
needs: publish
if: vars.CONAN_CENTER_FORK != ''
uses: ./.github/workflows/conan-center.yml
with:
tag: ${{ github.event.release.tag_name }}
secrets:
CONAN_CENTER_TOKEN: ${{ secrets.CONAN_CENTER_TOKEN }}
51 changes: 51 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Build, package and compiler output
/build*/
/out/
/dist/
/release-stage/
CMakeUserPresets.json
CMakeCache.txt
CMakeFiles/
compile_commands.json
*.o
*.obj
*.a
*.so
*.so.*
*.dylib
*.dll
*.lib
*.exe
*.pdb
*.gcda
*.gcno
*.profraw
*.profdata

# Local Conan state; no dependency lock is needed by the current recipes
/conan.lock
/.conan2/
/test_package/build*/
/test_package/CMakeUserPresets.json

# Tool environments and reference checkouts
/.venv/
/reference-js/
/reference-dart/
node_modules/
__pycache__/
*.py[cod]
.pytest_cache/
.DS_Store
*.swp
*.swo

# Local configuration, storage and fuzz findings
.env
.env.*
!.env.example
*.sqlite3*
*.db*
crash-*
leak-*
timeout-*
50 changes: 50 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.16)
project(txms VERSION 0.1.0 LANGUAGES C)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(CTest)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Build position independent code")
option(TXMS_SANITIZE "Address and undefined behavior sanitizers" OFF)
option(TXMS_FUZZ "Build libFuzzer target (Clang)" OFF)
add_library(txms src/txms.c src/txms_hex.c src/txms_utf16.c src/txms_encode.c src/txms_decode.c)
target_include_directories(txms PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_compile_features(txms PUBLIC c_std_11)
if(MSVC)
target_compile_options(txms PRIVATE /W4 /WX /utf-8)
set_target_properties(txms PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
target_compile_options(txms PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
set_target_properties(txms PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 0)
if(TXMS_SANITIZE)
target_compile_options(txms PUBLIC -fsanitize=address,undefined -fno-omit-frame-pointer)
target_link_options(txms PUBLIC -fsanitize=address,undefined)
endif()
if(BUILD_TESTING)
add_executable(txms_test tests/test.c)
target_link_libraries(txms_test PRIVATE txms)
if(MSVC)
target_compile_options(txms_test PRIVATE /W4 /WX /utf-8 /UNDEBUG)
else()
target_compile_options(txms_test PRIVATE -Wall -Wextra -Wpedantic -Werror -UNDEBUG)
endif()
add_test(NAME txms_unit COMMAND txms_test)
add_executable(txms_oracle tests/oracle.c)
target_link_libraries(txms_oracle PRIVATE txms)
endif()
if(TXMS_FUZZ)
target_compile_options(txms PRIVATE -fsanitize=fuzzer-no-link,address,undefined)
add_executable(txms_fuzz tests/fuzz.c)
target_link_libraries(txms_fuzz PRIVATE txms)
target_compile_options(txms_fuzz PRIVATE -fsanitize=fuzzer,address,undefined)
target_link_options(txms_fuzz PRIVATE -fsanitize=fuzzer,address,undefined)
endif()
install(TARGETS txms EXPORT txmsTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES include/txms.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT txmsTargets NAMESPACE txms:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/txms)
file(RELATIVE_PATH TXMS_PC_PREFIX_RELATIVE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}")
configure_file(cmake/txms.pc.in txms.pc @ONLY)
configure_package_config_file(cmake/txmsConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/txmsConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/txms)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/txmsConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/txmsConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/txmsConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/txms)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/txms.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CORE License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

All distribution of the Covered Software in Source Code Form, including any
Modifications and/or Contributions must be disclosed and publicly available.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY CLAIM, DAMAGES OR
OTHER LIABILITIES, WHETHER IN AN ACTION OF A CONTRACT, TORT, OR OTHERWISE,
ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE, OR
OTHER DEALINGS IN THE SOFTWARE.
Loading
Loading