Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@node-dlc/messaging

atomicfinance4.9kMIT1.1.3TypeScript support: included

DLC Messaging Protocol

dlc, messaging protocol

readme

@node-dlc/messaging

Build Status Standard Code Style License: GPL v3

Installation

npm i @node-dlc/messaging

Usage

import { OracleAnnouncement } from '@node-dlc/messaging';

const buf = Buffer.from(
  'fdd824fd02ab1efe41fa42ea1dcd103a0251929dd2b192d2daece8a4ce4d81f68a183b750d92d6f02d796965dc79adf4e7786e08f861a1ecc897afbba2dab9cff6eb0a81937eb8b005b07acf849ad2cec22107331dedbf5a607654fad4eafe39c278e27dde68fdd822fd02450011f9313f1edd903fab297d5350006b669506eb0ffda0bb58319b4df89ac24e14fd15f9791dc78d1596b06f4969bdb37d9e394dc9fedaa18d694027fa32b5ea2a5e60080c58e13727367c3a4ce1ad65dfb3c7e3ca1ea912b0299f6e383bab2875058aa96a1c74633130af6fbd008788de6ac9db76da4ecc7303383cc1a49f525316413850f7e3ac385019d560e84c5b3a3e9ae6c83f59fe4286ddfd23ea46d7ae04610a175cd28a9bf5f574e245c3dfe230dc4b0adf4daaea96780e594f6464f676505f4b74cfe3ffc33415a23de795bf939ce64c0c02033bbfc6c9ff26fb478943a1ece775f38f5db067ca4b2a9168b40792398def9164bfe5c46838472dc3c162af16c811b7a116e9417d5bccb9e5b8a5d7d26095aba993696188c3f85a02f7ab8d12ada171c352785eb63417228c7e248909fc2d673e1bb453140bf8bf429375819afb5e9556663b76ff09c2a7ba9779855ffddc6d360cb459cf8c42a2b949d0de19fe96163d336fd66a4ce2f1791110e679572a20036ffae50204ef520c01058ff4bef28218d1c0e362ee3694ad8b2ae83a51c86c4bc1630ed6202a158810096726f809fc828fafdcf053496affdf887ae8c54b6ca4323ccecf6a51121c4f0c60e790536dab41b221db1c6b35065dc19a9d31cf75901aa35eefecbb6fefd07296cda13cb34ce3b58eba20a0eb8f9614994ec7fee3cc290e30e6b1e3211ae1f3a85b6de6abdbb77d6d9ed33a1cee3bd5cd93a71f12c9c45e385d744ad0e7286660305100fdd80a11000200076274632f75736400000000001109425443205072696365',
  'hex',
);

const instance = OracleAnnouncement.deserialize(buf);

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[1.0.1] - 2025-07-15

New Features

