@babylonlabs-io/ts-sdk 0.2.1-rc.3 → 0.3.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 +169 -0
- package/dist/{PayoutManager-rMj54HDh.js → PayoutManager-BkOfdb2_.js} +38 -36
- package/dist/PayoutManager-BkOfdb2_.js.map +1 -0
- package/dist/PayoutManager-DZ7EIcAJ.cjs +2 -0
- package/dist/PayoutManager-DZ7EIcAJ.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +49 -48
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +47 -46
- package/dist/tbv/core/utils/fee/constants.d.ts +7 -0
- package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +47 -46
- package/package.json +20 -20
- package/dist/PayoutManager-Dg_i_S7w.cjs +0 -2
- package/dist/PayoutManager-Dg_i_S7w.cjs.map +0 -1
- package/dist/PayoutManager-rMj54HDh.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
Parameters
|
|
10
|
+
|
|
11
|
+
Licensor: Babylon Labs Ltd.
|
|
12
|
+
|
|
13
|
+
Licensed Work: babylon-toolkit
|
|
14
|
+
The Licensed Work is (c) 2024 Babylon Labs Ltd.
|
|
15
|
+
|
|
16
|
+
Additional Use Grant:
|
|
17
|
+
|
|
18
|
+
In addition to the uses permitted under the non-production license below,
|
|
19
|
+
we grant you a limited, non-exclusive, non-transferable, non-sublicensable,
|
|
20
|
+
revocable license, limited as set forth below, to use the Licensed Work
|
|
21
|
+
in this repository for production commercial uses built on or using and integrated
|
|
22
|
+
with the Babylon Protocol, not including Competing Uses.
|
|
23
|
+
|
|
24
|
+
Any use beyond the scope of this license, including uses that are not built on or
|
|
25
|
+
using and integrated with the Babylon Protocol, or are Competing Uses,
|
|
26
|
+
will terminate this license to you, automatically and without notice.
|
|
27
|
+
|
|
28
|
+
This License applies separately and solely to the specific versions of the Licensed Work
|
|
29
|
+
in the specified repository on or before the date of this License, and we may require a
|
|
30
|
+
different license and different provisions for each subsequent version of the
|
|
31
|
+
Licensed Work released by us.
|
|
32
|
+
|
|
33
|
+
"Babylon Labs", "we", "our", or "us" means Babylon Labs Ltd.
|
|
34
|
+
|
|
35
|
+
"Babylon Protocol" means the Bitcoin staking protocol as further described in the documentation
|
|
36
|
+
here (https://docs.babylonlabs.io/docs/introduction/babylon-overview), as updated from time to time.
|
|
37
|
+
|
|
38
|
+
"Competing Use" means any use of the Licensed Work in any product, software, protocol, network,
|
|
39
|
+
application, or service that is made available to any party and that
|
|
40
|
+
(i) substitutes for the use of the Babylon Protocol,
|
|
41
|
+
(ii) offers the same or substantially similar functionality as the Babylon Protocol or
|
|
42
|
+
(iii) is built on or uses a protocol with substantially similar functionality as the Babylon Protocol
|
|
43
|
+
or otherwise facilitates the staking of bitcoin other than by utilizing the Babylon Protocol.
|
|
44
|
+
|
|
45
|
+
The provisions in this License apply to each individual, entity, group, or association
|
|
46
|
+
(each and collectively, "you" or "your") who uses the Licensed Work for production,
|
|
47
|
+
and you agree to such provisions. Your production use of the Licensed Work is conditional on your
|
|
48
|
+
agreement to this License. If you do not agree and consent to be bound to this License,
|
|
49
|
+
do not so use the Software.
|
|
50
|
+
|
|
51
|
+
If you do not fall within the limited scope of this license as described above or below,
|
|
52
|
+
or are otherwise not in strict compliance with this License, then this production license does not
|
|
53
|
+
extend to you and does not grant you any production use, including any copying, distributing, or
|
|
54
|
+
making any derivative use of the Licensed Work for production purposes.
|
|
55
|
+
|
|
56
|
+
Limited Scope of License. Your commercial production license to the Licensed Work
|
|
57
|
+
under this License does not extend to any use:
|
|
58
|
+
|
|
59
|
+
1. unless you have legal capacity to consent and agree to be bound by this License;
|
|
60
|
+
2. unless you have the technical knowledge necessary or advisable to understand and evaluate the
|
|
61
|
+
risks of using the Licensed Work and the Babylon Protocol;
|
|
62
|
+
3. if you are a resident or agent of, or an entity organized, incorporated or doing business in,
|
|
63
|
+
Afghanistan, Belarus, Bosnia and Herzegovina, Burundi, Central African Republic, Crimea, Cuba,
|
|
64
|
+
Democratic People's Republic of Korea, Democratic Republic of the Congo,
|
|
65
|
+
Donetsk or Luhansk Regions of Ukraine, Eritrea, Guinea, Guinea-Bissau, Haiti, Iran, Iraq, Lebanon,
|
|
66
|
+
Libya, Mali, Myanmar, Nicaragua, Russia, Somalia, South Sudan, Sudan, Syria, Venezuela, Yemen,
|
|
67
|
+
or Zimbabwe or any other country to which the United States, the United Kingdom,
|
|
68
|
+
the European Union or any of its member states or the United Nations or any of its member states
|
|
69
|
+
(collectively, the "Major Jurisdictions") embargoes goods or imposes sanctions
|
|
70
|
+
(such embargoed or sanctioned territories, collectively, the "Restricted Territories");
|
|
71
|
+
4. if you are, or if you directly or indirectly own or control, from any person or entity that is
|
|
72
|
+
listed on any sanctions list or equivalent maintained by any of the Major Jurisdictions
|
|
73
|
+
(collectively, "Sanctions Lists Persons");
|
|
74
|
+
5. to transact in or with any Restricted Territories or Sanctions List Persons;
|
|
75
|
+
6. if you are a U.S. Person as defined in 17 CFR § 230.902, or currently or ordinarily located or
|
|
76
|
+
resident in (or incorporated or organized in) the United States of America, Canada, or
|
|
77
|
+
Australia (collectively, "Excluded Jurisdictions"), or to transact in or with Excluded Jurisdictions;
|
|
78
|
+
7. to defraud, or otherwise materially mislead, any person;
|
|
79
|
+
8. in violation of applicable laws, rules or regulations in your relevant jurisdiction;
|
|
80
|
+
9. that circumvents any sanctions or export controls targeting you or the country or territory where
|
|
81
|
+
you are located; or
|
|
82
|
+
10. in any activity that transmits, exchanges, or is otherwise supported by the direct or indirect
|
|
83
|
+
proceeds of criminal or fraudulent activity.
|
|
84
|
+
|
|
85
|
+
Any production use of the Licensed Work by you confirms your agreement to the foregoing limitations,
|
|
86
|
+
and your understanding and agreement that they are limitations and not restrictions.
|
|
87
|
+
|
|
88
|
+
Change Date: 2027-03-15 (March 15th, 2027)
|
|
89
|
+
|
|
90
|
+
Change License: Apache 2.0
|
|
91
|
+
|
|
92
|
+
-----------------------------------------------------------------------------
|
|
93
|
+
|
|
94
|
+
Terms
|
|
95
|
+
|
|
96
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
97
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
98
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
99
|
+
production use.
|
|
100
|
+
|
|
101
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
102
|
+
available distribution of a specific version of the Licensed Work under this
|
|
103
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
104
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
105
|
+
above terminate.
|
|
106
|
+
|
|
107
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
108
|
+
currently in effect as described in this License, you must purchase a
|
|
109
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
110
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
111
|
+
|
|
112
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
113
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
114
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
115
|
+
for each version of the Licensed Work released by Licensor.
|
|
116
|
+
|
|
117
|
+
You must conspicuously display this License on each original or modified copy
|
|
118
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
119
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
120
|
+
License apply to your use of that work.
|
|
121
|
+
|
|
122
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
123
|
+
terminate your rights under this License for the current and all other
|
|
124
|
+
versions of the Licensed Work.
|
|
125
|
+
|
|
126
|
+
This License does not grant you any right in any trademark or logo of
|
|
127
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
128
|
+
Licensor as expressly required by this License).
|
|
129
|
+
|
|
130
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
131
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
132
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
133
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
134
|
+
TITLE.
|
|
135
|
+
|
|
136
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
137
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
138
|
+
as long as you comply with the Covenants of Licensor below.
|
|
139
|
+
|
|
140
|
+
-----------------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
Covenants of Licensor
|
|
143
|
+
|
|
144
|
+
In consideration of the right to use this License’s text and the "Business
|
|
145
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
146
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
147
|
+
|
|
148
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
149
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
150
|
+
where "compatible" means that software provided under the Change License can
|
|
151
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
152
|
+
later version. Licensor may specify additional Change Licenses without
|
|
153
|
+
limitation.
|
|
154
|
+
|
|
155
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
156
|
+
impose any additional restriction on the right granted in this License, as
|
|
157
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
158
|
+
|
|
159
|
+
3. To specify a Change Date.
|
|
160
|
+
|
|
161
|
+
4. Not to modify this License in any other way.
|
|
162
|
+
|
|
163
|
+
-----------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
Notice
|
|
166
|
+
|
|
167
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
168
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
169
|
+
under an Open Source License, as stated in this License.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var I = (n, t, e) =>
|
|
4
|
-
import * as
|
|
5
|
-
import { script as D, Transaction as E, address as q, Psbt as
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var X = (n, t, e) => t in n ? L(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var I = (n, t, e) => X(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import * as S from "bitcoinjs-lib";
|
|
5
|
+
import { script as D, Transaction as E, address as q, Psbt as $ } from "bitcoinjs-lib";
|
|
6
6
|
import { Buffer as p } from "buffer";
|
|
7
7
|
import { m as C, s as T, b as z, k as j, v as A, a as O, e as W } from "./challengeAssert-DVErOd8l.js";
|
|
8
8
|
import { createPublicClient as F, http as M, encodeFunctionData as Y, zeroAddress as J } from "viem";
|
|
@@ -12,6 +12,7 @@ const Z = 58, V = 43, G = 11, N = 546, H = BigInt(N), Q = 30, tt = 2, mt = 1.1;
|
|
|
12
12
|
function et(n) {
|
|
13
13
|
return n <= tt ? Q : 0;
|
|
14
14
|
}
|
|
15
|
+
const wt = 5;
|
|
15
16
|
function nt(n, t, e) {
|
|
16
17
|
if (n.length === 0)
|
|
17
18
|
throw new Error("Insufficient funds: no UTXOs available");
|
|
@@ -48,10 +49,10 @@ function nt(n, t, e) {
|
|
|
48
49
|
`Insufficient funds: need ${t + i} sats (${t} pegin + ${i} fee), have ${u} sats`
|
|
49
50
|
);
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function xt(n) {
|
|
52
53
|
return n > H;
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function Pt() {
|
|
55
56
|
return N;
|
|
56
57
|
}
|
|
57
58
|
function st(n) {
|
|
@@ -82,7 +83,7 @@ function st(n) {
|
|
|
82
83
|
return { version: o, locktime: u, outputs: i };
|
|
83
84
|
}
|
|
84
85
|
function rt(n) {
|
|
85
|
-
const { unfundedTxHex: t, selectedUTXOs: e, changeAddress: s, changeAmount: a, network: o } = n, { version: u, locktime: i, outputs: r } = st(t), c = new
|
|
86
|
+
const { unfundedTxHex: t, selectedUTXOs: e, changeAddress: s, changeAmount: a, network: o } = n, { version: u, locktime: i, outputs: r } = st(t), c = new S.Transaction();
|
|
86
87
|
c.version = u, c.locktime = i;
|
|
87
88
|
for (const l of e) {
|
|
88
89
|
const d = p.from(l.txid, "hex").reverse();
|
|
@@ -91,7 +92,7 @@ function rt(n) {
|
|
|
91
92
|
for (const l of r)
|
|
92
93
|
c.addOutput(l.script, l.value);
|
|
93
94
|
if (a > H) {
|
|
94
|
-
const l =
|
|
95
|
+
const l = S.address.toOutputScript(s, o);
|
|
95
96
|
c.addOutput(l, Number(a));
|
|
96
97
|
}
|
|
97
98
|
return c.toHex();
|
|
@@ -100,7 +101,7 @@ function R(n) {
|
|
|
100
101
|
const t = n.startsWith("0x") ? n.slice(2) : n;
|
|
101
102
|
return `0x${E.fromHex(t).getId()}`;
|
|
102
103
|
}
|
|
103
|
-
function
|
|
104
|
+
function Tt(n, t, e) {
|
|
104
105
|
if (n.length === 0)
|
|
105
106
|
throw new Error("No input UTXOs provided for split transaction");
|
|
106
107
|
if (t.length === 0)
|
|
@@ -144,8 +145,8 @@ function Pt(n, t, e) {
|
|
|
144
145
|
outputs: o
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
|
-
function
|
|
148
|
-
const s = E.fromHex(n), a = new
|
|
148
|
+
function vt(n, t, e) {
|
|
149
|
+
const s = E.fromHex(n), a = new $();
|
|
149
150
|
if (a.setVersion(s.version), a.setLocktime(s.locktime), !p.isBuffer(e) || e.length !== 32)
|
|
150
151
|
throw new Error(
|
|
151
152
|
`Invalid publicKeyNoCoord: expected 32-byte Buffer (x-only pubkey), got ${p.isBuffer(e) ? `${e.length}-byte Buffer` : typeof e}`
|
|
@@ -290,7 +291,7 @@ async function ct(n, t) {
|
|
|
290
291
|
async function ut(n, t) {
|
|
291
292
|
return k(`${t}/tx/${n}`);
|
|
292
293
|
}
|
|
293
|
-
async function
|
|
294
|
+
async function kt(n, t) {
|
|
294
295
|
try {
|
|
295
296
|
const e = await fetch(`${t}/tx/${n}/hex`);
|
|
296
297
|
if (!e.ok) {
|
|
@@ -318,7 +319,7 @@ async function lt(n, t, e) {
|
|
|
318
319
|
scriptPubKey: a.scriptpubkey
|
|
319
320
|
};
|
|
320
321
|
}
|
|
321
|
-
async function
|
|
322
|
+
async function Et(n, t) {
|
|
322
323
|
try {
|
|
323
324
|
const e = await k(`${t}/address/${n}/utxo`), s = await k(`${t}/v1/validate-address/${n}`);
|
|
324
325
|
if (!s.isvalid)
|
|
@@ -340,13 +341,13 @@ async function kt(n, t) {
|
|
|
340
341
|
);
|
|
341
342
|
}
|
|
342
343
|
}
|
|
343
|
-
function
|
|
344
|
+
function It(n) {
|
|
344
345
|
return it[n];
|
|
345
346
|
}
|
|
346
|
-
async function
|
|
347
|
+
async function Bt(n, t) {
|
|
347
348
|
return k(`${t}/address/${n}/txs`);
|
|
348
349
|
}
|
|
349
|
-
async function
|
|
350
|
+
async function St(n) {
|
|
350
351
|
const t = await fetch(`${n}/v1/fees/recommended`);
|
|
351
352
|
if (!t.ok)
|
|
352
353
|
throw new Error(
|
|
@@ -588,7 +589,7 @@ function $t(n) {
|
|
|
588
589
|
return x[t] ?? x[e];
|
|
589
590
|
}
|
|
590
591
|
}
|
|
591
|
-
function
|
|
592
|
+
function Ct(n) {
|
|
592
593
|
const t = U(n);
|
|
593
594
|
if (t === void 0) return !1;
|
|
594
595
|
const e = t.substring(0, 10);
|
|
@@ -616,7 +617,7 @@ function K(n) {
|
|
|
616
617
|
}
|
|
617
618
|
throw n instanceof Error ? (console.error("[Contract Error] Unhandled error:", n.message), n) : new Error(`Contract call failed: ${String(n)}`);
|
|
618
619
|
}
|
|
619
|
-
class
|
|
620
|
+
class Ht {
|
|
620
621
|
/**
|
|
621
622
|
* Creates a new PeginManager instance.
|
|
622
623
|
*
|
|
@@ -692,7 +693,7 @@ class Ct {
|
|
|
692
693
|
const { fundedTxHex: e, depositorBtcPubkey: s } = t, a = e.startsWith("0x") ? e.slice(2) : e, o = E.fromHex(a);
|
|
693
694
|
if (o.ins.length === 0)
|
|
694
695
|
throw new Error("Transaction has no inputs");
|
|
695
|
-
const u = new
|
|
696
|
+
const u = new $();
|
|
696
697
|
u.setVersion(o.version), u.setLocktime(o.locktime);
|
|
697
698
|
const i = s.startsWith("0x") ? s.slice(2) : s;
|
|
698
699
|
if (i.length !== 64 || !/^[0-9a-fA-F]+$/.test(i))
|
|
@@ -733,7 +734,7 @@ class Ct {
|
|
|
733
734
|
script: h.script,
|
|
734
735
|
value: h.value
|
|
735
736
|
});
|
|
736
|
-
const f = await this.config.btcWallet.signPsbt(u.toHex()), g =
|
|
737
|
+
const f = await this.config.btcWallet.signPsbt(u.toHex()), g = $.fromHex(f);
|
|
737
738
|
try {
|
|
738
739
|
g.finalizeAllInputs();
|
|
739
740
|
} catch {
|
|
@@ -886,7 +887,7 @@ class Ct {
|
|
|
886
887
|
}
|
|
887
888
|
const s = C(this.config.btcNetwork);
|
|
888
889
|
try {
|
|
889
|
-
return `0x${
|
|
890
|
+
return `0x${S.address.toOutputScript(e, s).toString("hex")}`;
|
|
890
891
|
} catch {
|
|
891
892
|
throw new Error(
|
|
892
893
|
`Invalid BTC payout address: "${e}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
|
|
@@ -925,7 +926,7 @@ class Ct {
|
|
|
925
926
|
return this.config.vaultContracts.btcVaultsManager;
|
|
926
927
|
}
|
|
927
928
|
}
|
|
928
|
-
class
|
|
929
|
+
class Ut {
|
|
929
930
|
/**
|
|
930
931
|
* Creates a new PayoutManager instance.
|
|
931
932
|
*
|
|
@@ -1071,7 +1072,7 @@ class Ht {
|
|
|
1071
1072
|
}
|
|
1072
1073
|
}
|
|
1073
1074
|
export {
|
|
1074
|
-
|
|
1075
|
+
Ct as A,
|
|
1075
1076
|
N as B,
|
|
1076
1077
|
x as C,
|
|
1077
1078
|
H as D,
|
|
@@ -1080,25 +1081,26 @@ export {
|
|
|
1080
1081
|
Q as L,
|
|
1081
1082
|
V as M,
|
|
1082
1083
|
Z as P,
|
|
1084
|
+
wt as S,
|
|
1083
1085
|
G as T,
|
|
1084
1086
|
tt as W,
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
+
xt as a,
|
|
1088
|
+
Tt as b,
|
|
1087
1089
|
R as c,
|
|
1088
|
-
|
|
1090
|
+
vt as d,
|
|
1089
1091
|
v as e,
|
|
1090
1092
|
rt as f,
|
|
1091
|
-
|
|
1093
|
+
Pt as g,
|
|
1092
1094
|
ot as h,
|
|
1093
1095
|
at as i,
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1096
|
+
Ht as j,
|
|
1097
|
+
Ut as k,
|
|
1098
|
+
Bt as l,
|
|
1099
|
+
Et as m,
|
|
1100
|
+
It as n,
|
|
1101
|
+
St as o,
|
|
1100
1102
|
st as p,
|
|
1101
|
-
|
|
1103
|
+
kt as q,
|
|
1102
1104
|
et as r,
|
|
1103
1105
|
nt as s,
|
|
1104
1106
|
ut as t,
|
|
@@ -1109,4 +1111,4 @@ export {
|
|
|
1109
1111
|
U as y,
|
|
1110
1112
|
$t as z
|
|
1111
1113
|
};
|
|
1112
|
-
//# sourceMappingURL=PayoutManager-
|
|
1114
|
+
//# sourceMappingURL=PayoutManager-BkOfdb2_.js.map
|