@bitgo-beta/utxo-descriptors 0.0.1-beta.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.
- package/LICENSE +191 -0
- package/README.md +36 -0
- package/dist/cjs/src/index.d.ts +2 -0
- package/dist/cjs/src/index.d.ts.map +1 -0
- package/dist/cjs/src/index.js +38 -0
- package/dist/cjs/src/sbtc/constants.d.ts +29 -0
- package/dist/cjs/src/sbtc/constants.d.ts.map +1 -0
- package/dist/cjs/src/sbtc/constants.js +32 -0
- package/dist/cjs/src/sbtc/depositAddress.d.ts +28 -0
- package/dist/cjs/src/sbtc/depositAddress.d.ts.map +1 -0
- package/dist/cjs/src/sbtc/depositAddress.js +44 -0
- package/dist/cjs/src/sbtc/descriptor.d.ts +67 -0
- package/dist/cjs/src/sbtc/descriptor.d.ts.map +1 -0
- package/dist/cjs/src/sbtc/descriptor.js +79 -0
- package/dist/cjs/src/sbtc/index.d.ts +4 -0
- package/dist/cjs/src/sbtc/index.d.ts.map +1 -0
- package/dist/cjs/src/sbtc/index.js +20 -0
- package/dist/cjs/test/unit/sbtc/descriptor.d.ts +2 -0
- package/dist/cjs/test/unit/sbtc/descriptor.d.ts.map +1 -0
- package/dist/cjs/test/unit/sbtc/descriptor.js +249 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/sbtc/constants.d.ts +29 -0
- package/dist/esm/sbtc/constants.d.ts.map +1 -0
- package/dist/esm/sbtc/constants.js +29 -0
- package/dist/esm/sbtc/depositAddress.d.ts +28 -0
- package/dist/esm/sbtc/depositAddress.d.ts.map +1 -0
- package/dist/esm/sbtc/depositAddress.js +40 -0
- package/dist/esm/sbtc/descriptor.d.ts +67 -0
- package/dist/esm/sbtc/descriptor.d.ts.map +1 -0
- package/dist/esm/sbtc/descriptor.js +75 -0
- package/dist/esm/sbtc/index.d.ts +4 -0
- package/dist/esm/sbtc/index.d.ts.map +1 -0
- package/dist/esm/sbtc/index.js +4 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2022 BitGo
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -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)).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.sbtc = void 0;
|
|
37
|
+
exports.sbtc = __importStar(require("./sbtc"));
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsK0NBQStCIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogYXMgc2J0YyBmcm9tICcuL3NidGMnO1xuIl19
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Well-known unspendable Taproot internal key.
|
|
3
|
+
*
|
|
4
|
+
* Nothing-up-my-sleeve point on secp256k1 with no known private key. Using it
|
|
5
|
+
* as a Taproot internal key guarantees the output cannot be spent via the
|
|
6
|
+
* key path — only via one of the script-path leaves.
|
|
7
|
+
*/
|
|
8
|
+
export declare const UNSPENDABLE_INTERNAL_KEY = "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0";
|
|
9
|
+
/**
|
|
10
|
+
* Default reclaim relative timelock — number of Bitcoin blocks the depositor
|
|
11
|
+
* must wait before they can reclaim their BTC if the sBTC signers fail to
|
|
12
|
+
* process the deposit.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_RECLAIM_LOCK_TIME = 950;
|
|
15
|
+
/**
|
|
16
|
+
* Default max signer fee in satoshis. Encoded as a big-endian u64 (8 bytes)
|
|
17
|
+
* inside the deposit-leaf metadata payload.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_MAX_SIGNER_FEE = 80000;
|
|
20
|
+
/** Length of the encoded sBTC max-fee field, in bytes. */
|
|
21
|
+
export declare const MAX_FEE_BYTE_LENGTH = 8;
|
|
22
|
+
/**
|
|
23
|
+
* Length of the Stacks recipient field inside the deposit payload — 22 bytes:
|
|
24
|
+
* byte 0 = Clarity principal type (0x05 standard, 0x06 contract)
|
|
25
|
+
* byte 1 = Stacks address version (e.g. 0x16 mainnet, 0x1a testnet)
|
|
26
|
+
* bytes 2..21 = 20-byte hash160 of the principal
|
|
27
|
+
*/
|
|
28
|
+
export declare const STACKS_RECIPIENT_BYTE_LENGTH = 22;
|
|
29
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/sbtc/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,qEAAqE,CAAC;AAE3G;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,KAAK,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STACKS_RECIPIENT_BYTE_LENGTH = exports.MAX_FEE_BYTE_LENGTH = exports.DEFAULT_MAX_SIGNER_FEE = exports.DEFAULT_RECLAIM_LOCK_TIME = exports.UNSPENDABLE_INTERNAL_KEY = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Well-known unspendable Taproot internal key.
|
|
6
|
+
*
|
|
7
|
+
* Nothing-up-my-sleeve point on secp256k1 with no known private key. Using it
|
|
8
|
+
* as a Taproot internal key guarantees the output cannot be spent via the
|
|
9
|
+
* key path — only via one of the script-path leaves.
|
|
10
|
+
*/
|
|
11
|
+
exports.UNSPENDABLE_INTERNAL_KEY = '50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0';
|
|
12
|
+
/**
|
|
13
|
+
* Default reclaim relative timelock — number of Bitcoin blocks the depositor
|
|
14
|
+
* must wait before they can reclaim their BTC if the sBTC signers fail to
|
|
15
|
+
* process the deposit.
|
|
16
|
+
*/
|
|
17
|
+
exports.DEFAULT_RECLAIM_LOCK_TIME = 950;
|
|
18
|
+
/**
|
|
19
|
+
* Default max signer fee in satoshis. Encoded as a big-endian u64 (8 bytes)
|
|
20
|
+
* inside the deposit-leaf metadata payload.
|
|
21
|
+
*/
|
|
22
|
+
exports.DEFAULT_MAX_SIGNER_FEE = 80000;
|
|
23
|
+
/** Length of the encoded sBTC max-fee field, in bytes. */
|
|
24
|
+
exports.MAX_FEE_BYTE_LENGTH = 8;
|
|
25
|
+
/**
|
|
26
|
+
* Length of the Stacks recipient field inside the deposit payload — 22 bytes:
|
|
27
|
+
* byte 0 = Clarity principal type (0x05 standard, 0x06 contract)
|
|
28
|
+
* byte 1 = Stacks address version (e.g. 0x16 mainnet, 0x1a testnet)
|
|
29
|
+
* bytes 2..21 = 20-byte hash160 of the principal
|
|
30
|
+
*/
|
|
31
|
+
exports.STACKS_RECIPIENT_BYTE_LENGTH = 22;
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3NidGMvY29uc3RhbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQ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Interface = bip32.BIP32Interface;
|
|
4
|
+
/**
|
|
5
|
+
* Compile the sBTC deposit Taproot scriptPubKey.
|
|
6
|
+
*
|
|
7
|
+
* If `params.walletKeys` contains BIP32 xpubs, the descriptor is derivable and
|
|
8
|
+
* `derivationIndex` selects which child keys go into the reclaim leaf. If
|
|
9
|
+
* `params.walletKeys` contains raw 32-byte x-only Buffers, the descriptor is
|
|
10
|
+
* definite and `derivationIndex` is ignored.
|
|
11
|
+
*
|
|
12
|
+
* We can't use `Descriptor.fromStringDetectType()` here: that path doesn't
|
|
13
|
+
* enable the `drop` ExtParams flag, so it rejects `r:older` and `payload_drop`
|
|
14
|
+
* fragments. We branch on the input shape instead — that's the same signal
|
|
15
|
+
* the descriptor library would use, just observable to us before parsing.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createSbtcDepositScriptPubKey(params: SbtcDepositDescriptorParams, derivationIndex?: number): Buffer;
|
|
18
|
+
/**
|
|
19
|
+
* Derive the three concrete x-only reclaim pubkeys at the given derivation
|
|
20
|
+
* index from a triple of BIP32 xpubs.
|
|
21
|
+
*
|
|
22
|
+
* The descriptor library performs this derivation internally when computing
|
|
23
|
+
* `scriptPubkey()`; this helper exposes the same derivation for callers that
|
|
24
|
+
* need the keys directly (e.g., constructing a witness for the reclaim leaf).
|
|
25
|
+
*/
|
|
26
|
+
export declare function deriveReclaimKeys(walletKeys: [BIP32Interface, BIP32Interface, BIP32Interface], index: number): [Buffer, Buffer, Buffer];
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=depositAddress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depositAddress.d.ts","sourceRoot":"","sources":["../../../../src/sbtc/depositAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAA+B,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAExF,KAAK,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,2BAA2B,EAAE,eAAe,SAAI,GAAG,MAAM,CAQ9G;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,cAAc,CAAC,EAC5D,KAAK,EAAE,MAAM,GACZ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAM1B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSbtcDepositScriptPubKey = createSbtcDepositScriptPubKey;
|
|
4
|
+
exports.deriveReclaimKeys = deriveReclaimKeys;
|
|
5
|
+
const wasm_utxo_1 = require("@bitgo/wasm-utxo");
|
|
6
|
+
const descriptor_1 = require("./descriptor");
|
|
7
|
+
/**
|
|
8
|
+
* Compile the sBTC deposit Taproot scriptPubKey.
|
|
9
|
+
*
|
|
10
|
+
* If `params.walletKeys` contains BIP32 xpubs, the descriptor is derivable and
|
|
11
|
+
* `derivationIndex` selects which child keys go into the reclaim leaf. If
|
|
12
|
+
* `params.walletKeys` contains raw 32-byte x-only Buffers, the descriptor is
|
|
13
|
+
* definite and `derivationIndex` is ignored.
|
|
14
|
+
*
|
|
15
|
+
* We can't use `Descriptor.fromStringDetectType()` here: that path doesn't
|
|
16
|
+
* enable the `drop` ExtParams flag, so it rejects `r:older` and `payload_drop`
|
|
17
|
+
* fragments. We branch on the input shape instead — that's the same signal
|
|
18
|
+
* the descriptor library would use, just observable to us before parsing.
|
|
19
|
+
*/
|
|
20
|
+
function createSbtcDepositScriptPubKey(params, derivationIndex = 0) {
|
|
21
|
+
const descString = (0, descriptor_1.createSbtcDepositDescriptor)(params);
|
|
22
|
+
const isDefinite = params.walletKeys.every(Buffer.isBuffer);
|
|
23
|
+
if (isDefinite) {
|
|
24
|
+
return Buffer.from(wasm_utxo_1.Descriptor.fromString(descString, 'definite').scriptPubkey());
|
|
25
|
+
}
|
|
26
|
+
const desc = wasm_utxo_1.Descriptor.fromString(descString, 'derivable');
|
|
27
|
+
return Buffer.from(desc.atDerivationIndex(derivationIndex).scriptPubkey());
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Derive the three concrete x-only reclaim pubkeys at the given derivation
|
|
31
|
+
* index from a triple of BIP32 xpubs.
|
|
32
|
+
*
|
|
33
|
+
* The descriptor library performs this derivation internally when computing
|
|
34
|
+
* `scriptPubkey()`; this helper exposes the same derivation for callers that
|
|
35
|
+
* need the keys directly (e.g., constructing a witness for the reclaim leaf).
|
|
36
|
+
*/
|
|
37
|
+
function deriveReclaimKeys(walletKeys, index) {
|
|
38
|
+
const [k1, k2, k3] = walletKeys.map((k) => {
|
|
39
|
+
const child = k.derive(index);
|
|
40
|
+
return Buffer.from(child.publicKey.subarray(1));
|
|
41
|
+
});
|
|
42
|
+
return [k1, k2, k3];
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwb3NpdEFkZHJlc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvc2J0Yy9kZXBvc2l0QWRkcmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQW1CQSxzRUFRQztBQVVELDhDQVNDO0FBOUNELGdEQUFxRDtBQUVyRCw2Q0FBd0Y7QUFJeEY7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsU0FBZ0IsNkJBQTZCLENBQUMsTUFBbUMsRUFBRSxlQUFlLEdBQUcsQ0FBQztJQUNwRyxNQUFNLFVBQVUsR0FBRyxJQUFBLHdDQUEyQixFQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3ZELE1BQU0sVUFBVSxHQUFHLE1BQU0sQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDL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0cnVjdGluZyBhIHdpdG5lc3MgZm9yIHRoZSByZWNsYWltIGxlYWYpLlxuICovXG5leHBvcnQgZnVuY3Rpb24gZGVyaXZlUmVjbGFpbUtleXMoXG4gIHdhbGxldEtleXM6IFtCSVAzMkludGVyZmFjZSwgQklQMzJJbnRlcmZhY2UsIEJJUDMySW50ZXJmYWNlXSxcbiAgaW5kZXg6IG51bWJlclxuKTogW0J1ZmZlciwgQnVmZmVyLCBCdWZmZXJdIHtcbiAgY29uc3QgW2sxLCBrMiwgazNdID0gd2FsbGV0S2V5cy5tYXAoKGspID0+IHtcbiAgICBjb25zdCBjaGlsZCA9IGsuZGVyaXZlKGluZGV4KTtcbiAgICByZXR1cm4gQnVmZmVyLmZyb20oY2hpbGQucHVibGljS2V5LnN1YmFycmF5KDEpKTtcbiAgfSk7XG4gIHJldHVybiBbazEsIGsyLCBrM107XG59XG4iXX0=
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { bip32 } from '@bitgo/wasm-utxo';
|
|
2
|
+
type BIP32Interface = bip32.BIP32Interface;
|
|
3
|
+
/**
|
|
4
|
+
* A reclaim key entry — either a BIP32 xpub/xprv (derivable) or a concrete
|
|
5
|
+
* 32-byte x-only public key (definite).
|
|
6
|
+
*/
|
|
7
|
+
export type SbtcReclaimKey = BIP32Interface | Buffer;
|
|
8
|
+
export type SbtcDepositDescriptorParams = {
|
|
9
|
+
/**
|
|
10
|
+
* The three reclaim keys (user, backup, bitgo). Used in the reclaim leaf as
|
|
11
|
+
* a 2-of-3 Tapscript multisig (`multi_a`). If a key is a `BIP32Interface`,
|
|
12
|
+
* it is rendered as `<xpub>/*` and the descriptor is derivable. If a key is
|
|
13
|
+
* a 32-byte `Buffer`, it is rendered as a concrete x-only hex key and the
|
|
14
|
+
* descriptor is definite.
|
|
15
|
+
*/
|
|
16
|
+
walletKeys: [SbtcReclaimKey, SbtcReclaimKey, SbtcReclaimKey];
|
|
17
|
+
/**
|
|
18
|
+
* Number of Bitcoin blocks the depositor must wait (relative timelock) before
|
|
19
|
+
* the reclaim leaf becomes spendable.
|
|
20
|
+
*/
|
|
21
|
+
lockTime: number;
|
|
22
|
+
/** Max satoshis the sBTC signers may take. Encoded big-endian u64 (8 bytes). */
|
|
23
|
+
maxFee: number | bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Stacks recipient bytes — 22 bytes:
|
|
26
|
+
* byte 0 = Clarity principal type (0x05 standard, 0x06 contract)
|
|
27
|
+
* byte 1 = Stacks address version (e.g. 0x16 mainnet, 0x1a testnet)
|
|
28
|
+
* bytes 2..21 = 20-byte hash160 of the principal
|
|
29
|
+
*/
|
|
30
|
+
stacksRecipient: Buffer;
|
|
31
|
+
/** 32-byte x-only sBTC signers' aggregate pubkey. */
|
|
32
|
+
signersAggregateKey: Buffer;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Encode the deposit-leaf metadata that the sBTC signers parse from the
|
|
36
|
+
* witness: max-fee (u64 big-endian, 8 bytes) followed by the 22-byte
|
|
37
|
+
* Stacks recipient. Total: 30 bytes.
|
|
38
|
+
*
|
|
39
|
+
* The result is the single `payload_drop` argument inside the deposit leaf.
|
|
40
|
+
*/
|
|
41
|
+
export declare function encodeDepositPayload(maxFee: number | bigint, stacksRecipient: Buffer): Buffer;
|
|
42
|
+
/**
|
|
43
|
+
* Build the sBTC peg-in deposit Taproot descriptor as a single all-miniscript
|
|
44
|
+
* `tr()` with two leaves:
|
|
45
|
+
*
|
|
46
|
+
* tr(<UNSPENDABLE>,
|
|
47
|
+
* {
|
|
48
|
+
* c:and_v(payload_drop(<feeBE||recipient>), pk_k(<signersKey>)),
|
|
49
|
+
* and_v(r:older(<lockTime>), multi_a(2, xpub1/*, xpub2/*, xpub3/*))
|
|
50
|
+
* }
|
|
51
|
+
* )
|
|
52
|
+
*
|
|
53
|
+
* - Deposit leaf compiles to: `<30B-payload> OP_DROP <signersKey> OP_CHECKSIG`
|
|
54
|
+
* - Reclaim leaf compiles to: `<lockTime> OP_CSV OP_DROP <k1> OP_CHECKSIG <k2> OP_CHECKSIGADD <k3> OP_CHECKSIGADD OP_2 OP_NUMEQUAL`
|
|
55
|
+
*
|
|
56
|
+
* Both fragments are valid Bitcoin miniscript via the `payload_drop` and
|
|
57
|
+
* `r:older` extensions added in `@bitgo/wasm-utxo` 4.11.0
|
|
58
|
+
* (BitGoWASM PR #272).
|
|
59
|
+
*
|
|
60
|
+
* The descriptor is derivable: the reclaim xpubs use `/*` and the descriptor
|
|
61
|
+
* library resolves them to concrete x-only keys at each derivation index.
|
|
62
|
+
*
|
|
63
|
+
* @returns descriptor string (without checksum)
|
|
64
|
+
*/
|
|
65
|
+
export declare function createSbtcDepositDescriptor(params: SbtcDepositDescriptorParams): string;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../../src/sbtc/descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAI9C,KAAK,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,MAAM,CAAC;AAErD,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAC7D;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAYF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAW7F;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,2BAA2B,GAAG,MAAM,CAwBvF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeDepositPayload = encodeDepositPayload;
|
|
4
|
+
exports.createSbtcDepositDescriptor = createSbtcDepositDescriptor;
|
|
5
|
+
const wasm_utxo_1 = require("@bitgo/wasm-utxo");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
function asDescriptorKey(key) {
|
|
8
|
+
if (Buffer.isBuffer(key)) {
|
|
9
|
+
if (key.length !== 32) {
|
|
10
|
+
throw new Error(`reclaim key buffer must be 32 bytes x-only (got ${key.length})`);
|
|
11
|
+
}
|
|
12
|
+
return key.toString('hex');
|
|
13
|
+
}
|
|
14
|
+
return key.neutered().toBase58() + '/*';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Encode the deposit-leaf metadata that the sBTC signers parse from the
|
|
18
|
+
* witness: max-fee (u64 big-endian, 8 bytes) followed by the 22-byte
|
|
19
|
+
* Stacks recipient. Total: 30 bytes.
|
|
20
|
+
*
|
|
21
|
+
* The result is the single `payload_drop` argument inside the deposit leaf.
|
|
22
|
+
*/
|
|
23
|
+
function encodeDepositPayload(maxFee, stacksRecipient) {
|
|
24
|
+
if (stacksRecipient.length !== constants_1.STACKS_RECIPIENT_BYTE_LENGTH) {
|
|
25
|
+
throw new Error(`stacksRecipient must be ${constants_1.STACKS_RECIPIENT_BYTE_LENGTH} bytes (got ${stacksRecipient.length})`);
|
|
26
|
+
}
|
|
27
|
+
const fee = typeof maxFee === 'bigint' ? maxFee : BigInt(maxFee);
|
|
28
|
+
if (fee < 0n || fee > 0xffffffffffffffffn) {
|
|
29
|
+
throw new Error(`maxFee (${maxFee}) does not fit in unsigned 64 bits`);
|
|
30
|
+
}
|
|
31
|
+
const feeBuf = Buffer.alloc(constants_1.MAX_FEE_BYTE_LENGTH);
|
|
32
|
+
feeBuf.writeBigUInt64BE(fee);
|
|
33
|
+
return Buffer.concat([feeBuf, stacksRecipient]);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build the sBTC peg-in deposit Taproot descriptor as a single all-miniscript
|
|
37
|
+
* `tr()` with two leaves:
|
|
38
|
+
*
|
|
39
|
+
* tr(<UNSPENDABLE>,
|
|
40
|
+
* {
|
|
41
|
+
* c:and_v(payload_drop(<feeBE||recipient>), pk_k(<signersKey>)),
|
|
42
|
+
* and_v(r:older(<lockTime>), multi_a(2, xpub1/*, xpub2/*, xpub3/*))
|
|
43
|
+
* }
|
|
44
|
+
* )
|
|
45
|
+
*
|
|
46
|
+
* - Deposit leaf compiles to: `<30B-payload> OP_DROP <signersKey> OP_CHECKSIG`
|
|
47
|
+
* - Reclaim leaf compiles to: `<lockTime> OP_CSV OP_DROP <k1> OP_CHECKSIG <k2> OP_CHECKSIGADD <k3> OP_CHECKSIGADD OP_2 OP_NUMEQUAL`
|
|
48
|
+
*
|
|
49
|
+
* Both fragments are valid Bitcoin miniscript via the `payload_drop` and
|
|
50
|
+
* `r:older` extensions added in `@bitgo/wasm-utxo` 4.11.0
|
|
51
|
+
* (BitGoWASM PR #272).
|
|
52
|
+
*
|
|
53
|
+
* The descriptor is derivable: the reclaim xpubs use `/*` and the descriptor
|
|
54
|
+
* library resolves them to concrete x-only keys at each derivation index.
|
|
55
|
+
*
|
|
56
|
+
* @returns descriptor string (without checksum)
|
|
57
|
+
*/
|
|
58
|
+
function createSbtcDepositDescriptor(params) {
|
|
59
|
+
if (params.lockTime <= 0) {
|
|
60
|
+
throw new Error(`lockTime (${params.lockTime}) must be greater than 0`);
|
|
61
|
+
}
|
|
62
|
+
if (params.signersAggregateKey.length !== 32) {
|
|
63
|
+
throw new Error(`signersAggregateKey must be 32 bytes x-only (got ${params.signersAggregateKey.length})`);
|
|
64
|
+
}
|
|
65
|
+
const payloadHex = encodeDepositPayload(params.maxFee, params.stacksRecipient).toString('hex');
|
|
66
|
+
const reclaimKeys = params.walletKeys.map(asDescriptorKey);
|
|
67
|
+
// `payload_drop` is not yet in the public MiniscriptNode TS union, so cast
|
|
68
|
+
// the deposit leaf — the formatter is generic and renders it correctly.
|
|
69
|
+
const depositLeaf = {
|
|
70
|
+
'c:and_v': [{ payload_drop: payloadHex }, { pk_k: params.signersAggregateKey.toString('hex') }],
|
|
71
|
+
};
|
|
72
|
+
const reclaimLeaf = {
|
|
73
|
+
and_v: [{ 'r:older': params.lockTime }, { multi_a: [2, ...reclaimKeys] }],
|
|
74
|
+
};
|
|
75
|
+
return wasm_utxo_1.ast.formatNode({
|
|
76
|
+
tr: [constants_1.UNSPENDABLE_INTERNAL_KEY, [depositLeaf, reclaimLeaf]],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVzY3JpcHRvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9zYnRjL2Rlc2NyaXB0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUF3REEsb0RBV0M7QUF5QkQsa0VBd0JDO0FBcEhELGdEQUE4QztBQUU5QywyQ0FBMEc7QUFxQzFHLFNBQVMsZUFBZSxDQUFDLEdBQW1CO0lBQzFDLElBQUksTUFBTSxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDO1FBQ3pCLElBQUksR0FBRyxDQUFDLE1BQU0sS0FBSyxFQUFFLEVBQUUsQ0FBQztZQUN0QixNQUFNLElBQUksS0FBSyxDQUFDLG1EQUFtRCxHQUFHLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztRQUNwRixDQUFDO1FBQ0QsT0FBTyxHQUFHLENBQUMsUUFBUSxDQUFDLEtBQUssQ0FBQ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O1xufVxuIl19
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sbtc/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./descriptor"), exports);
|
|
19
|
+
__exportStar(require("./depositAddress"), exports);
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvc2J0Yy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsOENBQTRCO0FBQzVCLCtDQUE2QjtBQUM3QixtREFBaUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2NvbnN0YW50cyc7XG5leHBvcnQgKiBmcm9tICcuL2Rlc2NyaXB0b3InO1xuZXhwb3J0ICogZnJvbSAnLi9kZXBvc2l0QWRkcmVzcyc7XG4iXX0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../../../test/unit/sbtc/descriptor.ts"],"names":[],"mappings":""}
|