@babylonlabs-io/ts-sdk 0.27.1 → 0.28.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/dist/{buildAndBroadcastRefund-BzYJv-Fv.js → buildAndBroadcastRefund-Cc4-L7gX.js} +32 -31
- package/dist/buildAndBroadcastRefund-Cc4-L7gX.js.map +1 -0
- package/dist/buildAndBroadcastRefund-OoaQaNqn.cjs +2 -0
- package/dist/buildAndBroadcastRefund-OoaQaNqn.cjs.map +1 -0
- package/dist/deriveVaultRoot-B4gnRbW_.cjs +2 -0
- package/dist/deriveVaultRoot-B4gnRbW_.cjs.map +1 -0
- package/dist/{context-ktqanzXE.js → deriveVaultRoot-DAMZDqg-.js} +495 -541
- package/dist/deriveVaultRoot-DAMZDqg-.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +55 -55
- package/dist/sha2-CPdTLk1u.js +280 -0
- package/dist/sha2-CPdTLk1u.js.map +1 -0
- package/dist/sha2-CsTynrfJ.cjs +2 -0
- package/dist/sha2-CsTynrfJ.cjs.map +1 -0
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/wallets/index.d.ts +2 -1
- package/dist/shared/wallets/index.d.ts.map +1 -1
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +8 -0
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -1
- package/dist/signing-BZigafm0.js.map +1 -1
- package/dist/signing-DHSXjhLM.cjs.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +2 -2
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +52 -52
- package/dist/tbv/core/services/deposit/peginState.d.ts +1 -1
- package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +1 -1
- package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts +13 -0
- package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/context.d.ts +9 -0
- package/dist/tbv/core/vault-secrets/context.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts +56 -0
- package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/expand.d.ts +18 -3
- package/dist/tbv/core/vault-secrets/expand.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/index.d.ts +6 -3
- package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
- package/dist/tbv/core/wots/blockDerivation.d.ts +20 -24
- package/dist/tbv/core/wots/blockDerivation.d.ts.map +1 -1
- package/dist/tbv/core/wots/errors.d.ts +3 -1
- package/dist/tbv/core/wots/errors.d.ts.map +1 -1
- package/dist/tbv/core/wots/index.d.ts +1 -2
- package/dist/tbv/core/wots/index.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +52 -52
- package/dist/testing/MockBitcoinWallet.d.ts +9 -3
- package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.js +65 -54
- package/dist/testing/index.js.map +1 -1
- package/dist/types-CQ86O7NX.js +650 -0
- package/dist/types-CQ86O7NX.js.map +1 -0
- package/dist/types-CcwaEPE1.cjs +2 -0
- package/dist/types-CcwaEPE1.cjs.map +1 -0
- package/dist/{vault-registry-reader-CpCOte7w.js → vault-registry-reader-CshEgmS0.js} +31 -30
- package/dist/{vault-registry-reader-CpCOte7w.js.map → vault-registry-reader-CshEgmS0.js.map} +1 -1
- package/dist/vault-registry-reader-_2BjSjoN.cjs +2 -0
- package/dist/{vault-registry-reader-BizmBSBV.cjs.map → vault-registry-reader-_2BjSjoN.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/buildAndBroadcastRefund-BEASMFsz.cjs +0 -2
- package/dist/buildAndBroadcastRefund-BEASMFsz.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-BzYJv-Fv.js.map +0 -1
- package/dist/context-B4fYDTxy.cjs +0 -2
- package/dist/context-B4fYDTxy.cjs.map +0 -1
- package/dist/context-ktqanzXE.js.map +0 -1
- package/dist/sha2-1XZuToHP.cjs +0 -2
- package/dist/sha2-1XZuToHP.cjs.map +0 -1
- package/dist/sha2-ZzfZqQSw.js +0 -1123
- package/dist/sha2-ZzfZqQSw.js.map +0 -1
- package/dist/tbv/core/wots/deriveWotsPkHash.d.ts +0 -9
- package/dist/tbv/core/wots/deriveWotsPkHash.d.ts.map +0 -1
- package/dist/vault-registry-reader-BizmBSBV.cjs +0 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for `deriveVaultRoot` — the SDK helper that wires a wallet's
|
|
3
|
+
* `deriveContextHash` API to the canonical `vaultContext` encoding.
|
|
4
|
+
*
|
|
5
|
+
* The helper is a thin pass-through; tests pin the wiring contract:
|
|
6
|
+
* - Forwards the hardcoded `appName` "babylon-vault" verbatim.
|
|
7
|
+
* - Forwards the hex of the 72-byte `vaultContext` (lowercase, 144 chars).
|
|
8
|
+
* - Decodes the wallet's 64-char hex output to 32 bytes.
|
|
9
|
+
* - Rejects malformed wallet output (wrong length / non-hex / uppercase).
|
|
10
|
+
* - Propagates wallet errors unchanged (user rejection, not-supported, etc.).
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=deriveVaultRoot.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveVaultRoot.test.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -38,6 +38,10 @@ export interface VaultContextInput {
|
|
|
38
38
|
* Outpoints are serialized as 36-byte `txid || vout_BE`, sorted
|
|
39
39
|
* ascending lexicographically, concatenated, then hashed.
|
|
40
40
|
*
|
|
41
|
+
* @stability frozen — on-chain-binding. Any change to layout, sort
|
|
42
|
+
* order, or serialization is a hard fork; existing deposits would no
|
|
43
|
+
* longer match their committed `depositorWotsPkHash`.
|
|
44
|
+
*
|
|
41
45
|
* @throws If `outpoints` is empty or contains duplicates.
|
|
42
46
|
*/
|
|
43
47
|
export declare function buildFundingOutpointsCommitment(outpoints: readonly FundingOutpoint[]): Uint8Array;
|
|
@@ -47,6 +51,11 @@ export declare function buildFundingOutpointsCommitment(outpoints: readonly Fund
|
|
|
47
51
|
* app side).
|
|
48
52
|
*
|
|
49
53
|
* Output length is always 72 bytes.
|
|
54
|
+
*
|
|
55
|
+
* @stability frozen — on-chain-binding. The 72-byte layout is the
|
|
56
|
+
* input to `deriveContextHash`; any change rotates the vault root and
|
|
57
|
+
* therefore every WOTS key, hashlock secret, and auth anchor derived
|
|
58
|
+
* from it. Existing deposits cannot be recovered after a layout change.
|
|
50
59
|
*/
|
|
51
60
|
export declare function buildVaultContext(input: VaultContextInput): Uint8Array;
|
|
52
61
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAeH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,UAAU,CAAC;IACjB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,kBAAkB,EAAE,UAAU,CAAC;IAC/B,yEAAyE;IACzE,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAoCD
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAeH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,UAAU,CAAC;IACjB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,kBAAkB,EAAE,UAAU,CAAC;IAC/B,yEAAyE;IACzE,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAoCD;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,SAAS,eAAe,EAAE,GACpC,UAAU,CAsBZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,CAqBtE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { VaultContextInput } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* The fixed `appName` passed to the wallet's `deriveContextHash` for
|
|
4
|
+
* Babylon vault derivations. The wallet displays this in its approval
|
|
5
|
+
* dialog. Defined by `derive-vault-secrets.md` §2.2 — must not be
|
|
6
|
+
* changed without coordinating a spec revision and a downstream
|
|
7
|
+
* migration plan, as it provides app-level domain separation across
|
|
8
|
+
* applications using the same wallet.
|
|
9
|
+
*/
|
|
10
|
+
export declare const VAULT_APP_NAME = "babylon-vault";
|
|
11
|
+
/**
|
|
12
|
+
* Minimal structural shape for the wallet capability needed by this
|
|
13
|
+
* helper. Typed against the method directly so callers can pass any
|
|
14
|
+
* value that implements `deriveContextHash` — `BitcoinWallet` from
|
|
15
|
+
* this SDK, `IBTCProvider` from `@babylonlabs-io/wallet-connector`,
|
|
16
|
+
* or a test mock — without depending on the rest of either interface.
|
|
17
|
+
*/
|
|
18
|
+
export interface DeriveContextHashCapableWallet {
|
|
19
|
+
deriveContextHash(appName: string, context: string): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Derive the 32-byte vault root from a wallet by encoding the
|
|
23
|
+
* canonical {@link VaultContextInput} and forwarding to
|
|
24
|
+
* `wallet.deriveContextHash`.
|
|
25
|
+
*
|
|
26
|
+
* Validates the wallet's output strictly: must be exactly 64
|
|
27
|
+
* lowercase hex characters per `derive-context-hash.md` §2.1. A
|
|
28
|
+
* conformant wallet always satisfies this, but we re-check at the
|
|
29
|
+
* SDK boundary so a non-conformant wallet (or a wallet returning a
|
|
30
|
+
* malformed value through a buggy adapter) fails loud here rather
|
|
31
|
+
* than producing silently-wrong derived secrets downstream.
|
|
32
|
+
*
|
|
33
|
+
* The helper itself produces only valid spec inputs (`appName` is
|
|
34
|
+
* the hardcoded `VAULT_APP_NAME`; `context` is hex of the 72-byte
|
|
35
|
+
* `vaultContext`, always 144 chars lowercase), so input-side
|
|
36
|
+
* validation is unnecessary.
|
|
37
|
+
*
|
|
38
|
+
* @param wallet - Any value implementing `deriveContextHash`.
|
|
39
|
+
* @param input - The canonical {@link VaultContextInput} that
|
|
40
|
+
* uniquely identifies the vault. Encoded by
|
|
41
|
+
* {@link buildVaultContext} into a 72-byte structure
|
|
42
|
+
* before being hex-encoded for the wallet.
|
|
43
|
+
* @stability frozen — on-chain-binding. The pair (`VAULT_APP_NAME`,
|
|
44
|
+
* `vaultContext` encoding) is the wallet's input space; changing
|
|
45
|
+
* either rotates the root and invalidates every secret derived from
|
|
46
|
+
* it. `VAULT_APP_NAME` is fixed by `derive-vault-secrets.md` §2.2
|
|
47
|
+
* and must never change without a coordinated spec revision.
|
|
48
|
+
*
|
|
49
|
+
* @returns 32-byte root suitable for {@link expandAuthAnchor},
|
|
50
|
+
* {@link expandHashlockSecret}, {@link expandWotsSeed}.
|
|
51
|
+
* @throws If the wallet returns a non-64-char or non-lowercase-hex
|
|
52
|
+
* string. Errors from the wallet (user rejection,
|
|
53
|
+
* method-not-supported, etc.) propagate unchanged.
|
|
54
|
+
*/
|
|
55
|
+
export declare function deriveVaultRoot(wallet: DeriveContextHashCapableWallet, input: VaultContextInput): Promise<Uint8Array>;
|
|
56
|
+
//# sourceMappingURL=deriveVaultRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveVaultRoot.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/deriveVaultRoot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEtE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAU9C;;;;;;GAMG;AACH,MAAM,WAAW,8BAA8B;IAC7C,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,8BAA8B,EACtC,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,UAAU,CAAC,CAuBrB"}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* `derive-vault-secrets.md` §2.2.
|
|
4
4
|
*
|
|
5
5
|
* Pure, synchronous expanders that derive three domain-separated
|
|
6
|
-
* secrets from a 32-byte `root`. The root is spec-opaque —
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* secrets from a 32-byte `root`. The root is spec-opaque — typically
|
|
7
|
+
* obtained via `deriveVaultRoot(wallet, vaultContextInput)` (which
|
|
8
|
+
* forwards to the wallet's `deriveContextHash`), but any 32-byte
|
|
9
|
+
* pseudorandom source satisfies the contract.
|
|
9
10
|
*
|
|
10
11
|
* All expand calls use HKDF-Expand-SHA-256 with `root` directly as the
|
|
11
12
|
* PRK (RFC 5869 §3.3: the Extract step is omitted when the input is
|
|
@@ -20,6 +21,10 @@
|
|
|
20
21
|
* `SHA256(authAnchor)` is committed as the OP_RETURN preimage hash in
|
|
21
22
|
* the Pre-PegIn; the raw preimage is revealed to the vault provider's
|
|
22
23
|
* `auth_createDepositorToken` RPC in exchange for a CWT bearer token.
|
|
24
|
+
*
|
|
25
|
+
* @stability frozen — on-chain-binding. Changing the HKDF info encoding
|
|
26
|
+
* (label or argument order) rotates the anchor and invalidates the VP
|
|
27
|
+
* bearer-token flow for existing deposits.
|
|
23
28
|
*/
|
|
24
29
|
export declare function expandAuthAnchor(root: Uint8Array): Uint8Array;
|
|
25
30
|
/**
|
|
@@ -29,6 +34,10 @@ export declare function expandAuthAnchor(root: Uint8Array): Uint8Array;
|
|
|
29
34
|
* `SHA256(hashlockSecret)` is committed as the HTLC taproot hashlock
|
|
30
35
|
* at vout = `htlcVout` in the Pre-PegIn. The raw preimage is revealed
|
|
31
36
|
* on Ethereum via `activateVaultWithSecret`.
|
|
37
|
+
*
|
|
38
|
+
* @stability frozen — on-chain-binding. Changing the HKDF info
|
|
39
|
+
* encoding produces a different secret whose SHA-256 will not match
|
|
40
|
+
* the on-chain hashlock; affected vaults can never be activated.
|
|
32
41
|
*/
|
|
33
42
|
export declare function expandHashlockSecret(root: Uint8Array, htlcVout: number): Uint8Array;
|
|
34
43
|
/**
|
|
@@ -38,6 +47,12 @@ export declare function expandHashlockSecret(root: Uint8Array, htlcVout: number)
|
|
|
38
47
|
* Fed into the per-vault WOTS block-keypair derivation. Only the
|
|
39
48
|
* `keccak256` hash of the derived public keys appears on-chain
|
|
40
49
|
* (committed as `depositorWotsPkHash`).
|
|
50
|
+
*
|
|
51
|
+
* @stability frozen — on-chain-binding. Changing the HKDF info
|
|
52
|
+
* encoding (label or htlcVout serialization) rotates the seed and
|
|
53
|
+
* therefore the WOTS keys; existing `depositorWotsPkHash` commitments
|
|
54
|
+
* would no longer match. Per-vault domain separation depends on the
|
|
55
|
+
* `i2osp4(htlcVout)` argument: do not change its encoding.
|
|
41
56
|
*/
|
|
42
57
|
export declare function expandWotsSeed(root: Uint8Array, htlcVout: number): Uint8Array;
|
|
43
58
|
//# sourceMappingURL=expand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/expand.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/expand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA0BH;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAQ7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM,GACf,UAAU,CAQZ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAQ7E"}
|
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
* from a single 32-byte root.
|
|
5
5
|
*
|
|
6
6
|
* Implements `derive-vault-secrets.md` §2.2 and Appendix A. The root is
|
|
7
|
-
* spec-opaque — callers produce it
|
|
8
|
-
*
|
|
9
|
-
* provenance-agnostic and only
|
|
7
|
+
* spec-opaque — callers produce it from `wallet.deriveContextHash` via
|
|
8
|
+
* {@link deriveVaultRoot} (canonical path), or from any other source
|
|
9
|
+
* that yields 32 bytes. The SDK is provenance-agnostic and only
|
|
10
|
+
* consumes the 32 bytes.
|
|
10
11
|
*
|
|
11
12
|
* @module tbv/core/vault-secrets
|
|
12
13
|
*/
|
|
13
14
|
export { expandAuthAnchor, expandHashlockSecret, expandWotsSeed, } from './expand';
|
|
14
15
|
export { buildFundingOutpointsCommitment, buildVaultContext } from './context';
|
|
15
16
|
export type { FundingOutpoint, VaultContextInput } from './context';
|
|
17
|
+
export { deriveVaultRoot, VAULT_APP_NAME } from './deriveVaultRoot';
|
|
18
|
+
export type { DeriveContextHashCapableWallet } from './deriveVaultRoot';
|
|
16
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE/E,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEpE,YAAY,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
import { WotsBlockPublicKey } from '../clients/vault-provider/types';
|
|
2
1
|
import { Hex } from 'viem';
|
|
2
|
+
import { WotsBlockPublicKey } from '../clients/vault-provider/types';
|
|
3
3
|
/**
|
|
4
|
-
* Derive
|
|
5
|
-
*
|
|
6
|
-
* Internally uses PBKDF2 with 2048 rounds of HMAC-SHA-512 and the passphrase
|
|
7
|
-
* `"mnemonic"` (no user password), per the BIP-39 specification.
|
|
4
|
+
* Derive deterministic WOTS block public keys from a per-vault 64-byte seed.
|
|
8
5
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* Derive deterministic WOTS block public keys for a specific vault.
|
|
6
|
+
* The seed must come from `expandWotsSeed(root, htlcVout)` (vault-secrets
|
|
7
|
+
* module). Per-vault uniqueness is encoded in `htlcVout`; this function
|
|
8
|
+
* only handles the chain derivation. Per-block 20-byte seeds are derived
|
|
9
|
+
* as `hash160(seed || blockIdx)` and fed into the standard Rust
|
|
10
|
+
* `babe::wots` chain logic.
|
|
15
11
|
*
|
|
16
|
-
*
|
|
17
|
-
* matching the Rust `Vec<babe::wots::PublicKey>` format expected by the
|
|
18
|
-
* vault provider's `submitDepositorWotsKey` RPC.
|
|
12
|
+
* The seed is zeroed in the `finally` block.
|
|
19
13
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
14
|
+
* @stability frozen — on-chain-binding. Per-block seed derivation,
|
|
15
|
+
* chain length, checksum-digit ordering, and terminal byte layout
|
|
16
|
+
* must match Rust `babe::wots` byte-for-byte. Any divergence rotates
|
|
17
|
+
* `depositorWotsPkHash` and breaks resume + on-chain verification
|
|
18
|
+
* for every existing vault.
|
|
22
19
|
*
|
|
23
|
-
* @param seed
|
|
24
|
-
* @param vaultId - Vault identifier / pegin tx hash (hex, with or without 0x prefix).
|
|
25
|
-
* @param depositorPk - Depositor's BTC public key (hex, with or without 0x prefix).
|
|
26
|
-
* @param appContractAddress - Application contract address.
|
|
20
|
+
* @param seed - 64-byte per-vault seed.
|
|
27
21
|
* @returns Array of 2 WOTS block public keys.
|
|
28
|
-
* @throws If seed
|
|
22
|
+
* @throws If `seed.length !== 64`.
|
|
29
23
|
*/
|
|
30
|
-
export declare function
|
|
24
|
+
export declare function deriveWotsBlocksFromSeed(seed: Uint8Array): Promise<WotsBlockPublicKey[]>;
|
|
31
25
|
/**
|
|
32
26
|
* Compute the keccak256 hash of WOTS block public keys.
|
|
33
27
|
*
|
|
@@ -39,8 +33,10 @@ export declare function deriveWotsBlockPublicKeys(seed: Uint8Array, vaultId: str
|
|
|
39
33
|
* The result is committed on-chain as `depositorWotsPkHash` so the vault
|
|
40
34
|
* provider can verify submitted WOTS public keys.
|
|
41
35
|
*
|
|
42
|
-
* @
|
|
43
|
-
*
|
|
36
|
+
* @stability frozen — on-chain-binding. Concatenation order of chain
|
|
37
|
+
* tips and the keccak256 input layout MUST match Rust
|
|
38
|
+
* `btc_vault::wots_public_keys_keccak256` byte-for-byte. Any change
|
|
39
|
+
* rotates the on-chain commitment and breaks every existing vault.
|
|
44
40
|
*/
|
|
45
41
|
export declare function computeWotsBlockPublicKeysHash(publicKeys: WotsBlockPublicKey[]): Hex;
|
|
46
42
|
//# sourceMappingURL=blockDerivation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockDerivation.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wots/blockDerivation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"blockDerivation.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wots/blockDerivation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,iCAAiC,CAAC;AAgJzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA+E/B;AAuBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,kBAAkB,EAAE,GAC/B,GAAG,CAmCL"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Check whether an error from the vault provider indicates that the
|
|
3
3
|
* submitted WOTS public key hash does not match the on-chain
|
|
4
|
-
* commitment. This signals that the wrong
|
|
4
|
+
* commitment. This signals that the wrong wallet is connected (its
|
|
5
|
+
* `deriveContextHash` produces a different vault root and therefore
|
|
6
|
+
* different WOTS keys).
|
|
5
7
|
*/
|
|
6
8
|
export declare function isWotsMismatchError(error: unknown): boolean;
|
|
7
9
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wots/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wots/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAc3D"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { deriveWotsPkHash } from './deriveWotsPkHash';
|
|
1
|
+
export { deriveWotsBlocksFromSeed, computeWotsBlockPublicKeysHash, } from './blockDerivation';
|
|
3
2
|
export { isWotsMismatchError } from './errors';
|
|
4
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wots/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wots/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/tbv/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../challengeAssert-BM8m9gPM.cjs"),P=require("@babylonlabs-io/babylon-tbv-rust-wasm"),d=require("../payout-DP6KMFP1.cjs"),a=require("../bitcoin-DIN0OupO.cjs"),l=require("../signing-DHSXjhLM.cjs"),u=require("../validation-u8W7Lp2x.cjs"),t=require("../buildAndBroadcastRefund-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../challengeAssert-BM8m9gPM.cjs"),P=require("@babylonlabs-io/babylon-tbv-rust-wasm"),d=require("../payout-DP6KMFP1.cjs"),a=require("../bitcoin-DIN0OupO.cjs"),l=require("../signing-DHSXjhLM.cjs"),u=require("../validation-u8W7Lp2x.cjs"),t=require("../buildAndBroadcastRefund-OoaQaNqn.cjs"),o=require("../fundPeginTransaction-DaWoYCgO.cjs"),i=require("../psbtInputFields-CB8hqjQ5.cjs"),r=require("../deriveVaultRoot-B4gnRbW_.cjs"),e=require("../vault-registry-reader-_2BjSjoN.cjs"),s=require("../types-CcwaEPE1.cjs");exports.buildChallengeAssertPsbt=n.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=n.buildDepositorPayoutPsbt;exports.buildNoPayoutPsbt=n.buildNoPayoutPsbt;exports.buildPeginInputPsbt=n.buildPeginInputPsbt;exports.buildPeginTxFromFundedPrePegin=n.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=n.buildPrePeginPsbt;exports.computeNumLocalChallengers=n.computeNumLocalChallengers;exports.extractPeginInputSignature=n.extractPeginInputSignature;exports.finalizePeginInputPsbt=n.finalizePeginInputPsbt;Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>P.computeMinClaimValue});Object.defineProperty(exports,"deriveVaultId",{enumerable:!0,get:()=>P.deriveVaultId});exports.buildPayoutPsbt=d.buildPayoutPsbt;exports.buildRefundPsbt=d.buildRefundPsbt;exports.createPayoutScript=d.createPayoutScript;exports.extractPayoutSignature=d.extractPayoutSignature;exports.deriveNativeSegwitAddress=a.deriveNativeSegwitAddress;exports.deriveTaprootAddress=a.deriveTaprootAddress;exports.ensureHexPrefix=a.ensureHexPrefix;exports.formatSatoshisToBtc=a.formatSatoshisToBtc;exports.getNetwork=a.getNetwork;exports.hexToUint8Array=a.hexToUint8Array;exports.isAddressFromPublicKey=a.isAddressFromPublicKey;exports.isValidHex=a.isValidHex;exports.processPublicKeyToXOnly=a.processPublicKeyToXOnly;exports.stripHexPrefix=a.stripHexPrefix;exports.toXOnly=a.toXOnly;exports.uint8ArrayToHex=a.uint8ArrayToHex;exports.validateWalletPubkey=a.validateWalletPubkey;exports.ContractStatus=l.ContractStatus;exports.PeginAction=l.PeginAction;exports.canPerformAction=l.canPerformAction;exports.createTaprootScriptPathSignOptions=l.createTaprootScriptPathSignOptions;exports.getPeginProtocolState=l.getPeginProtocolState;exports.BITCOIN_ADDRESS_RE=u.BITCOIN_ADDRESS_RE;exports.HEX_RE=u.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=u.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=u.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=u.TXID_RE;exports.BIP68NotMatureError=t.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=t.ClaimerPegoutStatusValue;exports.PayoutManager=t.PayoutManager;exports.activateVault=t.activateVault;exports.buildAndBroadcastRefund=t.buildAndBroadcastRefund;exports.computeHashlock=t.computeHashlock;exports.isDepositAmountValid=t.isDepositAmountValid;exports.isPegoutTerminalStatus=t.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=t.isRecognizedPegoutStatus;exports.pollAndSignPayouts=t.pollAndSignPayouts;exports.signDepositorGraph=t.signDepositorGraph;exports.submitWotsPublicKey=t.submitWotsPublicKey;exports.validateDepositAmount=t.validateDepositAmount;exports.validateMultiVaultDepositInputs=t.validateMultiVaultDepositInputs;exports.validateProviderSelection=t.validateProviderSelection;exports.validateRemainingCapacity=t.validateRemainingCapacity;exports.validateSecretAgainstHashlock=t.validateSecretAgainstHashlock;exports.validateVaultAmounts=t.validateVaultAmounts;exports.validateVaultProviderPubkey=t.validateVaultProviderPubkey;exports.waitForPeginStatus=t.waitForPeginStatus;exports.BTC_DUST_SAT=o.BTC_DUST_SAT;exports.DUST_THRESHOLD=o.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=o.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=o.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=o.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=o.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=o.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=o.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=o.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=o.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=o.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=o.fundPeginTransaction;exports.parseUnfundedWasmTransaction=o.parseUnfundedWasmTransaction;exports.peginOutputCount=o.peginOutputCount;exports.rateBasedTxBufferFee=o.rateBasedTxBufferFee;exports.BitcoinScriptType=i.BitcoinScriptType;exports.UtxoNotAvailableError=i.UtxoNotAvailableError;exports.assertUtxosAvailable=i.assertUtxosAvailable;exports.calculateBtcTxHash=i.calculateBtcTxHash;exports.collectReservedUtxoRefs=i.collectReservedUtxoRefs;exports.extractInputsFromTransaction=i.extractInputsFromTransaction;exports.getDustThreshold=i.getDustThreshold;exports.getPsbtInputFields=i.getPsbtInputFields;exports.getScriptType=i.getScriptType;exports.selectUtxosForDeposit=i.selectUtxosForDeposit;exports.selectUtxosForPegin=i.selectUtxosForPegin;exports.shouldAddChangeOutput=i.shouldAddChangeOutput;exports.validateUtxosAvailable=i.validateUtxosAvailable;exports.CONTRACT_ERRORS=r.CONTRACT_ERRORS;exports.PeginManager=r.PeginManager;exports.VAULT_APP_NAME=r.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=r.buildFundingOutpointsCommitment;exports.buildVaultContext=r.buildVaultContext;exports.computeWotsBlockPublicKeysHash=r.computeWotsBlockPublicKeysHash;exports.deriveVaultRoot=r.deriveVaultRoot;exports.deriveWotsBlocksFromSeed=r.deriveWotsBlocksFromSeed;exports.expandAuthAnchor=r.expandAuthAnchor;exports.expandHashlockSecret=r.expandHashlockSecret;exports.expandWotsSeed=r.expandWotsSeed;exports.extractErrorData=r.extractErrorData;exports.getContractErrorMessage=r.getContractErrorMessage;exports.handleContractError=r.handleContractError;exports.isKnownContractError=r.isKnownContractError;exports.isWotsMismatchError=r.isWotsMismatchError;exports.ApplicationRegistryABI=e.ApplicationRegistryABI;exports.MEMPOOL_API_URLS=e.MEMPOOL_API_URLS;exports.ProtocolParamsABI=e.ProtocolParamsABI;exports.ServerIdentityError=e.ServerIdentityError;exports.VaultProviderRpcClient=e.VaultProviderRpcClient;exports.ViemProtocolParamsReader=e.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=e.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=e.ViemVaultKeeperReader;exports.ViemVaultRegistryReader=e.ViemVaultRegistryReader;exports.VpResponseValidationError=e.VpResponseValidationError;exports.VpTokenProvider=e.VpTokenProvider;exports.getAddressTxs=e.getAddressTxs;exports.getAddressUtxos=e.getAddressUtxos;exports.getMempoolApiUrl=e.getMempoolApiUrl;exports.getNetworkFees=e.getNetworkFees;exports.getTxHex=e.getTxHex;exports.getTxInfo=e.getTxInfo;exports.getUtxoInfo=e.getUtxoInfo;exports.pushTx=e.pushTx;exports.resolveProtocolAddresses=e.resolveProtocolAddresses;exports.validateRequestDepositorClaimerArtifactsResponse=e.validateRequestDepositorClaimerArtifactsResponse;exports.verifyServerIdentity=e.verifyServerIdentity;exports.BTCVaultRegistryABI=s.BTCVaultRegistryABI;exports.DaemonStatus=s.DaemonStatus;exports.JSON_RPC_ERROR_CODES=s.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=s.JsonRpcClient;exports.JsonRpcError=s.JsonRpcError;exports.POST_WOTS_STATUSES=s.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=s.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=s.RpcErrorCode;exports.VP_TERMINAL_STATUSES=s.VP_TERMINAL_STATUSES;exports.VP_TRANSIENT_STATUSES=s.VP_TRANSIENT_STATUSES;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/tbv/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { i as e, g as t, h as r, d as o, a as i, b as n, c as l, e as u, f as d } from "../challengeAssert-j2Vwqo0-.js";
|
|
2
2
|
import { computeMinClaimValue as c, deriveVaultId as T } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
3
|
-
import { a as S, b as
|
|
4
|
-
import { d as
|
|
5
|
-
import { C as F, P as B, a as D, c as
|
|
3
|
+
import { a as S, b as A, c as E, e as _ } from "../payout-B_fvQU3q.js";
|
|
4
|
+
import { d as R, a as m, e as x, f as b, g as I, h as f, i as v, b as C, p as U, s as O, t as V, u as h, v as y } from "../bitcoin-B-Y0DlqR.js";
|
|
5
|
+
import { C as F, P as B, a as D, c as M, g as H } from "../signing-BZigafm0.js";
|
|
6
6
|
import { B as k, H as W, K as X, M as K, T as w } from "../validation-CxqROCno.js";
|
|
7
|
-
import { B as Y, C as J, P as j, a as Z, m as z, h as q, i as Q, l as $, k as aa, p as sa, b as ea, s as ta, v as ra, g as oa, d as ia, c as na, j as la, e as ua, f as da, w as Pa } from "../buildAndBroadcastRefund-
|
|
8
|
-
import { B as Ta, D as pa, F as Sa, L as
|
|
9
|
-
import { B as Oa, U as
|
|
10
|
-
import { C as Ka, P as wa,
|
|
11
|
-
import { A as is, M as ns, P as ls, S as us, V as ds, k as Ps, l as cs, m as Ts, n as ps, h as Ss, j as
|
|
12
|
-
import { B as Os, D as
|
|
7
|
+
import { B as Y, C as J, P as j, a as Z, m as z, h as q, i as Q, l as $, k as aa, p as sa, b as ea, s as ta, v as ra, g as oa, d as ia, c as na, j as la, e as ua, f as da, w as Pa } from "../buildAndBroadcastRefund-Cc4-L7gX.js";
|
|
8
|
+
import { B as Ta, D as pa, F as Sa, L as Aa, M as Ea, P as _a, b as ga, a as Ra, S as ma, T as xa, W as ba, f as Ia, c as fa, p as va, r as Ca } from "../fundPeginTransaction-oV-dNJOU.js";
|
|
9
|
+
import { B as Oa, U as Va, a as ha, f as ya, c as Na, e as Fa, g as Ba, i as Da, h as Ma, s as Ha, b as La, d as ka, v as Wa } from "../psbtInputFields-DeTFSJOq.js";
|
|
10
|
+
import { C as Ka, P as wa, V as Ga, k as Ya, l as Ja, c as ja, m as Za, d as za, b as qa, f as Qa, j as $a, e as as, g as ss, h as es, i as ts, a as rs } from "../deriveVaultRoot-DAMZDqg-.js";
|
|
11
|
+
import { A as is, M as ns, P as ls, S as us, V as ds, k as Ps, l as cs, m as Ts, n as ps, h as Ss, j as As, g as Es, a as _s, b as gs, c as Rs, d as ms, e as xs, f as bs, p as Is, r as fs, v as vs, i as Cs } from "../vault-registry-reader-CshEgmS0.js";
|
|
12
|
+
import { B as Os, D as Vs, b as hs, J as ys, a as Ns, d as Fs, P as Bs, R as Ds, c as Ms, V as Hs } from "../types-CQ86O7NX.js";
|
|
13
13
|
export {
|
|
14
14
|
is as ApplicationRegistryABI,
|
|
15
15
|
Y as BIP68NotMatureError,
|
|
@@ -21,20 +21,20 @@ export {
|
|
|
21
21
|
J as ClaimerPegoutStatusValue,
|
|
22
22
|
F as ContractStatus,
|
|
23
23
|
pa as DUST_THRESHOLD,
|
|
24
|
-
|
|
24
|
+
Vs as DaemonStatus,
|
|
25
25
|
Sa as FEE_SAFETY_MARGIN,
|
|
26
26
|
W as HEX_RE,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
hs as JSON_RPC_ERROR_CODES,
|
|
28
|
+
ys as JsonRpcClient,
|
|
29
29
|
Ns as JsonRpcError,
|
|
30
30
|
X as KNOWN_SCRIPT_PREFIXES,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
Aa as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
|
|
32
|
+
Ea as MAX_NON_LEGACY_OUTPUT_SIZE,
|
|
33
33
|
K as MAX_REASONABLE_FEE_SATS,
|
|
34
34
|
ns as MEMPOOL_API_URLS,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
_a as P2TR_INPUT_SIZE,
|
|
36
|
+
ga as PEGIN_AUTH_ANCHOR_OUTPUTS,
|
|
37
|
+
Ra as PEGIN_FIXED_OUTPUTS,
|
|
38
38
|
Fs as POST_WOTS_STATUSES,
|
|
39
39
|
Bs as PRE_DEPOSITOR_SIGNATURES_STATES,
|
|
40
40
|
j as PayoutManager,
|
|
@@ -46,78 +46,78 @@ export {
|
|
|
46
46
|
us as ServerIdentityError,
|
|
47
47
|
w as TXID_RE,
|
|
48
48
|
xa as TX_BUFFER_SIZE_OVERHEAD,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Ms as
|
|
49
|
+
Va as UtxoNotAvailableError,
|
|
50
|
+
Ga as VAULT_APP_NAME,
|
|
51
|
+
Ms as VP_TERMINAL_STATUSES,
|
|
52
|
+
Hs as VP_TRANSIENT_STATUSES,
|
|
52
53
|
ds as VaultProviderRpcClient,
|
|
53
54
|
Ps as ViemProtocolParamsReader,
|
|
54
55
|
cs as ViemUniversalChallengerReader,
|
|
55
56
|
Ts as ViemVaultKeeperReader,
|
|
56
57
|
ps as ViemVaultRegistryReader,
|
|
57
58
|
Ss as VpResponseValidationError,
|
|
58
|
-
|
|
59
|
+
As as VpTokenProvider,
|
|
59
60
|
ba as WALLET_RELAY_FEE_RATE_THRESHOLD,
|
|
60
61
|
Z as activateVault,
|
|
61
|
-
|
|
62
|
+
ha as assertUtxosAvailable,
|
|
62
63
|
z as buildAndBroadcastRefund,
|
|
63
64
|
e as buildChallengeAssertPsbt,
|
|
64
65
|
t as buildDepositorPayoutPsbt,
|
|
65
|
-
|
|
66
|
+
Ya as buildFundingOutpointsCommitment,
|
|
66
67
|
r as buildNoPayoutPsbt,
|
|
67
68
|
S as buildPayoutPsbt,
|
|
68
69
|
o as buildPeginInputPsbt,
|
|
69
70
|
i as buildPeginTxFromFundedPrePegin,
|
|
70
71
|
n as buildPrePeginPsbt,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
A as buildRefundPsbt,
|
|
73
|
+
Ja as buildVaultContext,
|
|
74
|
+
ya as calculateBtcTxHash,
|
|
74
75
|
D as canPerformAction,
|
|
75
76
|
Na as collectReservedUtxoRefs,
|
|
76
77
|
q as computeHashlock,
|
|
77
78
|
c as computeMinClaimValue,
|
|
78
79
|
l as computeNumLocalChallengers,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
ja as computeWotsBlockPublicKeysHash,
|
|
81
|
+
E as createPayoutScript,
|
|
82
|
+
M as createTaprootScriptPathSignOptions,
|
|
83
|
+
R as deriveNativeSegwitAddress,
|
|
83
84
|
m as deriveTaprootAddress,
|
|
84
85
|
T as deriveVaultId,
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
Za as deriveVaultRoot,
|
|
87
|
+
za as deriveWotsBlocksFromSeed,
|
|
87
88
|
x as ensureHexPrefix,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
qa as expandAuthAnchor,
|
|
90
|
+
Qa as expandHashlockSecret,
|
|
91
|
+
$a as expandWotsSeed,
|
|
92
|
+
as as extractErrorData,
|
|
92
93
|
Fa as extractInputsFromTransaction,
|
|
93
|
-
|
|
94
|
+
_ as extractPayoutSignature,
|
|
94
95
|
u as extractPeginInputSignature,
|
|
95
96
|
d as finalizePeginInputPsbt,
|
|
96
97
|
b as formatSatoshisToBtc,
|
|
97
98
|
Ia as fundPeginTransaction,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
Es as getAddressTxs,
|
|
100
|
+
_s as getAddressUtxos,
|
|
101
|
+
ss as getContractErrorMessage,
|
|
101
102
|
Ba as getDustThreshold,
|
|
102
|
-
|
|
103
|
+
gs as getMempoolApiUrl,
|
|
103
104
|
I as getNetwork,
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
Rs as getNetworkFees,
|
|
106
|
+
H as getPeginProtocolState,
|
|
106
107
|
Da as getPsbtInputFields,
|
|
107
|
-
|
|
108
|
+
Ma as getScriptType,
|
|
108
109
|
ms as getTxHex,
|
|
109
110
|
xs as getTxInfo,
|
|
110
111
|
bs as getUtxoInfo,
|
|
111
|
-
|
|
112
|
+
es as handleContractError,
|
|
112
113
|
f as hexToUint8Array,
|
|
113
114
|
v as isAddressFromPublicKey,
|
|
114
115
|
Q as isDepositAmountValid,
|
|
115
|
-
|
|
116
|
+
ts as isKnownContractError,
|
|
116
117
|
$ as isPegoutTerminalStatus,
|
|
117
118
|
aa as isRecognizedPegoutStatus,
|
|
118
119
|
C as isValidHex,
|
|
119
|
-
|
|
120
|
-
rs as mnemonicToWotsSeed,
|
|
120
|
+
rs as isWotsMismatchError,
|
|
121
121
|
fa as parseUnfundedWasmTransaction,
|
|
122
122
|
va as peginOutputCount,
|
|
123
123
|
sa as pollAndSignPayouts,
|
|
@@ -125,14 +125,14 @@ export {
|
|
|
125
125
|
Is as pushTx,
|
|
126
126
|
Ca as rateBasedTxBufferFee,
|
|
127
127
|
fs as resolveProtocolAddresses,
|
|
128
|
-
|
|
128
|
+
Ha as selectUtxosForDeposit,
|
|
129
129
|
La as selectUtxosForPegin,
|
|
130
130
|
ka as shouldAddChangeOutput,
|
|
131
131
|
ea as signDepositorGraph,
|
|
132
132
|
O as stripHexPrefix,
|
|
133
133
|
ta as submitWotsPublicKey,
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
V as toXOnly,
|
|
135
|
+
h as uint8ArrayToHex,
|
|
136
136
|
ra as validateDepositAmount,
|
|
137
137
|
oa as validateMultiVaultDepositInputs,
|
|
138
138
|
ia as validateProviderSelection,
|
|
@@ -142,7 +142,7 @@ export {
|
|
|
142
142
|
Wa as validateUtxosAvailable,
|
|
143
143
|
ua as validateVaultAmounts,
|
|
144
144
|
da as validateVaultProviderPubkey,
|
|
145
|
-
|
|
145
|
+
y as validateWalletPubkey,
|
|
146
146
|
Cs as verifyServerIdentity,
|
|
147
147
|
Pa as waitForPeginStatus
|
|
148
148
|
};
|
|
@@ -8,10 +8,15 @@ export interface MockBitcoinWalletConfig {
|
|
|
8
8
|
address?: string;
|
|
9
9
|
network?: BitcoinNetwork;
|
|
10
10
|
shouldFailSigning?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Optional override for `deriveContextHash`. When omitted the mock
|
|
13
|
+
* returns a deterministic 64-char lowercase hex string derived from
|
|
14
|
+
* `(appName, context)` so tests can assert pass-through wiring
|
|
15
|
+
* without pinning a specific value. Override to inject spec test
|
|
16
|
+
* vectors or to simulate failure modes.
|
|
17
|
+
*/
|
|
18
|
+
deriveContextHash?: (appName: string, context: string) => Promise<string>;
|
|
11
19
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Mock Bitcoin wallet for testing.
|
|
14
|
-
*/
|
|
15
20
|
export declare class MockBitcoinWallet implements BitcoinWallet {
|
|
16
21
|
private config;
|
|
17
22
|
constructor(config?: MockBitcoinWalletConfig);
|
|
@@ -21,6 +26,7 @@ export declare class MockBitcoinWallet implements BitcoinWallet {
|
|
|
21
26
|
signPsbts(psbtsHexes: string[], _options?: SignPsbtOptions[]): Promise<string[]>;
|
|
22
27
|
signMessage(message: string, type: "bip322-simple" | "ecdsa"): Promise<string>;
|
|
23
28
|
getNetwork(): Promise<BitcoinNetwork>;
|
|
29
|
+
deriveContextHash(appName: string, context: string): Promise<string>;
|
|
24
30
|
/** Updates configuration for testing different scenarios. */
|
|
25
31
|
updateConfig(updates: Partial<MockBitcoinWalletConfig>): void;
|
|
26
32
|
/** Resets to default configuration. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MockBitcoinWallet.d.ts","sourceRoot":"","sources":["../../src/testing/MockBitcoinWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MockBitcoinWallet.d.ts","sourceRoot":"","sources":["../../src/testing/MockBitcoinWallet.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACpF,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAChB,MAAM,4CAA4C,CAAC;AAGpD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3E;AA6BD,qBAAa,iBAAkB,YAAW,aAAa;IACrD,OAAO,CAAC,MAAM,CAAoC;gBAEtC,MAAM,GAAE,uBAA4B;IAc1C,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAc1C,SAAS,CACb,UAAU,EAAE,MAAM,EAAE,EACpB,QAAQ,CAAC,EAAE,eAAe,EAAE,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC;IASd,WAAW,CACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,eAAe,GAAG,OAAO,GAC9B,OAAO,CAAC,MAAM,CAAC;IAiBZ,UAAU,IAAI,OAAO,CAAC,cAAc,CAAC;IAIrC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1E,6DAA6D;IAC7D,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAAG,IAAI;IAO7D,uCAAuC;IACvC,KAAK,IAAI,IAAI;CAUd"}
|
package/dist/testing/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var l=(i,t,e)=>t in i?d(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>l(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../sha2-CsTynrfJ.cjs"),r=require("buffer"),u=require("../bitcoin-DIN0OupO.cjs"),q=require("../shared/index.cjs"),h=async(i,t)=>{const e=new TextEncoder,n=e.encode(i),s=e.encode(t),a=new Uint8Array(4+n.length+4+s.length),c=new DataView(a.buffer);return c.setUint32(0,n.length),a.set(n,4),c.setUint32(4+n.length,s.length),a.set(s,4+n.length+4),u.uint8ArrayToHex(g.sha256(a))};class f{constructor(t={}){o(this,"config");this.config={publicKeyHex:t.publicKeyHex||"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",address:t.address||"tb1pqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx6jks",network:t.network??q.BitcoinNetworks.SIGNET,shouldFailSigning:t.shouldFailSigning??!1,deriveContextHash:t.deriveContextHash??h}}async getPublicKeyHex(){return this.config.publicKeyHex}async getAddress(){return this.config.address}async signPsbt(t){if(this.config.shouldFailSigning)throw new Error("Mock signing failed");if(!t||t.length===0)throw new Error("Invalid PSBT: empty hex string");return t+"deadbeef"}async signPsbts(t,e){const n=[];for(const s of t){const a=await this.signPsbt(s);n.push(a)}return n}async signMessage(t,e){if(this.config.shouldFailSigning)throw new Error("Mock signing failed");if(!t||t.length===0)throw new Error("Invalid message: empty string");return r.Buffer.from(`mock-signature-${e}-${t}-${this.config.publicKeyHex}`).toString("base64")}async getNetwork(){return this.config.network}async deriveContextHash(t,e){return this.config.deriveContextHash(t,e)}updateConfig(t){this.config={...this.config,...t}}reset(){this.config={publicKeyHex:"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",address:"tb1pqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx6jks",network:q.BitcoinNetworks.SIGNET,shouldFailSigning:!1,deriveContextHash:h}}}class b{constructor(t={}){o(this,"account");o(this,"chain");o(this,"shouldFailOperations");o(this,"transactionDelay");o(this,"nonce",0);this.account={address:t.address||"0x742d35cc6634c0532925a3b844bc9e7595f0beb0"},this.chain={id:t.chainId??11155111},this.shouldFailOperations=t.shouldFailOperations??!1,this.transactionDelay=t.transactionDelay??0,this.signMessage=this.signMessage.bind(this),this.sendTransaction=this.sendTransaction.bind(this)}async signMessage(t){const e=t.message,n=t.account||this.account.address;if(this.shouldFailOperations)throw new Error("Mock signing failed");if(!e||e.length===0)throw new Error("Invalid message: empty string");const s=`personal_sign:${e}-${n}-${this.chain.id}`;return`0x${r.Buffer.from(s).toString("hex").slice(0,130).padEnd(130,"0")}`}async sendTransaction(t){var s;if(this.shouldFailOperations)throw new Error("Mock transaction failed");if(!t.to)throw new Error("Invalid transaction: missing 'to' address");this.transactionDelay>0&&await new Promise(a=>setTimeout(a,this.transactionDelay)),this.nonce++;const e=JSON.stringify({from:this.account.address,to:t.to,value:((s=t.value)==null?void 0:s.toString())||"0",nonce:this.nonce,chainId:this.chain.id});return`0x${r.Buffer.from(e).toString("hex").slice(0,64).padEnd(64,"0")}`}updateConfig(t){t.address!==void 0&&(this.account.address=t.address),t.chainId!==void 0&&(this.chain.id=t.chainId),t.shouldFailOperations!==void 0&&(this.shouldFailOperations=t.shouldFailOperations),t.transactionDelay!==void 0&&(this.transactionDelay=t.transactionDelay)}reset(){this.account.address="0x742d35cc6634c0532925a3b844bc9e7595f0beb0",this.chain.id=11155111,this.shouldFailOperations=!1,this.transactionDelay=0,this.nonce=0}getCurrentNonce(){return this.nonce}}exports.MockBitcoinWallet=f;exports.MockEthereumWallet=b;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|