@secondlayer/stacks 2.11.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +47 -0
  2. package/dist/shared/{stacks-v150hffx.js → stacks-01pbr7gf.js} +13 -12
  3. package/dist/shared/stacks-01pbr7gf.js.map +11 -0
  4. package/dist/shared/stacks-0cdm20eh.js +225 -0
  5. package/dist/shared/stacks-0cdm20eh.js.map +11 -0
  6. package/dist/shared/{stacks-hxm7r5ay.cjs → stacks-44y18a8e.cjs} +3 -10
  7. package/dist/shared/stacks-44y18a8e.cjs.map +10 -0
  8. package/dist/shared/{stacks-7nvbv61d.js → stacks-59xy6t1p.js} +27 -25
  9. package/dist/shared/{stacks-7nvbv61d.js.map → stacks-59xy6t1p.js.map} +6 -6
  10. package/dist/shared/{stacks-63xbc6cj.js → stacks-6n2m9hyk.js} +3 -3
  11. package/dist/shared/stacks-bnbdqznq.cjs +211 -0
  12. package/dist/shared/stacks-bnbdqznq.cjs.map +11 -0
  13. package/dist/shared/stacks-esn3wcw5.cjs +416 -0
  14. package/dist/shared/stacks-esn3wcw5.cjs.map +18 -0
  15. package/dist/shared/{stacks-3kmj5yre.js → stacks-g67f4w1d.js} +5 -12
  16. package/dist/shared/stacks-g67f4w1d.js.map +10 -0
  17. package/dist/shared/stacks-kjg7fw4y.js +434 -0
  18. package/dist/shared/stacks-kjg7fw4y.js.map +18 -0
  19. package/dist/shared/{stacks-maamjqma.cjs → stacks-tbv5p6pn.cjs} +7 -9
  20. package/dist/shared/stacks-tbv5p6pn.cjs.map +11 -0
  21. package/dist/shared/{stacks-k5an9zcw.cjs → stacks-y5epf0sb.cjs} +19 -22
  22. package/dist/shared/{stacks-k5an9zcw.cjs.map → stacks-y5epf0sb.cjs.map} +6 -6
  23. package/dist/src/accounts/index.cjs +28 -1
  24. package/dist/src/accounts/index.cjs.map +4 -3
  25. package/dist/src/accounts/index.d.cts +23 -1
  26. package/dist/src/accounts/index.d.ts +23 -1
  27. package/dist/src/accounts/index.js +33 -1
  28. package/dist/src/accounts/index.js.map +4 -3
  29. package/dist/src/actions/index.cjs +8 -1
  30. package/dist/src/actions/index.cjs.map +1 -1
  31. package/dist/src/actions/index.d.cts +140 -6
  32. package/dist/src/actions/index.d.ts +140 -6
  33. package/dist/src/actions/index.js +22 -8
  34. package/dist/src/actions/index.js.map +1 -1
  35. package/dist/src/bitcoin/index.cjs +4 -175
  36. package/dist/src/bitcoin/index.cjs.map +4 -6
  37. package/dist/src/bitcoin/index.d.cts +18 -2
  38. package/dist/src/bitcoin/index.d.ts +18 -2
  39. package/dist/src/bitcoin/index.js +18 -181
  40. package/dist/src/bitcoin/index.js.map +4 -6
  41. package/dist/src/bns/index.js +3 -3
  42. package/dist/src/index.cjs +10 -1
  43. package/dist/src/index.cjs.map +3 -3
  44. package/dist/src/index.d.cts +167 -9
  45. package/dist/src/index.d.ts +167 -9
  46. package/dist/src/index.js +23 -7
  47. package/dist/src/index.js.map +3 -3
  48. package/dist/src/pox/index.js +3 -3
  49. package/dist/src/sbtc/index.cjs +49 -7
  50. package/dist/src/sbtc/index.cjs.map +6 -6
  51. package/dist/src/sbtc/index.d.cts +8 -2
  52. package/dist/src/sbtc/index.d.ts +8 -2
  53. package/dist/src/sbtc/index.js +56 -10
  54. package/dist/src/sbtc/index.js.map +6 -6
  55. package/dist/src/stackingdao/index.js +3 -3
  56. package/dist/src/tools/index.cjs +194 -13
  57. package/dist/src/tools/index.cjs.map +12 -9
  58. package/dist/src/tools/index.js +194 -13
  59. package/dist/src/tools/index.js.map +12 -9
  60. package/dist/src/x402/index.cjs +5 -2
  61. package/dist/src/x402/index.cjs.map +3 -3
  62. package/dist/src/x402/index.d.cts +36 -0
  63. package/dist/src/x402/index.d.ts +36 -0
  64. package/dist/src/x402/index.js +7 -4
  65. package/dist/src/x402/index.js.map +3 -3
  66. package/package.json +2 -4
  67. package/dist/shared/stacks-3kmj5yre.js.map +0 -10
  68. package/dist/shared/stacks-502j0efj.js +0 -210
  69. package/dist/shared/stacks-502j0efj.js.map +0 -15
  70. package/dist/shared/stacks-hxm7r5ay.cjs.map +0 -10
  71. package/dist/shared/stacks-maamjqma.cjs.map +0 -11
  72. package/dist/shared/stacks-v150hffx.js.map +0 -11
  73. package/dist/shared/stacks-xmsms921.cjs +0 -196
  74. package/dist/shared/stacks-xmsms921.cjs.map +0 -15
  75. /package/dist/shared/{stacks-63xbc6cj.js.map → stacks-6n2m9hyk.js.map} +0 -0
@@ -2,10 +2,13 @@
2
2
  var exports_bitcoin = {};
