Skip to content

Commit ee24c13

Browse files
authored
feat(utxo-descriptors): add sBTC taproot descriptors
2 parents 7afac15 + 19dac58 commit ee24c13

22 files changed

Lines changed: 693 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: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "@bitgo/utxo-descriptors",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "BitGo SDK for building UTXO descriptors",
6+
"main": "./dist/cjs/src/index.js",
7+
"module": "./dist/esm/index.js",
8+
"browser": "./dist/esm/index.js",
9+
"types": "./dist/cjs/src/index.d.ts",
10+
"files": [
11+
"dist/cjs",
12+
"dist/esm"
13+
],
14+
"exports": {
15+
".": {
16+
"import": {
17+
"types": "./dist/esm/index.d.ts",
18+
"default": "./dist/esm/index.js"
19+
},
20+
"require": {
21+
"types": "./dist/cjs/src/index.d.ts",
22+
"default": "./dist/cjs/src/index.js"
23+
}
24+
}
25+
},
26+
"scripts": {
27+
"build": "npm run build:cjs && npm run build:esm",
28+
"build:cjs": "yarn tsc --build --incremental --verbose .",
29+
"build:esm": "yarn tsc --project tsconfig.esm.json",
30+
"fmt": "prettier --write .",
31+
"check-fmt": "prettier --check '**/*.{ts,js,json}'",
32+
"clean": "rm -r ./dist",
33+
"lint": "eslint --quiet .",
34+
"prepare": "npm run build",
35+
"coverage": "nyc -- npm run unit-test",
36+
"unit-test": "mocha --recursive \"test/**/*.ts\""
37+
},
38+
"author": "BitGo SDK Team <sdkteam@bitgo.com>",
39+
"license": "MIT",
40+
"engines": {
41+
"node": ">=20"
42+
},
43+
"repository": {
44+
"type": "git",
45+
"url": "https://github.com/BitGo/BitGoJS.git",
46+
"directory": "modules/utxo-descriptors"
47+
},
48+
"lint-staged": {
49+
"*.{js,ts}": [
50+
"yarn prettier --write",
51+
"yarn eslint --fix"
52+
]
53+
},
54+
"publishConfig": {
55+
"access": "public"
56+
},
57+
"nyc": {
58+
"extension": [
59+
".ts"
60+
]
61+
},
62+
"dependencies": {
63+
"@bitgo/utxo-core": "^1.37.1",
64+
"@bitgo/wasm-utxo": "^4.11.0"
65+
}
66+
}

0 commit comments

Comments
 (0)