Single Funded DLC Support (PR #224)

  • Added single funded DLC detection: New singleFunded flag and methods in DlcOffer and DlcAccept
  • Auto-detection logic: Automatically identifies single funded DLC scenarios
  • Updated validation rules: Enhanced validation for single funded DLC scenarios
  • Comprehensive test coverage: Added tests for all new single funded functionality

In single funded DLCs:

  • DlcOffer: totalCollateral equals offerCollateral
  • DlcAccept: acceptCollateral is typically 0 or minimal

Bug Fixes

Number Input Handling (PR #225)

  • Fixed computeRoundingModulus: Now correctly handles number inputs by converting to satoshis (multiply by 1e8)
  • Preserved existing behavior: Value objects and BigInt inputs continue to work as before
  • Enhanced test coverage: Added comprehensive tests for all input types
  • Updated test consistency: Existing tests now use BigInt for raw satoshi values

Previously, number inputs were incorrectly treated as raw satoshi values instead of bitcoin amounts, leading to incorrect calculations.

🔧 Improvements

Development Tooling (PR #226)

  • ESLint upgrade: Updated from v7 to v8 with related plugins
  • TypeScript ESLint upgrade: Updated from v4 to v5
  • Import/export organization: Added simple-import-sort/exports rule for consistent ordering
  • Type safety improvements: Fixed TypeScript types (BigIntbigint) and enhanced type safety
  • Build configuration: Updated tsconfig.json files with consistent build output
  • Code quality: Improved BigNumber usage and better type inference with as const

[1.0.0] - 2025-06-30

🚨 BREAKING CHANGES

  • DLC Protocol Version 1: Complete protocol overhaul with new serialization format
  • Message Class Naming: Removed V0 suffixes from all DLC message classes
  • Incompatible with Previous Versions: All DLC messages use new format incompatible with v0.x releases
  • Type System Refactor: Introduced new type enums (ContractInfoType, ContractDescriptorType, OracleInfoType)

🚀 Major Features

DLC Specifications Compliance (PR #163)

  • Full rust-dlc Compatibility: 100% compatibility with rust-dlc implementation
  • Protocol Version 1: Added PROTOCOL_VERSION = 1 constant
  • Enhanced Type System: New discriminated union types for better type safety
  • F64 Precision Class: High-precision floating-point calculations for financial operations
  • Standardized Properties: Consistent naming across all message types

Message System Overhaul

  • New Message Formats: Complete refactor of DLC message serialization
  • TLV Compatibility: Preserved forward compatibility with unknown TLV handling
  • Enhanced Oracle Support: Improved oracle message parsing and compatibility
  • Simplified Class Names: Cleaner naming convention without version suffixes

🔧 Improvements

  • TypeScript Type Safety: Enhanced type checking with discriminated unions
  • Code Quality: Standardized formatting and removed duck typing patterns
  • Test Coverage: 171 passing internal tests with 24 new test vector files
  • Cross-Language Testing: Compatibility testing infrastructure with rust-dlc
  • Defensive Programming: Added error handling and validation throughout

🐛 Bug Fixes

  • Payout Calculations: Improved accuracy in payout curve calculations
  • Message Parsing: Enhanced oracle message parsing compatibility
  • BigInt Handling: Consolidated BigInt helper functions
  • Import Organization: Cleaned up package imports and dependencies

📦 Package Changes

  • Messaging Package: F64 class moved to messaging package for better organization
  • Transport Updates: Updated for new message format compatibility
  • Storage Libraries: Updated to handle new serialization format
  • CLI Enhancements: Improved rust-dlc CLI with oracle creation capabilities

🧪 Testing

  • Compatibility Tests: Comprehensive testing against rust-dlc implementation
  • Test Vector Updates: New test files for protocol version 1 compliance
  • Cross-Platform Testing: Verified compatibility across different environments
  • Increased Timeout: Extended compatibility test timeouts for complex scenarios

[0.24.1] - 2025-06-09

🔧 Improvements

  • Dependency Updates: Upgraded bitcoinjs-lib to version 6.1.7 across affected packages
    • @node-dlc/chainmon - Updated bitcoinjs-lib dependency
    • @node-dlc/messaging - Updated bitcoinjs-lib dependency
    • @node-dlc/transport - Updated bitcoinjs-lib dependency
  • Security: Latest bitcoinjs-lib includes security fixes and performance improvements
  • Compatibility: Enhanced Bitcoin protocol compatibility with latest library version

🐛 Bug Fixes

  • Package Dependencies: Resolved dependency conflicts in affected packages
  • Build Process: Updated package-lock.json files for consistent dependency resolution

[0.24.0] - 2025-06-02

🚀 Major Features

Node-Lightning Integration Complete

  • Absorbed deprecated node-lightning packages into node-dlc, making the project fully self-contained
  • Added new packages from node-lightning:
    • @node-dlc/bitcoind - Bitcoin Core RPC and ZMQ client
    • @node-dlc/bufio - Buffer I/O utilities
    • @node-dlc/checksum - Checksum utilities (CRC32C)
    • @node-dlc/crypto - Cryptographic functions
    • @node-dlc/wire - Lightning Network wire protocol
    • @node-dlc/noise - Noise protocol implementation
  • Enhanced existing packages with node-lightning functionality:
    • @node-dlc/bitcoin - Added Base58, Script, Tx, and other missing utilities
    • @node-dlc/core - Merged lightning utilities while preserving DLC functionality
    • @node-dlc/logger - Enhanced with additional features from node-lightning
    • @node-dlc/chainmon - Added BlockDiffer and BlockDiffResult functionality

Database Migration: RocksDB → LevelDB

  • Migrated from deprecated RocksDB to actively maintained classic-level
  • Renamed package from @node-dlc/rocksdb to @node-dlc/leveldb
  • Modern async/await API replacing legacy stream-based interface
  • Better performance with native LevelDB implementation

Architecture Improvements

  • Created @node-dlc/common package to resolve circular dependencies
  • Moved shared utilities (BitField, ShortChannelId, ChannelId, Base32) to common package
  • Cleaner dependency hierarchy with no circular references
  • Improved maintainability with better separation of concerns

⚡ New Features

  • Node.js 20.x Support: Upgraded ZeroMQ to v6 for full Node.js 20.x compatibility
  • Batch Funding Group TLV: Added support for batch funding group TLV in DlcSign messages
  • Enhanced DLC Messaging: Improved DLC message containers with bigsize encoding
  • Modern TypeScript: Updated to TypeScript 4.9.5 with better type safety

🔧 Improvements

  • Dependency Cleanup: Removed deprecated bcrypto package
  • Code Quality: Fixed linting and formatting across all packages
  • Documentation: Comprehensive migration guides and technical documentation
  • CI/CD: Updated GitHub Actions for Node.js 18+ support
  • Test Coverage: Maintained ~66% test coverage across all packages

🏗️ Breaking Changes

  • Node.js 18+ Required: Minimum Node.js version is now 18 (up from 14)
  • Database Format: LevelDB format is incompatible with previous RocksDB databases
    • Migration Required: Existing databases cannot be directly migrated
    • Fresh Start: New projects will use LevelDB format going forward
  • Package Renames: @node-dlc/rocksdb is now @node-dlc/leveldb
  • Import Changes: Some internal imports may need updating (see migration guide)

🐛 Bug Fixes

  • Message Size Issues: Fixed out of range errors in accept and sign messages
  • Missing Dependencies: Added missing secp256k1 dependency to messaging package
  • TypeScript Compatibility: Resolved type conflicts with modern TypeScript versions
  • Build Process: Fixed circular dependency issues preventing successful builds

📚 Documentation

  • Migration Guides: Detailed guides for RocksDB→LevelDB and node-lightning integration
  • API Documentation: Updated documentation for all new and enhanced packages
  • Technical Summaries: Comprehensive change documentation for developers
  • README Updates: Removed references to deprecated components

🔄 Internal Changes

  • Lerna Configuration: Improved monorepo management and publishing workflow
  • ESLint Configuration: Enhanced linting rules and formatting consistency
  • TypeScript Configuration: Added skipLibCheck for better compatibility
  • Build Optimization: Streamlined build process across all packages

[0.23.6] - 2024-05-01

Features

  • Added batch funding group TLV to DlcSign message

Bug Fixes

  • Fixed DLC message container size handling to prevent out of range errors
  • Added missing length field to BatchFundingGroup TLV

[0.23.5] - 2024-04-14

Bug Fixes

  • Switched DLC message container to bigsize encoding

[0.23.4] - 2024-04-09

Features

  • Added DLC message containers

Bug Fixes

  • Fixed missing length in BatchFundingGroup TLV

Migration Guide

From 0.23.x to 0.24.0

1. Node.js Version

# Update to Node.js 18+
nvm install 18
nvm use 18

2. Package Updates

# Update dependencies
npm install
# or
yarn install

# Rebuild all packages
npm run bootstrap
# or
yarn bootstrap

3. Database Migration

  • RocksDB databases are not compatible with the new LevelDB format
  • For new projects: No action needed, will use LevelDB automatically
  • For existing projects: Consider if database migration is needed or start fresh

4. Import Updates

// Old
import { BitField } from '@node-dlc/core';

// New - still works (re-exported)
import { BitField } from '@node-dlc/core';
// Or use direct import
import { BitField } from '@node-dlc/common';

5. Package Renames

// Old
import something from '@node-dlc/rocksdb';

// New
import something from '@node-dlc/leveldb';

For detailed migration information, see the individual migration guides in the repository.