3
3
  __export(exports_bitcoin, {
4
4
  verifyBitcoinPayment: () => verifyBitcoinPayment,
5
+ taprootTweakPubkey: () => taprootTweakPubkey,
5
6
  stripWitness: () => stripWitness,
6
7
  spvAdapterPrincipal: () => spvAdapterPrincipal,
7
8
  rootFromProof: () => rootFromProof,
8
9
  reverseBytes: () => reverseBytes,
10
+ publicKeyToP2wpkhAddress: () => publicKeyToP2wpkhAddress,
11
+ publicKeyToP2trAddress: () => publicKeyToP2trAddress,
9
12
  parseOutputScript: () => parseOutputScript,
10
13
  parseBlockHeader: () => parseBlockHeader,
11
14
  parseBitcoinTx: () => parseBitcoinTx,
@@ -31,151 +34,6 @@ __export(exports_bitcoin, {
31
34
  });
32
35
  module.exports = __toCommonJS(exports_bitcoin);
33
36
 
34
- // src/bitcoin/serialize.ts
35
- function doubleSha256(bytes) {
36
- return import_sha2.sha256(import_sha2.sha256(bytes));
37
- }
38
- function reverseBytes(bytes) {
39
- const out = new Uint8Array(bytes.length);
40
- for (let i = 0;i < bytes.length; i++) {
41
- out[i] = bytes[bytes.length - 1 - i];
42
- }
43
- return out;
44
- }
45
-
46
- class BtcReader {
47
- data;
48
- view;
49
- offset = 0;
50
- constructor(data) {
51
- this.data = data;
52
- this.view = new DataView(data.buffer, data.byteOffset, data.byteLength);
53
- }
54
- get length() {
55
- return this.data.length;
56
- }
57
- readUInt8() {
58
- const v = this.view.getUint8(this.offset);
59
- this.offset += 1;
60
- return v;
61
- }
62
- peekUInt8() {
63
- return this.view.getUint8(this.offset);
64
- }
65
- readUInt32LE() {
66
- const v = this.view.getUint32(this.offset, true);
67
- this.offset += 4;
68
- return v;
69
- }
70
- readUInt64LE() {
71
- const v = this.view.getBigUint64(this.offset, true);
72
- this.offset += 8;
73
- return v;
74
- }
75
- readBytes(n) {
76
- if (this.offset + n > this.data.length) {
77
- throw new Error(`Bitcoin tx underflow: need ${n} bytes at offset ${this.offset}, have ${this.data.length}`);
78
- }
79
- const slice = this.data.slice(this.offset, this.offset + n);
80
- this.offset += n;
81
- return slice;
82
- }
83
- readVarInt() {
84
- const first = this.readUInt8();
85
- if (first < 253)
86
- return first;
87
- if (first === 253) {
88
- const v = this.view.getUint16(this.offset, true);
89
- this.offset += 2;
90
- return v;
91
- }
92
- if (first === 254) {
93
- return this.readUInt32LE();
94
- }
95
- const big = this.readUInt64LE();
96
- if (big > BigInt(Number.MAX_SAFE_INTEGER)) {
97
- throw new Error("Bitcoin varint exceeds safe integer range");
98
- }
99
- return Number(big);
100
- }
101
- }
102
- function scanTx(rawTx) {
103
- const r = new BtcReader(rawTx);
104
- const version = r.readUInt32LE();
105
- let hasWitness = false;
106
- if (r.peekUInt8() === 0) {
107
- r.readUInt8();
108
- const flag = r.readUInt8();
109
- if (flag !== 1) {
110
- throw new Error(`Unexpected SegWit flag 0x${flag.toString(16)}`);
111
- }
112
- hasWitness = true;
113
- }
114
- const bodyStart = r.offset;
115
- const inputCount = r.readVarInt();
116
- const inputs = [];
117
- for (let i = 0;i < inputCount; i++) {
118
- const prevTxid = r.readBytes(32);
119
- const vout = r.readUInt32LE();
120
- const scriptSig = r.readBytes(r.readVarInt());
121
- const sequence = r.readUInt32LE();
122
- inputs.push({ prevTxid, vout, scriptSig, sequence });
123
- }
124
- const outputCount = r.readVarInt();
125
- const outputs = [];
126
- for (let i = 0;i < outputCount; i++) {
127
- const value = r.readUInt64LE();
128
- const scriptPubKey = r.readBytes(r.readVarInt());
129
- outputs.push({ value, scriptPubKey });
130
- }
131
- const bodyEnd = r.offset;
132
- if (hasWitness) {
133
- for (let i = 0;i < inputCount; i++) {
134
- const itemCount = r.readVarInt();
135
- for (let j = 0;j < itemCount; j++) {
136
- r.readBytes(r.readVarInt());
137
- }
138
- }
139
- }
140
- const locktime = r.readUInt32LE();
141
- const legacy = concatBytes(rawTx.slice(0, 4), rawTx.slice(bodyStart, bodyEnd), rawTx.slice(r.offset - 4, r.offset));
142
- return { version, hasWitness, inputs, outputs, locktime, legacy };
143
- }
144
- function parseBitcoinTx(rawTx) {
145
- const s = scanTx(rawTx);
146
- return {
147
- version: s.version,
148
- hasWitness: s.hasWitness,
149
- inputs: s.inputs,
150
- outputs: s.outputs,
151
- locktime: s.locktime,
152
- txidInternal: doubleSha256(s.legacy)
153
- };
154
- }
155
- function stripWitness(rawTx) {
156
- return scanTx(rawTx).legacy;
157
- }
158
- function bitcoinTxid(rawTx, { display = false } = {}) {
159
- const txid = doubleSha256(scanTx(rawTx).legacy);
160
- return display ? reverseBytes(txid) : txid;
161
- }
162
- function parseBlockHeader(header) {
163
- if (header.length !== 80) {
164
- throw new Error(`Bitcoin block header must be 80 bytes, got ${header.length}`);
165
- }
166
- const r = new BtcReader(header);
167
- const version = r.readUInt32LE();
168
- const prevBlock = r.readBytes(32);
169
- const merkleRoot = r.readBytes(32);
170
- const timestamp = r.readUInt32LE();
171
- const bits = r.readUInt32LE();
172
- const nonce = r.readUInt32LE();
173
- return { version, prevBlock, merkleRoot, timestamp, bits, nonce };
174
- }
175
- function blockHash(header, { display = false } = {}) {
176
- const hash = doubleSha256(header);
177
- return display ? reverseBytes(hash) : hash;
178
- }
179
37
  // src/bitcoin/merkle.ts
180
38
  function hashPair(left, right) {
181
39
  return doubleSha256(concatBytes(left, right));
@@ -627,35 +485,6 @@ function bitcoinVerifier(client, config) {
627
485
  }
628
486
  };
629
487
  }
630
- // src/bitcoin/address.ts
631
- var NETWORK_PARAMS = {
632
- mainnet: { p2pkh: 0, p2sh: 5, hrp: "bc" },
633
- testnet: { p2pkh: 111, p2sh: 196, hrp: "tb" }
634
- };
635
- function base58Check(version, payload) {
636
- const data = concatBytes(Uint8Array.of(version), payload);
637
- const checksum = doubleSha256(data).slice(0, 4);
638
- return base58.encode(concatBytes(data, checksum));
639
- }
640
- function formatBitcoinAddress(parsed, network = "mainnet") {
641
- const params = NETWORK_PARAMS[network];
642
- const hash = parsed.hash;
643
- if (!hash)
644
- return;
645
- switch (parsed.type) {
646
- case "p2pkh":
647
- return base58Check(params.p2pkh, hash);
648
- case "p2sh":
649
- return base58Check(params.p2sh, hash);
650
- case "p2wpkh":
651
- case "p2wsh":
652
- return bech32.encode(params.hrp, [0, ...bech32.toWords(hash)]);
653
- case "p2tr":
654
- return bech32m.encode(params.hrp, [1, ...bech32m.toWords(hash)]);
655
- default:
656
- return;
657
- }
658
- }
659
488
  // src/bitcoin/actions.ts
660
489
  async function verifyBitcoinPayment(client, params) {
661
490
  const {
@@ -697,5 +526,5 @@ async function verifyBitcoinPayment(client, params) {
697
526
  return { verified, mined, output, proof };
698
527
  }
699
528
 
700
- //# debugId=C9CBA2638352640064756E2164756E21
529
+ //# debugId=B0DCD31B5E33BB1664756E2164756E21
701
530
  //# sourceMappingURL=index.cjs.map
@@ -1,19 +1,17 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/bitcoin/serialize.ts", "../src/bitcoin/merkle.ts", "../src/bitcoin/proof.ts", "../src/bitcoin/codec.ts", "../src/bitcoin/constants.ts", "../src/bitcoin/abi/spvAdapter.ts", "../src/bitcoin/activation.ts", "../src/bitcoin/verifier.ts", "../src/bitcoin/address.ts", "../src/bitcoin/actions.ts"],
3
+ "sources": ["../src/bitcoin/merkle.ts", "../src/bitcoin/proof.ts", "../src/bitcoin/codec.ts", "../src/bitcoin/constants.ts", "../src/bitcoin/abi/spvAdapter.ts", "../src/bitcoin/activation.ts", "../src/bitcoin/verifier.ts", "../src/bitcoin/actions.ts"],
4
4
  "sourcesContent": [
5
- "import { concatBytes } from \"../utils/encoding.ts\";\nimport { sha256 } from \"../utils/hash.ts\";\n\n/**\n * Bitcoin double-SHA256: `sha256(sha256(bytes))`. This is the hash Bitcoin uses\n * for txids, block headers, and merkle nodes — NOT the same as the Stacks\n * `txidFromBytes` (which uses sha512_256), so it lives here, not in `utils/hash`.\n */\nexport function doubleSha256(bytes: Uint8Array): Uint8Array {\n\treturn sha256(sha256(bytes));\n}\n\n/**\n * Reverse a byte array. Bitcoin hashes are computed and stored in *internal*\n * (little-endian) order but *displayed* big-endian, so the two differ by a\n * reversal. The SIP-044 built-ins consume internal order; only reverse for\n * display / when matching an explorer value.\n */\nexport function reverseBytes(bytes: Uint8Array): Uint8Array {\n\tconst out = new Uint8Array(bytes.length);\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tout[i] = bytes[bytes.length - 1 - i] as number;\n\t}\n\treturn out;\n}\n\n/**\n * A little-endian, varint-aware byte reader for Bitcoin serialization. The\n * shared `utils/BytesReader` is big-endian only; Bitcoin tx fields are\n * little-endian with compact-size (varint) length prefixes.\n */\nexport class BtcReader {\n\tprivate readonly data: Uint8Array;\n\tprivate readonly view: DataView;\n\tpublic offset = 0;\n\n\tconstructor(data: Uint8Array) {\n\t\tthis.data = data;\n\t\tthis.view = new DataView(data.buffer, data.byteOffset, data.byteLength);\n\t}\n\n\tget length(): number {\n\t\treturn this.data.length;\n\t}\n\n\treadUInt8(): number {\n\t\tconst v = this.view.getUint8(this.offset);\n\t\tthis.offset += 1;\n\t\treturn v;\n\t}\n\n\t/** Read the next byte without advancing. */\n\tpeekUInt8(): number {\n\t\treturn this.view.getUint8(this.offset);\n\t}\n\n\treadUInt32LE(): number {\n\t\tconst v = this.view.getUint32(this.offset, true);\n\t\tthis.offset += 4;\n\t\treturn v;\n\t}\n\n\treadUInt64LE(): bigint {\n\t\tconst v = this.view.getBigUint64(this.offset, true);\n\t\tthis.offset += 8;\n\t\treturn v;\n\t}\n\n\treadBytes(n: number): Uint8Array {\n\t\tif (this.offset + n > this.data.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Bitcoin tx underflow: need ${n} bytes at offset ${this.offset}, have ${this.data.length}`,\n\t\t\t);\n\t\t}\n\t\tconst slice = this.data.slice(this.offset, this.offset + n);\n\t\tthis.offset += n;\n\t\treturn slice;\n\t}\n\n\t/** Read a Bitcoin compact-size unsigned integer (varint). */\n\treadVarInt(): number {\n\t\tconst first = this.readUInt8();\n\t\tif (first < 0xfd) return first;\n\t\tif (first === 0xfd) {\n\t\t\tconst v = this.view.getUint16(this.offset, true);\n\t\t\tthis.offset += 2;\n\t\t\treturn v;\n\t\t}\n\t\tif (first === 0xfe) {\n\t\t\treturn this.readUInt32LE();\n\t\t}\n\t\tconst big = this.readUInt64LE();\n\t\tif (big > BigInt(Number.MAX_SAFE_INTEGER)) {\n\t\t\tthrow new Error(\"Bitcoin varint exceeds safe integer range\");\n\t\t}\n\t\treturn Number(big);\n\t}\n}\n\nexport interface BitcoinTxInput {\n\t/** Previous output txid, in serialized (internal) byte order. */\n\tprevTxid: Uint8Array;\n\tvout: number;\n\tscriptSig: Uint8Array;\n\tsequence: number;\n}\n\nexport interface BitcoinTxOutput {\n\t/** Output value in satoshis. */\n\tvalue: bigint;\n\tscriptPubKey: Uint8Array;\n}\n\nexport interface ParsedBitcoinTx {\n\tversion: number;\n\thasWitness: boolean;\n\tinputs: BitcoinTxInput[];\n\toutputs: BitcoinTxOutput[];\n\tlocktime: number;\n\t/**\n\t * The legacy txid as the raw double-SHA256 in *internal* byte order — ready\n\t * to pass as the leaf to `verify-merkle-proof`. Witness data is excluded\n\t * (the txid is computed over the legacy serialization), so this is stable for\n\t * both legacy and SegWit txs. Use `reverseBytes` for the displayed form.\n\t */\n\ttxidInternal: Uint8Array;\n}\n\ninterface ScanResult {\n\tversion: number;\n\thasWitness: boolean;\n\tinputs: BitcoinTxInput[];\n\toutputs: BitcoinTxOutput[];\n\tlocktime: number;\n\t/** The legacy (witness-stripped) serialization — what the txid is hashed over. */\n\tlegacy: Uint8Array;\n}\n\n/**\n * Single-pass scan of a raw Bitcoin tx. Captures the inputs/outputs slice and\n * reassembles the legacy serialization so both `parseBitcoinTx` and\n * `stripWitness` share one parser (and one set of foot-guns).\n */\nfunction scanTx(rawTx: Uint8Array): ScanResult {\n\tconst r = new BtcReader(rawTx);\n\tconst version = r.readUInt32LE();\n\n\t// SegWit marker (0x00) + flag (0x01) sit immediately after the version. A\n\t// legacy tx can never have a zero input count, so 0x00 here is unambiguous.\n\tlet hasWitness = false;\n\tif (r.peekUInt8() === 0x00) {\n\t\tr.readUInt8(); // marker\n\t\tconst flag = r.readUInt8();\n\t\tif (flag !== 0x01) {\n\t\t\tthrow new Error(`Unexpected SegWit flag 0x${flag.toString(16)}`);\n\t\t}\n\t\thasWitness = true;\n\t}\n\n\tconst bodyStart = r.offset;\n\tconst inputCount = r.readVarInt();\n\tconst inputs: BitcoinTxInput[] = [];\n\tfor (let i = 0; i < inputCount; i++) {\n\t\tconst prevTxid = r.readBytes(32);\n\t\tconst vout = r.readUInt32LE();\n\t\tconst scriptSig = r.readBytes(r.readVarInt());\n\t\tconst sequence = r.readUInt32LE();\n\t\tinputs.push({ prevTxid, vout, scriptSig, sequence });\n\t}\n\n\tconst outputCount = r.readVarInt();\n\tconst outputs: BitcoinTxOutput[] = [];\n\tfor (let i = 0; i < outputCount; i++) {\n\t\tconst value = r.readUInt64LE();\n\t\tconst scriptPubKey = r.readBytes(r.readVarInt());\n\t\toutputs.push({ value, scriptPubKey });\n\t}\n\tconst bodyEnd = r.offset;\n\n\tif (hasWitness) {\n\t\tfor (let i = 0; i < inputCount; i++) {\n\t\t\tconst itemCount = r.readVarInt();\n\t\t\tfor (let j = 0; j < itemCount; j++) {\n\t\t\t\tr.readBytes(r.readVarInt());\n\t\t\t}\n\t\t}\n\t}\n\n\tconst locktime = r.readUInt32LE();\n\n\tconst legacy = concatBytes(\n\t\trawTx.slice(0, 4),\n\t\trawTx.slice(bodyStart, bodyEnd),\n\t\trawTx.slice(r.offset - 4, r.offset),\n\t);\n\n\treturn { version, hasWitness, inputs, outputs, locktime, legacy };\n}\n\n/** Parse a serialized Bitcoin tx (legacy or SegWit) into its fields + txid. */\nexport function parseBitcoinTx(rawTx: Uint8Array): ParsedBitcoinTx {\n\tconst s = scanTx(rawTx);\n\treturn {\n\t\tversion: s.version,\n\t\thasWitness: s.hasWitness,\n\t\tinputs: s.inputs,\n\t\toutputs: s.outputs,\n\t\tlocktime: s.locktime,\n\t\ttxidInternal: doubleSha256(s.legacy),\n\t};\n}\n\n/**\n * Return the legacy (witness-stripped) serialization of a tx. For a legacy tx\n * this is the input unchanged; for a SegWit tx the marker, flag, and witness\n * stack are removed. This is the byte string the txid is hashed over.\n */\nexport function stripWitness(rawTx: Uint8Array): Uint8Array {\n\treturn scanTx(rawTx).legacy;\n}\n\n/**\n * Compute a tx's id from its raw serialization. Internal byte order by default\n * (the merkle leaf / built-in input); pass `{ display: true }` for the\n * explorer-style big-endian form.\n */\nexport function bitcoinTxid(\n\trawTx: Uint8Array,\n\t{ display = false }: { display?: boolean } = {},\n): Uint8Array {\n\tconst txid = doubleSha256(scanTx(rawTx).legacy);\n\treturn display ? reverseBytes(txid) : txid;\n}\n\nexport interface BlockHeader {\n\tversion: number;\n\t/** Previous block hash, internal byte order. */\n\tprevBlock: Uint8Array;\n\t/** Merkle root, internal byte order — pairs with `verify-merkle-proof`. */\n\tmerkleRoot: Uint8Array;\n\ttimestamp: number;\n\tbits: number;\n\tnonce: number;\n}\n\n/** Parse an 80-byte Bitcoin block header into its fields (hashes internal order). */\nexport function parseBlockHeader(header: Uint8Array): BlockHeader {\n\tif (header.length !== 80) {\n\t\tthrow new Error(\n\t\t\t`Bitcoin block header must be 80 bytes, got ${header.length}`,\n\t\t);\n\t}\n\tconst r = new BtcReader(header);\n\tconst version = r.readUInt32LE();\n\tconst prevBlock = r.readBytes(32);\n\tconst merkleRoot = r.readBytes(32);\n\tconst timestamp = r.readUInt32LE();\n\tconst bits = r.readUInt32LE();\n\tconst nonce = r.readUInt32LE();\n\treturn { version, prevBlock, merkleRoot, timestamp, bits, nonce };\n}\n\n/**\n * Hash an 80-byte block header (double-SHA256). Internal byte order by default;\n * `{ display: true }` for the explorer-style block hash.\n */\nexport function blockHash(\n\theader: Uint8Array,\n\t{ display = false }: { display?: boolean } = {},\n): Uint8Array {\n\tconst hash = doubleSha256(header);\n\treturn display ? reverseBytes(hash) : hash;\n}\n",
6
5
  "import { concatBytes } from \"../utils/encoding.ts\";\nimport { doubleSha256 } from \"./serialize.ts\";\n\n/**\n * A Bitcoin merkle inclusion proof, shaped for the SIP-044 `verify-merkle-proof`\n * built-in: `(leaf-hash, root-hash, tx-index, tx-count, sibling-hashes)`.\n *\n * - `siblings` are the sibling node hashes from the leaf up to (excluding) the\n * root, in *internal* byte order — never reversed.\n * - `txCount` (not tree-depth) pins the canonical tree shape; the built-in\n * rejects any proof whose length differs from `ceil(log2(tx-count))`.\n */\nexport interface MerkleProof {\n\tsiblings: Uint8Array[];\n\ttxIndex: number;\n\ttxCount: number;\n}\n\n/** Combine an ordered pair of nodes into their parent hash. */\nfunction hashPair(left: Uint8Array, right: Uint8Array): Uint8Array {\n\treturn doubleSha256(concatBytes(left, right));\n}\n\n/** Collapse one merkle level into the next, duplicating the last node if odd. */\nfunction nextLevel(level: Uint8Array[]): Uint8Array[] {\n\tconst next: Uint8Array[] = [];\n\tfor (let i = 0; i < level.length; i += 2) {\n\t\tconst left = level[i];\n\t\tif (left === undefined) throw new Error(\"merkle: missing left node\");\n\t\t// Bitcoin duplicates the final node when a level has an odd count.\n\t\tconst right = level[i + 1] ?? left;\n\t\tnext.push(hashPair(left, right));\n\t}\n\treturn next;\n}\n\n/**\n * Compute the merkle root over txids in *internal* byte order. The result is\n * also internal order — it matches the `merkle-root` field read straight out of\n * an 80-byte block header, so it can be cross-checked against the header before\n * a proof is trusted.\n */\nexport function merkleRoot(txidsInternal: Uint8Array[]): Uint8Array {\n\tif (txidsInternal.length === 0) {\n\t\tthrow new Error(\"merkleRoot: empty tx list\");\n\t}\n\tlet level = txidsInternal.slice();\n\twhile (level.length > 1) {\n\t\tlevel = nextLevel(level);\n\t}\n\tconst root = level[0];\n\tif (root === undefined) throw new Error(\"merkleRoot: no root\");\n\treturn root;\n}\n\n/**\n * Build the merkle inclusion proof for the tx at `txIndex`. Sibling count is\n * exactly `ceil(log2(txCount))`, as the SIP-044 built-in requires.\n */\nexport function buildMerkleProof(\n\ttxidsInternal: Uint8Array[],\n\ttxIndex: number,\n): MerkleProof {\n\tconst txCount = txidsInternal.length;\n\tif (txCount === 0) {\n\t\tthrow new Error(\"buildMerkleProof: empty tx list\");\n\t}\n\tif (txIndex < 0 || txIndex >= txCount) {\n\t\tthrow new Error(\n\t\t\t`buildMerkleProof: txIndex ${txIndex} out of range for ${txCount} txs`,\n\t\t);\n\t}\n\n\tconst siblings: Uint8Array[] = [];\n\tlet index = txIndex;\n\tlet level = txidsInternal.slice();\n\twhile (level.length > 1) {\n\t\tconst isRight = index % 2 === 1;\n\t\tconst siblingIndex = isRight ? index - 1 : index + 1;\n\t\tconst self = level[index];\n\t\tif (self === undefined) throw new Error(\"buildMerkleProof: missing node\");\n\t\t// When the node is the last of an odd level, it is paired with itself.\n\t\tsiblings.push(level[siblingIndex] ?? self);\n\t\tlevel = nextLevel(level);\n\t\tindex = Math.floor(index / 2);\n\t}\n\n\treturn { siblings, txIndex, txCount };\n}\n\n/**\n * Recompute the merkle root from a leaf + its proof — the same fold the on-chain\n * `verify-merkle-proof` performs. Use it off-chain to self-check a constructed\n * proof against the header's merkle root before submitting a contract call.\n */\nexport function rootFromProof(\n\tleafInternal: Uint8Array,\n\tproof: MerkleProof,\n): Uint8Array {\n\tlet hash = leafInternal;\n\tlet index = proof.txIndex;\n\tfor (const sibling of proof.siblings) {\n\t\thash = index % 2 === 1 ? hashPair(sibling, hash) : hashPair(hash, sibling);\n\t\tindex = Math.floor(index / 2);\n\t}\n\treturn hash;\n}\n",
7
6
  "import { bytesToHex, hexToBytes, without0x } from \"../utils/encoding.ts\";\nimport { type MerkleProof, buildMerkleProof, rootFromProof } from \"./merkle.ts\";\nimport { parseBitcoinTx, parseBlockHeader, reverseBytes } from \"./serialize.ts\";\n\n/**\n * A self-contained Bitcoin SPV proof: everything the SIP-044 built-ins need to\n * prove a tx (and one of its outputs) is committed in a confirmed block. Hashes\n * are internal byte order throughout.\n */\nexport interface SpvProof {\n\trawTx: Uint8Array;\n\t/** The tx's txid, internal order — the merkle leaf. */\n\ttxidInternal: Uint8Array;\n\t/** Output index of interest, if the proof targets a specific output. */\n\tvout?: number;\n\tmerkle: MerkleProof;\n\t/** The 80-byte block header that commits the tx. */\n\theader: Uint8Array;\n\t/** Bitcoin block height. */\n\theight: number;\n}\n\n/** The block context a `ProofSource` resolves for a confirmed tx. */\nexport interface BlockForTx {\n\t/** 80-byte block header. */\n\theader: Uint8Array;\n\theight: number;\n\t/** All of the block's txids, internal order, in block order. */\n\ttxidsInternal: Uint8Array[];\n\t/** Index of the target tx within the block. */\n\ttxIndex: number;\n}\n\n/**\n * Where proof inputs come from. The default is the integrator's own Bitcoin node\n * (`bitcoinRpcSource`) — trustless; a hosted Esplora-compatible endpoint\n * (`esploraSource`) is the fallback. `buildTxProof` independently re-checks\n * whatever a source returns, so a wrong or hostile source fails loudly rather\n * than producing a bad proof.\n */\nexport interface ProofSource {\n\t/** Raw (serialized) tx bytes for a txid (display-order hex). */\n\tgetRawTx(txid: string): Promise<Uint8Array>;\n\t/** The confirming block's header, height, and txid set for a txid. */\n\tgetBlockForTx(txid: string): Promise<BlockForTx>;\n}\n\nfunction normalizeTxid(txid: string): string {\n\treturn without0x(txid).toLowerCase();\n}\n\n/**\n * Locate `txid` in a block's txid set and assemble its `BlockForTx`. Owns the\n * display→internal byte-order reversal (`reverseBytes`) so the ProofSources\n * can't drift on the one operation a silent merkle-root mismatch would hide.\n * `txidsDisplay` are display-order hex txids as returned by Core / Esplora.\n */\nfunction assembleBlockForTx(args: {\n\ttxid: string;\n\tblockId: string;\n\theaderHex: string;\n\theight: number;\n\ttxidsDisplay: string[];\n}): BlockForTx {\n\tconst txIndex = args.txidsDisplay.indexOf(normalizeTxid(args.txid));\n\tif (txIndex < 0) {\n\t\tthrow new Error(`tx ${args.txid} not found in block ${args.blockId}`);\n\t}\n\treturn {\n\t\theader: hexToBytes(args.headerHex),\n\t\theight: args.height,\n\t\ttxidsInternal: args.txidsDisplay.map((t) => reverseBytes(hexToBytes(t))),\n\t\ttxIndex,\n\t};\n}\n\n/**\n * Assemble an `SpvProof` for a txid from a `ProofSource`, validating every claim\n * the source makes:\n * - the returned raw tx actually hashes to the requested txid,\n * - the claimed `txIndex` points at that txid in the block, and\n * - the resulting merkle proof folds back to the block header's merkle root.\n * Any mismatch throws — the proof is never returned half-trusted.\n */\nexport async function buildTxProof(\n\tsource: ProofSource,\n\tparams: { txid: string; vout?: number },\n): Promise<SpvProof> {\n\tconst { txid, vout } = params;\n\tconst want = normalizeTxid(txid);\n\n\tconst [rawTx, block] = await Promise.all([\n\t\tsource.getRawTx(txid),\n\t\tsource.getBlockForTx(txid),\n\t]);\n\n\tconst parsed = parseBitcoinTx(rawTx);\n\tconst gotDisplay = bytesToHex(reverseBytes(parsed.txidInternal));\n\tif (gotDisplay !== want) {\n\t\tthrow new Error(\n\t\t\t`source returned a tx whose id ${gotDisplay} does not match requested ${want}`,\n\t\t);\n\t}\n\n\tconst atIndex = block.txidsInternal[block.txIndex];\n\tif (!atIndex || bytesToHex(atIndex) !== bytesToHex(parsed.txidInternal)) {\n\t\tthrow new Error(\n\t\t\t`source txIndex ${block.txIndex} does not point at tx ${want}`,\n\t\t);\n\t}\n\n\tconst merkle = buildMerkleProof(block.txidsInternal, block.txIndex);\n\n\tconst headerRoot = parseBlockHeader(block.header).merkleRoot;\n\tconst computed = rootFromProof(parsed.txidInternal, merkle);\n\tif (bytesToHex(computed) !== bytesToHex(headerRoot)) {\n\t\tthrow new Error(\n\t\t\t\"constructed merkle proof does not reconcile with the block header merkle root\",\n\t\t);\n\t}\n\n\treturn {\n\t\trawTx,\n\t\ttxidInternal: parsed.txidInternal,\n\t\tvout,\n\t\tmerkle,\n\t\theader: block.header,\n\t\theight: block.height,\n\t};\n}\n\n/**\n * Compose sources into an ordered fallback chain: each call tries them in turn\n * and returns the first success, throwing the last error if all fail. Put the\n * trustless integrator node first and a hosted endpoint last.\n */\nexport function fallbackProofSource(sources: ProofSource[]): ProofSource {\n\tif (sources.length === 0) {\n\t\tthrow new Error(\"fallbackProofSource: at least one source is required\");\n\t}\n\tasync function firstSuccess<T>(\n\t\tfn: (s: ProofSource) => Promise<T>,\n\t): Promise<T> {\n\t\tlet lastError: unknown;\n\t\tfor (const source of sources) {\n\t\t\ttry {\n\t\t\t\treturn await fn(source);\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error;\n\t\t\t}\n\t\t}\n\t\tthrow lastError;\n\t}\n\treturn {\n\t\tgetRawTx: (txid) => firstSuccess((s) => s.getRawTx(txid)),\n\t\tgetBlockForTx: (txid) => firstSuccess((s) => s.getBlockForTx(txid)),\n\t};\n}\n\nexport interface BitcoinRpcConfig {\n\t/** Bitcoin Core JSON-RPC endpoint URL. */\n\turl: string;\n\t/** Basic auth — `{ username, password }` or a pre-encoded base64 string. */\n\tauth?: { username: string; password: string } | string;\n\t/** Override the fetch implementation (testing / custom agents). */\n\tfetch?: typeof fetch;\n}\n\n/**\n * A `ProofSource` backed by the integrator's own Bitcoin Core node over\n * JSON-RPC. This is the trustless default. The node must run with `-txindex`\n * (or the tx must be in the mempool's block view) so `getrawtransaction` can\n * resolve the confirming block.\n */\nexport function bitcoinRpcSource(config: BitcoinRpcConfig): ProofSource {\n\tconst doFetch = config.fetch ?? fetch;\n\n\tasync function rpc<T>(method: string, rpcParams: unknown[]): Promise<T> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"content-type\": \"application/json\",\n\t\t};\n\t\tif (config.auth) {\n\t\t\tconst basic =\n\t\t\t\ttypeof config.auth === \"string\"\n\t\t\t\t\t? config.auth\n\t\t\t\t\t: btoa(`${config.auth.username}:${config.auth.password}`);\n\t\t\theaders.authorization = `Basic ${basic}`;\n\t\t}\n\t\tconst res = await doFetch(config.url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders,\n\t\t\tbody: JSON.stringify({\n\t\t\t\tjsonrpc: \"1.0\",\n\t\t\t\tid: \"secondlayer\",\n\t\t\t\tmethod,\n\t\t\t\tparams: rpcParams,\n\t\t\t}),\n\t\t});\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`bitcoin rpc ${method} failed: HTTP ${res.status}`);\n\t\t}\n\t\tconst json = (await res.json()) as {\n\t\t\tresult: T;\n\t\t\terror: { message: string } | null;\n\t\t};\n\t\tif (json.error) {\n\t\t\tthrow new Error(`bitcoin rpc ${method} error: ${json.error.message}`);\n\t\t}\n\t\treturn json.result;\n\t}\n\n\treturn {\n\t\tasync getRawTx(txid) {\n\t\t\treturn hexToBytes(await rpc<string>(\"getrawtransaction\", [txid, false]));\n\t\t},\n\t\tasync getBlockForTx(txid) {\n\t\t\tconst tx = await rpc<{ blockhash?: string }>(\"getrawtransaction\", [\n\t\t\t\ttxid,\n\t\t\t\ttrue,\n\t\t\t]);\n\t\t\tif (!tx.blockhash) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`tx ${txid} is not in a block (node needs -txindex, or the tx is unconfirmed)`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst block = await rpc<{ tx: string[]; height: number }>(\"getblock\", [\n\t\t\t\ttx.blockhash,\n\t\t\t\t1,\n\t\t\t]);\n\t\t\tconst header = await rpc<string>(\"getblockheader\", [tx.blockhash, false]);\n\t\t\treturn assembleBlockForTx({\n\t\t\t\ttxid,\n\t\t\t\tblockId: tx.blockhash,\n\t\t\t\theaderHex: header,\n\t\t\t\theight: block.height,\n\t\t\t\ttxidsDisplay: block.tx,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport interface EsploraConfig {\n\t/** Esplora REST base URL, e.g. `https://blockstream.info/api` or a self-hosted instance. */\n\turl: string;\n\t/** Override the fetch implementation. */\n\tfetch?: typeof fetch;\n}\n\n/**\n * A `ProofSource` backed by an Esplora REST API (self-hosted, or a hosted\n * provider as a fallback). Provider-agnostic: any Esplora-compatible endpoint\n * works. Use as the hosted fallback behind `bitcoinRpcSource`.\n */\nexport function esploraSource(config: EsploraConfig): ProofSource {\n\tconst doFetch = config.fetch ?? fetch;\n\tconst base = config.url.replace(/\\/+$/, \"\");\n\n\tasync function get(path: string): Promise<Response> {\n\t\tconst res = await doFetch(`${base}${path}`);\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`esplora GET ${path} failed: HTTP ${res.status}`);\n\t\t}\n\t\treturn res;\n\t}\n\n\treturn {\n\t\tasync getRawTx(txid) {\n\t\t\treturn hexToBytes((await (await get(`/tx/${txid}/hex`)).text()).trim());\n\t\t},\n\t\tasync getBlockForTx(txid) {\n\t\t\tconst status = (await (await get(`/tx/${txid}`)).json()) as {\n\t\t\t\tstatus: {\n\t\t\t\t\tconfirmed: boolean;\n\t\t\t\t\tblock_height: number;\n\t\t\t\t\tblock_hash: string;\n\t\t\t\t};\n\t\t\t};\n\t\t\tif (!status.status.confirmed) {\n\t\t\t\tthrow new Error(`tx ${txid} is unconfirmed`);\n\t\t\t}\n\t\t\tconst blockHashHex = status.status.block_hash;\n\t\t\tconst header = (\n\t\t\t\tawait (await get(`/block/${blockHashHex}/header`)).text()\n\t\t\t).trim();\n\t\t\tconst txids = (await (\n\t\t\t\tawait get(`/block/${blockHashHex}/txids`)\n\t\t\t).json()) as string[];\n\t\t\treturn assembleBlockForTx({\n\t\t\t\ttxid,\n\t\t\t\tblockId: blockHashHex,\n\t\t\t\theaderHex: header,\n\t\t\t\theight: status.status.block_height,\n\t\t\t\ttxidsDisplay: txids,\n\t\t\t});\n\t\t},\n\t};\n}\n",
8
7
  "import {\n\ttype BufferCV,\n\ttype ClarityValue,\n\ttype ListCV,\n\ttype TupleCV,\n\ttype UIntCV,\n\tbufferCV,\n\tlistCV,\n\tuintCV,\n} from \"../clarity/index.ts\";\nimport { hexToBytes } from \"../utils/encoding.ts\";\nimport type { MerkleProof } from \"./merkle.ts\";\n\n/**\n * Number of merkle levels for a tree of `txCount` leaves — i.e. the exact\n * sibling count the SIP-044 `verify-merkle-proof` built-in expects\n * (`ceil(log2(tx-count))`). Computed by repeated halving to avoid float error\n * at exact powers of two.\n */\nfunction merkleDepth(txCount: number): number {\n\tlet depth = 0;\n\tlet n = txCount;\n\twhile (n > 1) {\n\t\tn = Math.ceil(n / 2);\n\t\tdepth++;\n\t}\n\treturn depth;\n}\n\n/** Max siblings the native `verify-merkle-proof` accepts: `(list 24 (buff 32))`. */\nconst MAX_SIBLINGS = 24;\n\nfunction assertHash32(bytes: Uint8Array, label: string): void {\n\tif (bytes.length !== 32) {\n\t\tthrow new Error(`${label} must be 32 bytes, got ${bytes.length}`);\n\t}\n}\n\n/**\n * Encode the argument vector for the SIP-044 native built-in\n * `(verify-merkle-proof leaf-hash root-hash tx-index tx-count sibling-hashes)`.\n *\n * Returns the five args in order: `[leaf, root, tx-index, tx-count, siblings]`.\n * All hashes are passed in *internal* (raw) byte order — the built-in does NOT\n * reverse, and neither does this. The leaf is the tx's `txidInternal`; the root\n * is the block header's merkle root in internal order.\n *\n * Throws on shapes the built-in would reject, so a caller fails locally with a\n * clear message instead of an opaque on-chain `false`.\n */\nexport function encodeMerkleProofArgs(params: {\n\tleaf: Uint8Array;\n\troot: Uint8Array;\n\tproof: MerkleProof;\n}): [BufferCV, BufferCV, UIntCV, UIntCV, ListCV] {\n\tconst { leaf, root, proof } = params;\n\tassertHash32(leaf, \"merkle leaf\");\n\tassertHash32(root, \"merkle root\");\n\n\tif (proof.txIndex < 0 || proof.txIndex >= proof.txCount) {\n\t\tthrow new Error(\n\t\t\t`tx-index ${proof.txIndex} out of range for tx-count ${proof.txCount}`,\n\t\t);\n\t}\n\tif (proof.siblings.length > MAX_SIBLINGS) {\n\t\tthrow new Error(\n\t\t\t`proof has ${proof.siblings.length} siblings, native verify-merkle-proof caps at ${MAX_SIBLINGS}`,\n\t\t);\n\t}\n\tconst expectedDepth = merkleDepth(proof.txCount);\n\tif (proof.siblings.length !== expectedDepth) {\n\t\tthrow new Error(\n\t\t\t`proof has ${proof.siblings.length} siblings but tx-count ${proof.txCount} requires exactly ${expectedDepth}`,\n\t\t);\n\t}\n\tfor (const [i, sibling] of proof.siblings.entries()) {\n\t\tassertHash32(sibling, `sibling ${i}`);\n\t}\n\n\treturn [\n\t\tbufferCV(leaf),\n\t\tbufferCV(root),\n\t\tuintCV(proof.txIndex),\n\t\tuintCV(proof.txCount),\n\t\tlistCV(proof.siblings.map((s) => bufferCV(s))),\n\t];\n}\n\nexport interface DecodedTxOutput {\n\t/** scriptPubKey bytes. */\n\tscript: Uint8Array;\n\t/** Output value in satoshis. */\n\tamount: bigint;\n\t/** The tx's txid in internal byte order — ready as a merkle leaf. */\n\ttxid: Uint8Array;\n}\n\nfunction expectBuffer(cv: ClarityValue | undefined, label: string): Uint8Array {\n\tif (cv?.type !== \"buffer\") {\n\t\tthrow new Error(`expected ${label} to be a buffer, got ${cv?.type}`);\n\t}\n\treturn hexToBytes(cv.value);\n}\n\n/**\n * Decode the tuple returned by `get-bitcoin-tx-output?`:\n * `(tuple (script (buff 1024)) (amount uint) (txid (buff 32)))`.\n *\n * Accepts either the bare tuple or a `(response ok ...)` wrapping it, so it\n * works whether or not the caller has already unwrapped the response.\n */\nexport function decodeTxOutput(cv: ClarityValue): DecodedTxOutput {\n\tconst tuple: ClarityValue = cv.type === \"ok\" ? cv.value : cv;\n\tif (tuple.type !== \"tuple\") {\n\t\tthrow new Error(`expected a tuple, got ${tuple.type}`);\n\t}\n\tconst fields = (tuple as TupleCV).value;\n\tconst amount = fields.amount;\n\tif (amount?.type !== \"uint\") {\n\t\tthrow new Error(\n\t\t\t`expected tuple field \"amount\" to be uint, got ${amount?.type}`,\n\t\t);\n\t}\n\treturn {\n\t\tscript: expectBuffer(fields.script, 'tuple field \"script\"'),\n\t\tamount: amount.value,\n\t\ttxid: expectBuffer(fields.txid, 'tuple field \"txid\"'),\n\t};\n}\n\nexport type OutputScriptType =\n\t| \"p2pkh\"\n\t| \"p2sh\"\n\t| \"p2wpkh\"\n\t| \"p2wsh\"\n\t| \"p2tr\"\n\t| \"op_return\"\n\t| \"unknown\";\n\nexport interface ParsedOutputScript {\n\ttype: OutputScriptType;\n\t/**\n\t * The hash / witness program for the recognized output types: the 20-byte\n\t * pubkey-hash (p2pkh), 20-byte script-hash (p2sh), or the 20/32-byte witness\n\t * program (p2wpkh/p2wsh/p2tr). Undefined for op_return / unknown.\n\t *\n\t * Address formatting is intentionally left to the caller — base58/bech32 HRPs\n\t * and version bytes are network-dependent, so it belongs where the network is\n\t * known (see `verifyBitcoinPayment`), not in this pure decoder.\n\t */\n\thash?: Uint8Array;\n\t/** OP_RETURN payload (the pushed data after the OP_RETURN opcode). */\n\tdata?: Uint8Array;\n}\n\nconst OP_DUP = 0x76;\nconst OP_HASH160 = 0xa9;\nconst OP_EQUALVERIFY = 0x88;\nconst OP_CHECKSIG = 0xac;\nconst OP_EQUAL = 0x87;\nconst OP_RETURN = 0x6a;\nconst OP_0 = 0x00;\nconst OP_1 = 0x51;\n\n/**\n * Classify a Bitcoin output scriptPubKey by its standard template and surface\n * the embedded hash / witness program. Recognizes P2PKH, P2SH, P2WPKH, P2WSH,\n * P2TR, and OP_RETURN; anything else is `unknown`.\n */\nexport function parseOutputScript(script: Uint8Array): ParsedOutputScript {\n\tconst n = script.length;\n\n\t// P2PKH: OP_DUP OP_HASH160 <20> ... OP_EQUALVERIFY OP_CHECKSIG\n\tif (\n\t\tn === 25 &&\n\t\tscript[0] === OP_DUP &&\n\t\tscript[1] === OP_HASH160 &&\n\t\tscript[2] === 0x14 &&\n\t\tscript[23] === OP_EQUALVERIFY &&\n\t\tscript[24] === OP_CHECKSIG\n\t) {\n\t\treturn { type: \"p2pkh\", hash: script.slice(3, 23) };\n\t}\n\n\t// P2SH: OP_HASH160 <20> ... OP_EQUAL\n\tif (\n\t\tn === 23 &&\n\t\tscript[0] === OP_HASH160 &&\n\t\tscript[1] === 0x14 &&\n\t\tscript[22] === OP_EQUAL\n\t) {\n\t\treturn { type: \"p2sh\", hash: script.slice(2, 22) };\n\t}\n\n\t// P2WPKH: OP_0 <20>\n\tif (n === 22 && script[0] === OP_0 && script[1] === 0x14) {\n\t\treturn { type: \"p2wpkh\", hash: script.slice(2, 22) };\n\t}\n\n\t// P2WSH: OP_0 <32>\n\tif (n === 34 && script[0] === OP_0 && script[1] === 0x20) {\n\t\treturn { type: \"p2wsh\", hash: script.slice(2, 34) };\n\t}\n\n\t// P2TR: OP_1 <32>\n\tif (n === 34 && script[0] === OP_1 && script[1] === 0x20) {\n\t\treturn { type: \"p2tr\", hash: script.slice(2, 34) };\n\t}\n\n\t// OP_RETURN: data carrier\n\tif (n >= 1 && script[0] === OP_RETURN) {\n\t\treturn { type: \"op_return\", data: script.slice(1) };\n\t}\n\n\treturn { type: \"unknown\" };\n}\n",
9
- "export type BitcoinNetwork = \"mainnet\" | \"testnet\";\n\nexport interface SpvAdapterRef {\n\t/** Deployer principal. */\n\taddress: string;\n\t/** Contract name. */\n\tname: string;\n}\n\n/**\n * Reference `spv-adapter` deployments (the read-only wrapper around the SIP-044\n * built-ins) — the single source of truth for the published adapter principal.\n * Empty until Clarity 6 / Epoch 4.0 activates and the contract is deployed; drop\n * the real principal in here at that point (deploy recipe: `contracts/README.md`).\n * Until then, `verifyBitcoinPayment` requires an explicit `contract`.\n */\nexport const SPV_ADAPTER_CONTRACTS: Partial<\n\tRecord<BitcoinNetwork, SpvAdapterRef>\n> = {\n\t// mainnet: { address: \"SP...\", name: \"spv-adapter\" }, // pending plan 013 deploy\n\t// testnet: { address: \"ST...\", name: \"spv-adapter\" },\n};\n\n/** Resolve the reference adapter for a network, or `undefined` if none is deployed yet. */\nexport function getSpvAdapter(\n\tnetwork: BitcoinNetwork,\n): SpvAdapterRef | undefined {\n\treturn SPV_ADAPTER_CONTRACTS[network];\n}\n\n/** A `\"address.name\"` contract principal from an adapter ref. */\nexport function spvAdapterPrincipal(ref: SpvAdapterRef): string {\n\treturn `${ref.address}.${ref.name}`;\n}\n",
8
+ "export type BitcoinNetwork = \"mainnet\" | \"testnet\" | \"regtest\";\n\nexport interface SpvAdapterRef {\n\t/** Deployer principal. */\n\taddress: string;\n\t/** Contract name. */\n\tname: string;\n}\n\n/**\n * Reference `spv-adapter` deployments (the read-only wrapper around the SIP-044\n * built-ins) — the single source of truth for the published adapter principal.\n * Empty until Clarity 6 / Epoch 4.0 activates and the contract is deployed; drop\n * the real principal in here at that point (deploy recipe: `contracts/README.md`).\n * Until then, `verifyBitcoinPayment` requires an explicit `contract`.\n */\nexport const SPV_ADAPTER_CONTRACTS: Partial<\n\tRecord<BitcoinNetwork, SpvAdapterRef>\n> = {\n\t// mainnet: { address: \"SP...\", name: \"spv-adapter\" }, // pending plan 013 deploy\n\t// testnet: { address: \"ST...\", name: \"spv-adapter\" },\n};\n\n/** Resolve the reference adapter for a network, or `undefined` if none is deployed yet. */\nexport function getSpvAdapter(\n\tnetwork: BitcoinNetwork,\n): SpvAdapterRef | undefined {\n\treturn SPV_ADAPTER_CONTRACTS[network];\n}\n\n/** A `\"address.name\"` contract principal from an adapter ref. */\nexport function spvAdapterPrincipal(ref: SpvAdapterRef): string {\n\treturn `${ref.address}.${ref.name}`;\n}\n",
10
9
  "import type { AbiContract } from \"../../clarity/abi/index.ts\";\n\n/**\n * ABI for the reference `spv-adapter` contract — a thin, read-only wrapper that\n * exposes the SIP-044 Bitcoin built-ins (callable only from within a Clarity\n * contract) over read-only RPC. Plan 013 deploys a contract matching this shape;\n * `bitcoinVerifier` binds to it (or to an integrator's own contract with the\n * same surface).\n *\n * Hashes are internal (raw) byte order — the same as the built-ins. Do NOT\n * reverse before calling.\n */\nexport const SPV_ADAPTER_ABI = {\n\tfunctions: [\n\t\t{\n\t\t\t// (get-bitcoin-tx-output? tx vout)\n\t\t\tname: \"get-tx-output\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"tx\", type: { buff: { length: 4096 } } },\n\t\t\t\t{ name: \"vout\", type: \"uint128\" },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"script\", type: { buff: { length: 1024 } } },\n\t\t\t\t\t\t\t{ name: \"amount\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"txid\", type: { buff: { length: 32 } } },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t// (verify-merkle-proof leaf-hash root-hash tx-index tx-count sibling-hashes)\n\t\t\tname: \"verify-merkle\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"leaf\", type: { buff: { length: 32 } } },\n\t\t\t\t{ name: \"root\", type: { buff: { length: 32 } } },\n\t\t\t\t{ name: \"tx-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"tx-count\", type: \"uint128\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"siblings\",\n\t\t\t\t\ttype: { list: { type: { buff: { length: 32 } }, length: 24 } },\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: \"bool\",\n\t\t},\n\t\t{\n\t\t\t// Composed SPV check: authenticate the caller-supplied header against\n\t\t\t// `(get-burn-block-info? header-hash height)`, extract its merkle root,\n\t\t\t// and `verify-merkle-proof` tx inclusion under it — atomically on-chain.\n\t\t\t// (ok true) = mined, (ok false) = header valid but tx not included,\n\t\t\t// (err ...) = header not authentic at that height.\n\t\t\tname: \"was-tx-mined\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"header\", type: { buff: { length: 80 } } },\n\t\t\t\t{ name: \"height\", type: \"uint128\" },\n\t\t\t\t{ name: \"leaf\", type: { buff: { length: 32 } } },\n\t\t\t\t{ name: \"tx-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"tx-count\", type: \"uint128\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"siblings\",\n\t\t\t\t\ttype: { list: { type: { buff: { length: 32 } }, length: 24 } },\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: { response: { ok: \"bool\", error: \"uint128\" } },\n\t\t},\n\t],\n} as const satisfies AbiContract;\n",
11
10
  "import type { Client } from \"../clients/types.ts\";\n\n/**\n * SIP-044 (the native Bitcoin SPV built-ins) activates as part of the **Stacks\n * Epoch 4.0 hard fork**. The exact activation Bitcoin block height is only\n * selected after the SIP vote passes, so there is no constant to hardcode — a\n * caller passes it once it is known.\n */\nexport interface Clarity6Gate {\n\t/**\n\t * Bitcoin burn block height at which Clarity 6 / Epoch 4.0 activates. Pass it\n\t * once the vote selects it; until then `isClarity6Active` cannot answer and\n\t * throws.\n\t */\n\tactivationBurnHeight?: number;\n}\n\n/** Read the node's current Bitcoin burn block height from `/v2/info`. */\nexport async function getBurnBlockHeight(client: Client): Promise<number> {\n\tconst info = (await client.request(\"/v2/info\")) as {\n\t\tburn_block_height?: number;\n\t};\n\tif (typeof info?.burn_block_height !== \"number\") {\n\t\tthrow new Error(\"could not read burn_block_height from /v2/info\");\n\t}\n\treturn info.burn_block_height;\n}\n\n/**\n * Whether Clarity 6 (the native SPV built-ins) is active on the node behind\n * `client`. Compares the node's current burn height to the SIP-044 / Epoch 4.0\n * activation height, which must be supplied (it is unknown until the vote — see\n * `Clarity6Gate`). `bitcoinVerifier` uses this to refuse calls before activation\n * rather than failing with an opaque contract error.\n */\nexport async function isClarity6Active(\n\tclient: Client,\n\tgate: Clarity6Gate = {},\n): Promise<boolean> {\n\tif (gate.activationBurnHeight == null) {\n\t\tthrow new Error(\n\t\t\t\"Clarity 6 (SIP-044 / Epoch 4.0) activation burn height is not yet known — pass { activationBurnHeight } once the vote selects it\",\n\t\t);\n\t}\n\tconst current = await getBurnBlockHeight(client);\n\treturn current >= gate.activationBurnHeight;\n}\n",
12
11
  "import { readContract } from \"../actions/public/readContract.ts\";\nimport {\n\ttype ClarityValue,\n\tbufferCV,\n\tlistCV,\n\tuintCV,\n} from \"../clarity/index.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport {\n\ttype DecodedTxOutput,\n\tdecodeTxOutput,\n\tencodeMerkleProofArgs,\n} from \"./codec.ts\";\nimport type { MerkleProof } from \"./merkle.ts\";\nimport type { SpvProof } from \"./proof.ts\";\nimport { parseBlockHeader } from \"./serialize.ts\";\n\nexport interface BitcoinVerifierConfig {\n\t/** Adapter contract principal, `\"address.name\"` (the reference `spv-adapter` or an integrator's own). */\n\tcontract: string;\n\t/** Optional read-only call sender; defaults to the contract address. */\n\tsender?: string;\n}\n\nexport interface BitcoinVerifier {\n\t/**\n\t * Verify a merkle inclusion proof against a supplied root via the adapter's\n\t * `verify-merkle` (the native `verify-merkle-proof`). This proves membership\n\t * under `root`; authenticating that `root` belongs to a canonical Bitcoin\n\t * block is a separate step (header → height), composed in `verifyBitcoinPayment`.\n\t */\n\tverifyMerkleProof(input: {\n\t\tleaf: Uint8Array;\n\t\troot: Uint8Array;\n\t\tproof: MerkleProof;\n\t}): Promise<boolean>;\n\t/** Verify an `SpvProof`'s merkle inclusion against its own header root (membership only — not chain-authenticated). */\n\tverifySpvProof(proof: SpvProof): Promise<boolean>;\n\t/**\n\t * Full header-authenticated SPV check via the adapter's `was-tx-mined`: the\n\t * contract authenticates the proof's header against the chain\n\t * (`get-burn-block-info? header-hash`), extracts its root, and proves\n\t * inclusion — atomically. Returns `false` if the header isn't canonical at\n\t * its height or the tx isn't included. This is the real \"is it on Bitcoin\" check.\n\t */\n\twasTxMined(proof: SpvProof): Promise<boolean>;\n\t/**\n\t * Decode one output of a serialized Bitcoin tx via the adapter's\n\t * `get-tx-output` (the native `get-bitcoin-tx-output?`).\n\t */\n\tgetTxOutput(rawTx: Uint8Array, vout: number): Promise<DecodedTxOutput>;\n}\n\nfunction clarityToBool(cv: ClarityValue): boolean {\n\tconst value = cv.type === \"ok\" ? cv.value : cv;\n\tif (value.type === \"true\") return true;\n\tif (value.type === \"false\") return false;\n\tthrow new Error(`expected a boolean result, got ${value.type}`);\n}\n\n/**\n * Bind a `BitcoinVerifier` to a deployed adapter contract. There is a single,\n * native target — no caps and no legacy `clarity-bitcoin` path. The built-ins do\n * not exist until Clarity 6 / Epoch 4.0 activates, so read-only calls only\n * succeed on a node at that epoch (a local Clarity-6 devnet, or mainnet after\n * activation); guard with `isClarity6Active` when in doubt.\n */\nexport function bitcoinVerifier(\n\tclient: Client,\n\tconfig: BitcoinVerifierConfig,\n): BitcoinVerifier {\n\tconst { contract, sender } = config;\n\n\tasync function verifyMerkleProof(input: {\n\t\tleaf: Uint8Array;\n\t\troot: Uint8Array;\n\t\tproof: MerkleProof;\n\t}): Promise<boolean> {\n\t\tconst args = encodeMerkleProofArgs(input);\n\t\tconst result = await readContract(client, {\n\t\t\tcontract,\n\t\t\tfunctionName: \"verify-merkle\",\n\t\t\targs,\n\t\t\tsender,\n\t\t});\n\t\treturn clarityToBool(result);\n\t}\n\n\treturn {\n\t\tverifyMerkleProof,\n\t\tverifySpvProof(proof) {\n\t\t\tconst root = parseBlockHeader(proof.header).merkleRoot;\n\t\t\treturn verifyMerkleProof({\n\t\t\t\tleaf: proof.txidInternal,\n\t\t\t\troot,\n\t\t\t\tproof: proof.merkle,\n\t\t\t});\n\t\t},\n\t\tasync wasTxMined(proof) {\n\t\t\tconst result = await readContract(client, {\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: \"was-tx-mined\",\n\t\t\t\targs: [\n\t\t\t\t\tbufferCV(proof.header),\n\t\t\t\t\tuintCV(proof.height),\n\t\t\t\t\tbufferCV(proof.txidInternal),\n\t\t\t\t\tuintCV(proof.merkle.txIndex),\n\t\t\t\t\tuintCV(proof.merkle.txCount),\n\t\t\t\t\tlistCV(proof.merkle.siblings.map((s) => bufferCV(s))),\n\t\t\t\t],\n\t\t\t\tsender,\n\t\t\t});\n\t\t\t// (response bool uint): (ok true) mined, (ok false) not, (err) bad header → fail closed.\n\t\t\tif (result.type === \"err\") return false;\n\t\t\treturn clarityToBool(result);\n\t\t},\n\t\tasync getTxOutput(rawTx, vout) {\n\t\t\tconst result = await readContract(client, {\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: \"get-tx-output\",\n\t\t\t\targs: [bufferCV(rawTx), uintCV(vout)],\n\t\t\t\tsender,\n\t\t\t});\n\t\t\tif (result.type === \"err\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`get-tx-output failed on-chain: ${JSON.stringify(result.value)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn decodeTxOutput(result);\n\t\t},\n\t};\n}\n",
13
- "import { base58, bech32, bech32m } from \"@scure/base\";\nimport { concatBytes } from \"../utils/encoding.ts\";\nimport type { ParsedOutputScript } from \"./codec.ts\";\nimport type { BitcoinNetwork } from \"./constants.ts\";\nimport { doubleSha256 } from \"./serialize.ts\";\n\nconst NETWORK_PARAMS = {\n\tmainnet: { p2pkh: 0x00, p2sh: 0x05, hrp: \"bc\" },\n\ttestnet: { p2pkh: 0x6f, p2sh: 0xc4, hrp: \"tb\" },\n} as const;\n\n/** Base58Check-encode a versioned 20-byte payload (legacy P2PKH / P2SH). */\nfunction base58Check(version: number, payload: Uint8Array): string {\n\tconst data = concatBytes(Uint8Array.of(version), payload);\n\tconst checksum = doubleSha256(data).slice(0, 4);\n\treturn base58.encode(concatBytes(data, checksum));\n}\n\n/**\n * Render a parsed output script as a Bitcoin address for the given network.\n * Returns `undefined` for scripts without a standard address (OP_RETURN, P2PK,\n * unknown). Address encoding is network-dependent, which is why this is separate\n * from the pure `parseOutputScript` decoder.\n */\nexport function formatBitcoinAddress(\n\tparsed: ParsedOutputScript,\n\tnetwork: BitcoinNetwork = \"mainnet\",\n): string | undefined {\n\tconst params = NETWORK_PARAMS[network];\n\tconst hash = parsed.hash;\n\tif (!hash) return undefined;\n\tswitch (parsed.type) {\n\t\tcase \"p2pkh\":\n\t\t\treturn base58Check(params.p2pkh, hash);\n\t\tcase \"p2sh\":\n\t\t\treturn base58Check(params.p2sh, hash);\n\t\tcase \"p2wpkh\":\n\t\tcase \"p2wsh\":\n\t\t\treturn bech32.encode(params.hrp, [0, ...bech32.toWords(hash)]);\n\t\tcase \"p2tr\":\n\t\t\treturn bech32m.encode(params.hrp, [1, ...bech32m.toWords(hash)]);\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n",
14
12
  "import type { Client } from \"../clients/types.ts\";\nimport { formatBitcoinAddress } from \"./address.ts\";\nimport { type OutputScriptType, parseOutputScript } from \"./codec.ts\";\nimport {\n\ttype BitcoinNetwork,\n\tgetSpvAdapter,\n\tspvAdapterPrincipal,\n} from \"./constants.ts\";\nimport { type ProofSource, type SpvProof, buildTxProof } from \"./proof.ts\";\nimport { parseBitcoinTx } from \"./serialize.ts\";\nimport { bitcoinVerifier } from \"./verifier.ts\";\n\nexport interface BitcoinPaymentOutput {\n\tvout: number;\n\t/** scriptPubKey bytes. */\n\tscript: Uint8Array;\n\t/** Value in satoshis. */\n\tamount: bigint;\n\ttype: OutputScriptType;\n\t/** Address for the configured network, if the script has a standard one. */\n\taddress?: string;\n}\n\nexport interface VerifyBitcoinPaymentResult {\n\t/** `mined` AND every supplied `expect` constraint holds. */\n\tverified: boolean;\n\t/**\n\t * On-chain proof that the tx is committed in a Bitcoin block. With\n\t * `authenticateHeader` (default), this is the adapter's `was-tx-mined` —\n\t * header authenticated against the chain AND merkle inclusion. With it off,\n\t * it is merkle inclusion against the proof's own (unauthenticated) header.\n\t */\n\tmined: boolean;\n\t/** The decoded output at `vout`. */\n\toutput: BitcoinPaymentOutput;\n\t/** The proof used (built or supplied). */\n\tproof: SpvProof;\n}\n\nexport type VerifyBitcoinPaymentParams = (\n\t| { proof: SpvProof }\n\t| { txid: string; source: ProofSource }\n) & {\n\t/**\n\t * Adapter contract principal, `\"address.name\"`. Optional once a reference\n\t * adapter is published for `network` (see `SPV_ADAPTER_CONTRACTS`); until then\n\t * it is required.\n\t */\n\tcontract?: string;\n\t/** Output index to decode and assert against. */\n\tvout: number;\n\t/** Network for address formatting. Defaults to mainnet. */\n\tnetwork?: BitcoinNetwork;\n\t/** Optional expectations; each supplied field must match for `verified`. */\n\texpect?: { address?: string; amount?: bigint };\n\t/**\n\t * Confirm the proof's header is the canonical block at its height via\n\t * `get-header-merkle-root` (default true). Turn off only when the caller has\n\t * already authenticated the header.\n\t */\n\tauthenticateHeader?: boolean;\n\tsender?: string;\n};\n\n/**\n * Verify that a Bitcoin payment is committed on-chain and (optionally) matches\n * an expected recipient/amount. Composes the whole SPV flow:\n * 1. build the proof from a `ProofSource` (or accept a prepared `SpvProof`),\n * 2. prove the tx is mined — `was-tx-mined` (header authenticated against the\n * chain + merkle inclusion) by default, or membership-only when\n * `authenticateHeader` is off,\n * 3. decode the target output and assert any `expect` constraints.\n *\n * The output is decoded off-chain from the proof's raw tx, which is sound: the\n * raw tx is pinned to the proven txid (`buildTxProof` checks it hashes to the\n * leaf), so its bytes are committed.\n */\nexport async function verifyBitcoinPayment(\n\tclient: Client,\n\tparams: VerifyBitcoinPaymentParams,\n): Promise<VerifyBitcoinPaymentResult> {\n\tconst {\n\t\tcontract,\n\t\tvout,\n\t\tnetwork = \"mainnet\",\n\t\texpect,\n\t\tauthenticateHeader = true,\n\t\tsender,\n\t} = params;\n\n\tconst adapter = getSpvAdapter(network);\n\tconst resolvedContract =\n\t\tcontract ?? (adapter ? spvAdapterPrincipal(adapter) : undefined);\n\tif (!resolvedContract) {\n\t\tthrow new Error(\n\t\t\t`No spv-adapter deployed for ${network} — pass an explicit \\`contract\\`, or wait for Clarity 6 / Epoch 4.0 (deploy recipe: contracts/README.md).`,\n\t\t);\n\t}\n\n\tconst proof =\n\t\t\"proof\" in params\n\t\t\t? params.proof\n\t\t\t: await buildTxProof(params.source, { txid: params.txid, vout });\n\n\tconst verifier = bitcoinVerifier(client, {\n\t\tcontract: resolvedContract,\n\t\tsender,\n\t});\n\tconst mined = authenticateHeader\n\t\t? await verifier.wasTxMined(proof)\n\t\t: await verifier.verifySpvProof(proof);\n\n\tconst parsedTx = parseBitcoinTx(proof.rawTx);\n\tconst out = parsedTx.outputs[vout];\n\tif (!out) {\n\t\tthrow new Error(\n\t\t\t`vout ${vout} out of range (tx has ${parsedTx.outputs.length} outputs)`,\n\t\t);\n\t}\n\tconst parsedScript = parseOutputScript(out.scriptPubKey);\n\tconst address = formatBitcoinAddress(parsedScript, network);\n\tconst output: BitcoinPaymentOutput = {\n\t\tvout,\n\t\tscript: out.scriptPubKey,\n\t\tamount: out.value,\n\t\ttype: parsedScript.type,\n\t\taddress,\n\t};\n\n\tconst amountOk = expect?.amount === undefined || out.value === expect.amount;\n\tconst addressOk = expect?.address === undefined || address === expect.address;\n\tconst verified = mined && amountOk && addressOk;\n\n\treturn { verified, mined, output, proof };\n}\n"
15
13
  ],
16
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,SAAS,YAAY,CAAC,OAA+B;AAAA,EAC3D,OAAO,mBAAO,mBAAO,KAAK,CAAC;AAAA;AASrB,SAAS,YAAY,CAAC,OAA+B;AAAA,EAC3D,MAAM,MAAM,IAAI,WAAW,MAAM,MAAM;AAAA,EACvC,SAAS,IAAI,EAAG,IAAI,MAAM,QAAQ,KAAK;AAAA,IACtC,IAAI,KAAK,MAAM,MAAM,SAAS,IAAI;AAAA,EACnC;AAAA,EACA,OAAO;AAAA;AAAA;AAQD,MAAM,UAAU;AAAA,EACL;AAAA,EACA;AAAA,EACV,SAAS;AAAA,EAEhB,WAAW,CAAC,MAAkB;AAAA,IAC7B,KAAK,OAAO;AAAA,IACZ,KAAK,OAAO,IAAI,SAAS,KAAK,QAAQ,KAAK,YAAY,KAAK,UAAU;AAAA;AAAA,MAGnE,M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ACR,OAAO,QACP,MAAM,aAAa,OAAO,QAAQ,EAAE,MAAM,OAAO,MAAM,KAAK,CAAC;AAAA,EAEjE,MAAM,WAAW,gBAAgB,QAAQ;AAAA,IACxC,UAAU;AAAA,IACV;AAAA,EACD,CAAC;AAAA,EACD,MAAM,QAAQ,qBACX,MAAM,SAAS,WAAW,KAAK,IAC/B,MAAM,SAAS,eAAe,KAAK;AAAA,EAEtC,MAAM,WAAW,eAAe,MAAM,KAAK;AAAA,EAC3C,MAAM,MAAM,SAAS,QAAQ;AAAA,EAC7B,IAAI,CAAC,KAAK;AAAA,IACT,MAAM,IAAI,MACT,QAAQ,6BAA6B,SAAS,QAAQ,iBACvD;AAAA,EACD;AAAA,EACA,MAAM,eAAe,kBAAkB,IAAI,YAAY;AAAA,EACvD,MAAM,UAAU,qBAAqB,cAAc,OAAO;AAAA,EAC1D,MAAM,SAA+B;AAAA,IACpC;AAAA,IACA,QAAQ,IAAI;AAAA,IACZ,QAAQ,IAAI;AAAA,IACZ,MAAM,aAAa;AAAA,IACnB;AAAA,EACD;AAAA,EAEA,MAAM,WAAW,QAAQ,WAAW,aAAa,IAAI,UAAU,OAAO;AAAA,EACtE,MAAM,YAAY,QAAQ,YAAY,aAAa,YAAY,OAAO;AAAA,EACtE,MAAM,WAAW,SAAS,YAAY;AAAA,EAEtC,OAAO,EAAE,UAAU,OAAO,QAAQ,MAAM;AAAA;",
15
+ "debugId": "B0DCD31B5E33BB1664756E2164756E21",
18
16
  "names": []
19
17
  }
@@ -329,7 +329,7 @@ interface ParsedOutputScript {
329
329
  * P2TR, and OP_RETURN; anything else is `unknown`.
330
330
  */
331
331
  declare function parseOutputScript(script: Uint8Array): ParsedOutputScript;
332
- type BitcoinNetwork = "mainnet" | "testnet";
332
+ type BitcoinNetwork = "mainnet" | "testnet" | "regtest";
333
333
  interface SpvAdapterRef {
334
334
  /** Deployer principal. */
335
335
  address: string;
@@ -681,6 +681,22 @@ declare function bitcoinVerifier(client: Client, config: BitcoinVerifierConfig):
681
681
  * from the pure `parseOutputScript` decoder.
682
682
  */
683
683
  declare function formatBitcoinAddress(parsed: ParsedOutputScript, network?: BitcoinNetwork): string | undefined;
684
+ /**
685
+ * BIP341 key-path tweak: lift the x-only internal key to a point, add
686
+ * `tapTweakHash(P)·G` (no script tree), and return the x-only output key.
687
+ */
688
+ declare function taprootTweakPubkey(xonly: Uint8Array): Uint8Array;
689
+ /**
690
+ * Derive the native-segwit (P2WPKH, bech32 v0) address for a compressed
691
+ * public key.
692
+ */
693
+ declare function publicKeyToP2wpkhAddress(publicKey: Uint8Array | string, network?: BitcoinNetwork): string;
694
+ /**
695
+ * Derive the taproot (P2TR, bech32m v1) address for a public key — BIP341
696
+ * key-path spend, no script tree. Accepts a 33-byte compressed key (the
697
+ * parity byte is dropped) or a 32-byte x-only key.
698
+ */
699
+ declare function publicKeyToP2trAddress(publicKey: Uint8Array | string, network?: BitcoinNetwork): string;
684
700
  interface BitcoinPaymentOutput {
685
701
  vout: number;
686
702
  /** scriptPubKey bytes. */
@@ -749,4 +765,4 @@ type VerifyBitcoinPaymentParams = ({
749
765
  * leaf), so its bytes are committed.
750
766
  */
751
767
  declare function verifyBitcoinPayment(client: Client, params: VerifyBitcoinPaymentParams): Promise<VerifyBitcoinPaymentResult>;
752
- export { verifyBitcoinPayment, stripWitness, spvAdapterPrincipal, rootFromProof, reverseBytes, parseOutputScript, parseBlockHeader, parseBitcoinTx, merkleRoot2 as merkleRoot, isClarity6Active, getSpvAdapter, getBurnBlockHeight, formatBitcoinAddress, fallbackProofSource, esploraSource, encodeMerkleProofArgs, doubleSha256, decodeTxOutput, buildTxProof, buildMerkleProof, blockHash, bitcoinVerifier, bitcoinTxid, bitcoinRpcSource, VerifyBitcoinPaymentResult, VerifyBitcoinPaymentParams, SpvProof, SpvAdapterRef, SPV_ADAPTER_CONTRACTS, SPV_ADAPTER_ABI, ProofSource, ParsedOutputScript, ParsedBitcoinTx, OutputScriptType, MerkleProof, EsploraConfig, DecodedTxOutput, Clarity6Gate, BtcReader, BlockHeader, BlockForTx, BitcoinVerifierConfig, BitcoinVerifier, BitcoinTxOutput, BitcoinTxInput, BitcoinRpcConfig, BitcoinPaymentOutput, BitcoinNetwork };
768
+ export { verifyBitcoinPayment, taprootTweakPubkey, stripWitness, spvAdapterPrincipal, rootFromProof, reverseBytes, publicKeyToP2wpkhAddress, publicKeyToP2trAddress, parseOutputScript, parseBlockHeader, parseBitcoinTx, merkleRoot2 as merkleRoot, isClarity6Active, getSpvAdapter, getBurnBlockHeight, formatBitcoinAddress, fallbackProofSource, esploraSource, encodeMerkleProofArgs, doubleSha256, decodeTxOutput, buildTxProof, buildMerkleProof, blockHash, bitcoinVerifier, bitcoinTxid, bitcoinRpcSource, VerifyBitcoinPaymentResult, VerifyBitcoinPaymentParams, SpvProof, SpvAdapterRef, SPV_ADAPTER_CONTRACTS, SPV_ADAPTER_ABI, ProofSource, ParsedOutputScript, ParsedBitcoinTx, OutputScriptType, MerkleProof, EsploraConfig, DecodedTxOutput, Clarity6Gate, BtcReader, BlockHeader, BlockForTx, BitcoinVerifierConfig, BitcoinVerifier, BitcoinTxOutput, BitcoinTxInput, BitcoinRpcConfig, BitcoinPaymentOutput, BitcoinNetwork };
@@ -329,7 +329,7 @@ interface ParsedOutputScript {
329
329
  * P2TR, and OP_RETURN; anything else is `unknown`.
330
330
  */
331
331
  declare function parseOutputScript(script: Uint8Array): ParsedOutputScript;
332
- type BitcoinNetwork = "mainnet" | "testnet";
332
+ type BitcoinNetwork = "mainnet" | "testnet" | "regtest";
333
333
  interface SpvAdapterRef {
334
334
  /** Deployer principal. */
335
335
  address: string;
@@ -681,6 +681,22 @@ declare function bitcoinVerifier(client: Client, config: BitcoinVerifierConfig):
681
681
  * from the pure `parseOutputScript` decoder.
682
682
  */
683
683
  declare function formatBitcoinAddress(parsed: ParsedOutputScript, network?: BitcoinNetwork): string | undefined;
684
+ /**
685
+ * BIP341 key-path tweak: lift the x-only internal key to a point, add
686
+ * `tapTweakHash(P)·G` (no script tree), and return the x-only output key.
687
+ */
688
+ declare function taprootTweakPubkey(xonly: Uint8Array): Uint8Array;
689
+ /**
690
+ * Derive the native-segwit (P2WPKH, bech32 v0) address for a compressed
691
+ * public key.
692
+ */
693
+ declare function publicKeyToP2wpkhAddress(publicKey: Uint8Array | string, network?: BitcoinNetwork): string;
694
+ /**
695
+ * Derive the taproot (P2TR, bech32m v1) address for a public key — BIP341
696
+ * key-path spend, no script tree. Accepts a 33-byte compressed key (the
697
+ * parity byte is dropped) or a 32-byte x-only key.
698
+ */
699
+ declare function publicKeyToP2trAddress(publicKey: Uint8Array | string, network?: BitcoinNetwork): string;
684
700
  interface BitcoinPaymentOutput {
685
701
  vout: number;
686
702
  /** scriptPubKey bytes. */
@@ -749,4 +765,4 @@ type VerifyBitcoinPaymentParams = ({
749
765
  * leaf), so its bytes are committed.
750
766
  */
751
767
  declare function verifyBitcoinPayment(client: Client, params: VerifyBitcoinPaymentParams): Promise<VerifyBitcoinPaymentResult>;
752
- export { verifyBitcoinPayment, stripWitness, spvAdapterPrincipal, rootFromProof, reverseBytes, parseOutputScript, parseBlockHeader, parseBitcoinTx, merkleRoot2 as merkleRoot, isClarity6Active, getSpvAdapter, getBurnBlockHeight, formatBitcoinAddress, fallbackProofSource, esploraSource, encodeMerkleProofArgs, doubleSha256, decodeTxOutput, buildTxProof, buildMerkleProof, blockHash, bitcoinVerifier, bitcoinTxid, bitcoinRpcSource, VerifyBitcoinPaymentResult, VerifyBitcoinPaymentParams, SpvProof, SpvAdapterRef, SPV_ADAPTER_CONTRACTS, SPV_ADAPTER_ABI, ProofSource, ParsedOutputScript, ParsedBitcoinTx, OutputScriptType, MerkleProof, EsploraConfig, DecodedTxOutput, Clarity6Gate, BtcReader, BlockHeader, BlockForTx, BitcoinVerifierConfig, BitcoinVerifier, BitcoinTxOutput, BitcoinTxInput, BitcoinRpcConfig, BitcoinPaymentOutput, BitcoinNetwork };
768
+ export { verifyBitcoinPayment, taprootTweakPubkey, stripWitness, spvAdapterPrincipal, rootFromProof, reverseBytes, publicKeyToP2wpkhAddress, publicKeyToP2trAddress, parseOutputScript, parseBlockHeader, parseBitcoinTx, merkleRoot2 as merkleRoot, isClarity6Active, getSpvAdapter, getBurnBlockHeight, formatBitcoinAddress, fallbackProofSource, esploraSource, encodeMerkleProofArgs, doubleSha256, decodeTxOutput, buildTxProof, buildMerkleProof, blockHash, bitcoinVerifier, bitcoinTxid, bitcoinRpcSource, VerifyBitcoinPaymentResult, VerifyBitcoinPaymentParams, SpvProof, SpvAdapterRef, SPV_ADAPTER_CONTRACTS, SPV_ADAPTER_ABI, ProofSource, ParsedOutputScript, ParsedBitcoinTx, OutputScriptType, MerkleProof, EsploraConfig, DecodedTxOutput, Clarity6Gate, BtcReader, BlockHeader, BlockForTx, BitcoinVerifierConfig, BitcoinVerifier, BitcoinTxOutput, BitcoinTxInput, BitcoinRpcConfig, BitcoinPaymentOutput, BitcoinNetwork };