Skip to content

Commit 37a7a06

Browse files
committed
feat(utxo-descriptors): add sBTC taproot descriptors
Ticket: CSHLD-744
1 parent d473c4c commit 37a7a06

22 files changed

Lines changed: 692 additions & 0 deletions

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
/modules/utxo-lib/ @BitGo/btc-team
2828
/modules/utxo-ord/ @BitGo/btc-team
2929
/modules/utxo-staking/ @BitGo/btc-team
30+
/modules/utxo-descriptors/ @BitGo/btc-team @BitGo/ethalt-team
3031
/modules/babylonlabs-io-btc-staking-ts @BitGo/btc-team
3132
/modules/bitgo/test/v2/unit/coins/abstractUtxoCoin.ts @BitGo/btc-team
3233
/modules/bitgo/test/v2/unit/coins/payGoPSBTHexFixture/psbtHexProof.ts @BitGo/btc-team
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
extends: ['../../.eslintrc.json'],
3+
rules: {
4+
'import/order': ['error', { 'newlines-between': 'always' }],
5+
'import/no-internal-modules': 'off',
6+
},
7+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist
2+
/node_modules
3+
/.nyc_output
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
require: 'tsx',
3+
extension: ['.js', '.ts'],
4+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**/*.ts
2+
!**/*.d.ts
3+
src
4+
test
5+
tsconfig.json
6+
tslint.json
7+
.gitignore
8+
.eslintignore
9+
.mocharc.yml
10+
.prettierignore
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.nyc_output/
2+
dist
3+
node_modules
4+
test/fixtures
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
printWidth: 120
2+
singleQuote: true
3+
trailingComma: es5

modules/utxo-descriptors/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# @bitgo/utxo-descriptors
2+
3+
A library for constructing [Bitcoin output descriptors][bip-380] (BIP-380) — descriptor strings that pair on-chain UTXOs with a derivable, parseable key-tracking expression.
4+
5+
This package is the canonical home for descriptor-building logic across BitGo's UTXO codebase. It deliberately stays one layer above [`@bitgo/wasm-utxo`][wasm-utxo]: that package owns descriptor parsing and miniscript compilation. This package owns the high-level _builders_ that emit valid descriptor strings for the protocols BitGo supports.
6+
7+
## Install
8+
9+
```bash
10+
yarn add @bitgo/utxo-descriptors
11+
```
12+
13+
## Module layout
14+
15+
```
16+
src/
17+
├── index.ts # re-exports each protocol module under a namespace
18+
└── sbtc/ # sBTC peg-in deposit descriptors
19+
├── constants.ts
20+
├── descriptor.ts
21+
├── depositAddress.ts
22+
└── index.ts
23+
```
24+
25+
Each new protocol gets its own subdirectory under `src/` and is re-exported as a namespace from [`src/index.ts`](src/index.ts), so consumers import it as `import { sbtc } from '@bitgo/utxo-descriptors'`.
26+
27+
---
28+
29+
## sBTC
30+
31+
The `sbtc` namespace builds descriptors for sBTC peg-in deposits — Bitcoin UTXOs whose output script is a Taproot tree with two leaves:
32+
33+
- a **deposit** leaf, spendable only by the sBTC signers, that commits to the Stacks recipient and the maximum signer fee
34+
- a **reclaim** leaf, spendable by the depositor after a relative timelock, that lets the depositor recover their BTC if the signers fail to act
35+
36+
Both leaves are expressed as **Bitcoin miniscript fragments** inside a single `tr()` descriptor — no raw script bytes, no out-of-band leaf hashing. This is enabled by the `payload_drop(<hex>)` fragment and tap-context `r:older(N)` shipped in `@bitgo/wasm-utxo` 4.11.0 ([BitGoWASM #272](https://github.com/BitGo/BitGoWASM/pull/272)).
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "@bitgo/utxo-descriptors",
3+
"version": "1.39.1",
4+
"description": "BitGo SDK for building UTXO descriptors",
5+
"main": "./dist/cjs/src/index.js",
6+
"module": "./dist/esm/index.js",
7+
"browser": "./dist/esm/index.js",
8+
"types": "./dist/cjs/src/index.d.ts",
9+
"files": [
10+
"dist/cjs",
11+
"dist/esm"
12+
],
13+
"exports": {
14+
".": {
15+
"import": {
16+
"types": "./dist/esm/index.d.ts",
17+
"default": "./dist/esm/index.js"
18+
},
19+
"require": {
20+
"types": "./dist/cjs/src/index.d.ts",
21+
"default": "./dist/cjs/src/index.js"
22+
}
23+
}
24+
},
25+
"scripts": {
26+
"build": "npm run build:cjs && npm run build:esm",
27+
"build:cjs": "yarn tsc --build --incremental --verbose .",
28+
"build:esm": "yarn tsc --project tsconfig.esm.json",
29+
"fmt": "prettier --write .",
30+
"check-fmt": "prettier --check '**/*.{ts,js,json}'",
31+
"clean": "rm -r ./dist",
32+
"lint": "eslint --quiet .",
33+
"prepare": "npm run build",
34+
"coverage": "nyc -- npm run unit-test",
35+
"unit-test": "mocha --recursive \"test/**/*.ts\""
36+
},
37+
"author": "BitGo SDK Team <sdkteam@bitgo.com>",
38+
"license": "MIT",
39+
"engines": {
40+
"node": ">=20"
41+
},
42+
"repository": {
43+
"type": "git",
44+
"url": "https://github.com/BitGo/BitGoJS.git",
45+
"directory": "modules/utxo-descriptors"
46+
},
47+
"lint-staged": {
48+
"*.{js,ts}": [
49+
"yarn prettier --write",
50+
"yarn eslint --fix"
51+
]
52+
},
53+
"publishConfig": {
54+
"access": "public"
55+
},
56+
"nyc": {
57+
"extension": [
58+
".ts"
59+
]
60+
},
61+
"dependencies": {
62+
"@bitgo/utxo-core": "^1.37.1",
63+
"@bitgo/wasm-utxo": "^4.11.0"
64+
}
65+
}

0 commit comments

Comments
 (0)