Skip to content

feat(bitcoin): add taproot lock output method to Script#239

Merged
matthewjablack merged 4 commits into
masterfrom
alex/eng-1491-add-scriptp2trlock-to-node-dlcbitcoin
Jul 7, 2026
Merged

feat(bitcoin): add taproot lock output method to Script#239
matthewjablack merged 4 commits into
masterfrom
alex/eng-1491-add-scriptp2trlock-to-node-dlcbitcoin

Conversation

@w3irdrobot

@w3irdrobot w3irdrobot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds Taproot scriptPubKey support for DLC output handling in node-dlc.

This PR adds a Script.p2trLock() helper for constructing P2TR output scripts and updates DLC funding transaction change output creation to preserve raw changeSpk scripts instead of assuming all change outputs are P2WPKH.

Changes

  • Add Script.p2trLock() for OP_1 <x-only-pubkey> Taproot output scripts.
  • Add Script.fromRaw() for parsing raw scriptPubKey bytes without a length prefix.
  • Update BatchDlcTxBuilder to use raw changeSpk scripts directly.
  • Add tests for:
    • Taproot scriptPubKey construction.
    • Raw Taproot script parsing.
    • Offer-side Taproot change output preservation.
    • Accept-side Taproot change output preservation.

Context

Previously, BatchDlcTxBuilder rebuilt change outputs with:

Script.p2wpkhLock(changeSpk.slice(2))

That only works for P2WPKH scripts and breaks for Taproot/P2TR scriptPubKeys. This is problematic when payout/liquidation addresses are Taproot and the same script is used as changeSpk.

This PR keeps DLC funding outputs unchanged as P2WSH multisig. It only makes provided output scripts round-trip correctly.

Validation

  • yarn build
  • yarn workspace @node-dlc/bitcoin test
  • yarn workspace @node-dlc/core test -- --grep TxBuilder
  • Pre-commit lint hook passed

@w3irdrobot w3irdrobot self-assigned this Jun 29, 2026

@matthewjablack matthewjablack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small nit

other than that LGTM 🎉

Comment thread packages/bitcoin/lib/Script.ts

@matthewjablack matthewjablack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@matthewjablack matthewjablack merged commit e958a19 into master Jul 7, 2026
2 checks passed
@matthewjablack matthewjablack deleted the alex/eng-1491-add-scriptp2trlock-to-node-dlcbitcoin branch July 7, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants