diff --git a/.gitmodules b/.gitmodules index 8325dbf..b933c63 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "Zano"] - path = Zano +[submodule "Lethean"] + path = Lethean url = https://github.com/hyle-team/zano.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b4612bd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# Build-only: compiles the C++ cryptonote native addon (lethean-util) +# Requires the Lethean blockchain source tree mounted/copied alongside. +# +# Build context must be the parent directory (zano-upstream/), e.g.: +# docker build -f zano-node-util/Dockerfile -t lethean-util . +# +# The blockchain repo is expected at ./blockchain (symlinked as Lethean inside the package). + +FROM node:22 AS builder + +# Native build dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + python3 \ + python3-pip \ + libboost-system-dev \ + libboost-date-time-dev \ + libboost-thread-dev \ + libboost-serialization-dev \ + libboost-iostreams-dev \ + libboost-locale-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /workspace + +# Copy blockchain source (provides Lethean/ headers referenced by binding.gyp) +COPY blockchain/ ./blockchain/ + +# Copy the generated currency config header into the build path that binding.gyp expects +RUN mkdir -p blockchain/build/release/src/config +COPY blockchain/build/release/src/config/currency_config.h \ + blockchain/build/release/src/config/currency_config.h + +# Copy the addon source +COPY zano-node-util/package.json zano-node-util/package-lock.json ./zano-node-util/ +COPY zano-node-util/binding.gyp zano-node-util/main.cc zano-node-util/index.js ./zano-node-util/ + +# Symlink Lethean -> ../blockchain so binding.gyp paths resolve +RUN ln -sf /workspace/blockchain /workspace/zano-node-util/Lethean + +WORKDIR /workspace/zano-node-util + +RUN npm ci +RUN npm rebuild --build-from-source + +# Minimal runtime image with the compiled .node addon +FROM node:22-slim + +WORKDIR /app + +COPY --from=builder /workspace/zano-node-util/build ./build +COPY --from=builder /workspace/zano-node-util/index.js ./ +COPY --from=builder /workspace/zano-node-util/package.json ./ diff --git a/Lethean b/Lethean new file mode 120000 index 0000000..04631b5 --- /dev/null +++ b/Lethean @@ -0,0 +1 @@ +/home/claude/Code/lthn/blockchain \ No newline at end of file diff --git a/README.md b/README.md index eb86281..614d221 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,52 @@ -Zano-Node-Util -==================== +# lethean-util -Based on: https://github.com/Snipa22/node-cryptonote-util +CryptoNote node utility for Lethean — address generation, validation, and block/transaction processing. -Dependencies ------------- +This is Lethean's equivalent of `cryptoforknote-util`. It's a C++ native Node.js addon that links against the Lethean blockchain source tree. -* Boost (http://www.boost.org/) +## Install + +```bash +npm install +# Requires: cmake, g++, libboost-all-dev +# The native addon links against ../blockchain/src/ via the Lethean symlink +``` + +## Usage + +```javascript +var cn = require('lethean-util'); + +// Validate address +var decoded = cn.address_decode(Buffer.from('iTHNUNiuu3VP...')); + +// Get block hash +var hash = cn.get_pow_hash(blockBlob); + +// Convert block blob +var converted = cn.convert_blob(blockBlob); +``` + +## Functions + +| Function | Purpose | +|----------|---------| +| `address_decode` | Decode a Lethean address (iTHN prefix) | +| `is_address_valid` | Validate address format | +| `convert_blob` | Convert block blob for mining | +| `get_pow_hash` | Calculate ProgPoWZ proof-of-work hash | +| `get_hash_from_block_template_with_extra` | Hash with extra data | +| `get_blob_from_block_template` | Extract blob from template | +| `get_id_hash` | Get block ID hash | +| `get_merged_mining_nonce_size` | Merged mining nonce size | +| `baseDiff` | Base difficulty calculation | + +## Network + +| Property | Value | +|----------|-------| +| Address prefix | iTHN (standard), iTHn (integrated) | +| Decimal places | 12 | +| Coin units | 1,000,000,000,000 | + +Based on: https://github.com/Snipa22/node-cryptonote-util diff --git a/Zano b/Zano deleted file mode 160000 index 60471f7..0000000 --- a/Zano +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 60471f7f46c1e5e470f704c9e841a7f9bab3620e diff --git a/binding.gyp b/binding.gyp index 3d36a97..bebc1ec 100644 --- a/binding.gyp +++ b/binding.gyp @@ -4,40 +4,41 @@ "target_name": "cryptonote", "sources": [ "main.cc", - "Zano/src/currency_core/currency_format_utils.cpp", - "Zano/src/currency_core/currency_format_utils_blocks.cpp", - "Zano/src/currency_core/basic_pow_helpers.cpp", - "Zano/src/currency_core/basic_pow_helpers.cpp", - "Zano/src/crypto/tree-hash.c", - "Zano/src/crypto/crypto.cpp", - "Zano/src/crypto/crypto-ops.c", - "Zano/src/crypto/crypto-sugar.cpp", - "Zano/src/crypto/zarcanum.cpp", - "Zano/src/crypto/range_proofs.cpp", - "Zano/src/crypto/crypto-ops-data.c", - "Zano/src/crypto/hash.c", - "Zano/src/crypto/keccak.c", - "Zano/src/common/base58.cpp", - "Zano/contrib/ethereum/libethash/ethash.cpp", - "Zano/contrib/ethereum/libethash/keccak.c", - "Zano/contrib/ethereum/libethash/keccakf800.c", - "Zano/contrib/ethereum/libethash/progpow.cpp", - "Zano/contrib/ethereum/libethash/managed.cpp", - "Zano/src/currency_core/currency_format_utils_transactions.cpp", - "Zano/src/currency_core/genesis.cpp", - "Zano/src/currency_core/genesis_acc.cpp", - "Zano/src/crypto/random.c", - "Zano/contrib/ethereum/libethash/keccakf1600.c", - "Zano/contrib/ethereum/libethash/managed.cpp", - "Zano/contrib/ethereum/libethash/primes.c" + "Lethean/src/currency_core/currency_format_utils.cpp", + "Lethean/src/currency_core/currency_format_utils_blocks.cpp", + "Lethean/src/currency_core/basic_pow_helpers.cpp", + "Lethean/src/currency_core/basic_pow_helpers.cpp", + "Lethean/src/crypto/tree-hash.c", + "Lethean/src/crypto/crypto.cpp", + "Lethean/src/crypto/crypto-ops.c", + "Lethean/src/crypto/crypto-sugar.cpp", + "Lethean/src/crypto/zarcanum.cpp", + "Lethean/src/crypto/range_proofs.cpp", + "Lethean/src/crypto/crypto-ops-data.c", + "Lethean/src/crypto/hash.c", + "Lethean/src/crypto/keccak.c", + "Lethean/src/common/base58.cpp", + "Lethean/contrib/ethereum/libethash/ethash.cpp", + "Lethean/contrib/ethereum/libethash/keccak.c", + "Lethean/contrib/ethereum/libethash/keccakf800.c", + "Lethean/contrib/ethereum/libethash/progpow.cpp", + "Lethean/contrib/ethereum/libethash/managed.cpp", + "Lethean/src/currency_core/currency_format_utils_transactions.cpp", + "Lethean/src/currency_core/genesis.cpp", + "Lethean/src/currency_core/genesis_acc.cpp", + "Lethean/src/crypto/random.c", + "Lethean/contrib/ethereum/libethash/keccakf1600.c", + "Lethean/contrib/ethereum/libethash/managed.cpp", + "Lethean/contrib/ethereum/libethash/primes.c" ], "include_dirs": [ - "Zano/src/crypto", - "Zano/src", - "Zano/contrib", - "Zano/contrib/epee/include", - "Zano/contrib/eos_portable_archive", - "Zano/contrib/ethereum/libethash", + "Lethean/src/crypto", + "Lethean/src", + "Lethean/contrib", + "Lethean/contrib/epee/include", + "Lethean/contrib/eos_portable_archive", + "Lethean/contrib/ethereum/libethash", + "Lethean/contrib/randomx/src", "