npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@atomicfinance/bitcoin-ddk-provider

v4.2.7

Published

Bitcoin Abstraction Layer Ddk Provider

Readme

Bitcoin DDK Provider

A Bitcoin provider that implements DLC (Discreet Log Contract) functionality using the DDK (Discreet Log Contract Development Kit) interface.

Features

  • Interface-based design: Uses a DdkInterface that allows different DDK implementations to be injected
  • Flexible: Can work with ddk-ts, ddk-rn, or any custom DDK implementation
  • Type-safe: Full TypeScript support with proper type definitions
  • Testable: Easy to mock for unit testing

Installation

npm install @atomicfinance/bitcoin-ddk-provider

Usage

Basic Usage with ddk-ts

import BitcoinDdkProvider from '@atomicfinance/bitcoin-ddk-provider';
import * as ddkTs from '@bennyblader/ddk-ts';
import { BitcoinNetwork } from 'bitcoin-network';

// Create provider with ddk-ts implementation
const network = BitcoinNetwork.MAINNET;
const provider = new BitcoinDdkProvider(network, ddkTs);

// Use the provider
const version = await provider.getVersion();
console.log(`DDK Version: ${version}`);

Usage with ddk-rn

import BitcoinDdkProvider from '@atomicfinance/bitcoin-ddk-provider';
import * as ddkRn from '@bennyblader/ddk-rn';
import { BitcoinNetwork } from 'bitcoin-network';

// Create provider with ddk-rn implementation
const network = BitcoinNetwork.MAINNET;
const provider = new BitcoinDdkProvider(network, ddkRn);

Custom DDK Implementation

import BitcoinDdkProvider from '@atomicfinance/bitcoin-ddk-provider';
import { DdkInterface, DlcOutcome, PartyParams, DlcTransactions } from '@atomicfinance/types';

// Create your own DDK implementation
class MyCustomDdk implements DdkInterface {
  createDlcTransactions(
    outcomes: DlcOutcome[],
    localParams: PartyParams,
    remoteParams: PartyParams,
    refundLocktime: number,
    feeRate: bigint,
    fundLockTime: number,
    cetLockTime: number,
    fundOutputSerialId: bigint,
  ): DlcTransactions {
    // Your custom implementation
    return {
      fund: { /* ... */ },
      cets: [],
      refund: { /* ... */ },
      fundingScriptPubkey: Buffer.alloc(0),
    };
  }

  // Implement all other required methods...
  createCet(/* ... */) { /* ... */ }
  createCets(/* ... */) { /* ... */ }
  // ... etc
}

// Use your custom implementation
const network = BitcoinNetwork.MAINNET;
const customDdk = new MyCustomDdk();
const provider = new BitcoinDdkProvider(network, customDdk);

Testing with Mock Implementation

import BitcoinDdkProvider from '@atomicfinance/bitcoin-ddk-provider';
import { DdkInterface } from '@atomicfinance/types';

// Create a mock for testing
const mockDdk: DdkInterface = {
  createDlcTransactions: jest.fn().mockResolvedValue(/* mock data */),
  createFundTxLockingScript: jest.fn().mockReturnValue(Buffer.alloc(0)),
  // ... implement other methods as needed
};

const provider = new BitcoinDdkProvider(BitcoinNetwork.TESTNET, mockDdk);

API Reference

Constructor

constructor(network: BitcoinNetwork, ddkLib: DdkInterface)
  • network: The Bitcoin network to use (mainnet, testnet, etc.)
  • ddkLib: A DDK implementation that conforms to the DdkInterface

Methods

The provider implements all the standard DLC methods:

  • createDlcTransactions() - Create DLC transactions
  • createFundTx() - Create funding transaction
  • createCet() - Create CET (Contract Execution Transaction)
  • createCets() - Create multiple CETs
  • createRefundTransaction() - Create refund transaction
  • createCetAdaptorSignature() - Create CET adaptor signature
  • signFundTransactionInput() - Sign funding transaction input
  • verifyFundTxSignature() - Verify funding transaction signature
  • getVersion() - Get DDK version
  • getChangeOutputAndFees() - Calculate change output and fees
  • getTotalInputVsize() - Get total input vsize
  • isDustOutput() - Check if output is dust
  • createSplicedDlcTransactions() - Create spliced DLC transactions

Benefits of Interface-Based Design

  1. Dependency Injection: Easy to swap implementations
  2. Testing: Simple to mock for unit tests
  3. Flexibility: Support multiple DDK libraries
  4. Maintainability: Clear contract for what any DDK implementation must provide
  5. Future-Proof: Easy to add new DDK implementations or remove dependencies

Type Safety

All methods are fully typed using TypeScript interfaces from @atomicfinance/types. The provider ensures type safety while maintaining flexibility through the interface-based design.