@buildonspark/spark-sdk 0.1.44 → 0.1.46
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/CHANGELOG.md +17 -0
- package/dist/{RequestLightningSendInput-BxbCtwpV.d.cts → RequestLightningSendInput-2cSh_In4.d.cts} +1 -1
- package/dist/{RequestLightningSendInput-RGel43ks.d.ts → RequestLightningSendInput-CN6BNg_g.d.ts} +1 -1
- package/dist/address/index.cjs +2 -2
- package/dist/address/index.d.cts +2 -2
- package/dist/address/index.d.ts +2 -2
- package/dist/address/index.js +2 -2
- package/dist/{chunk-EKFD62HN.js → chunk-4EMV7HHW.js} +2 -1
- package/dist/{chunk-4Q2ZDYYU.js → chunk-BGGEVUJK.js} +1157 -208
- package/dist/{chunk-CIZNCBKE.js → chunk-C2S227QR.js} +648 -45
- package/dist/{chunk-WPTRVD2V.js → chunk-DXR2PXJU.js} +15 -15
- package/dist/{chunk-NBCNYDWJ.js → chunk-HHNQ3ZHC.js} +2 -2
- package/dist/{chunk-DAXGVPVM.js → chunk-HSCLBJEL.js} +2 -2
- package/dist/{chunk-6AFUC5M2.js → chunk-HWJWKEIU.js} +8 -2
- package/dist/{chunk-A2ZLMH6I.js → chunk-JB64OQES.js} +259 -327
- package/dist/{chunk-KEKGSH7B.js → chunk-KMUMFYFX.js} +3 -3
- package/dist/chunk-LHRD2WT6.js +2374 -0
- package/dist/{chunk-HTMXTJRK.js → chunk-N5VZVCGJ.js} +4 -4
- package/dist/{chunk-SQKXGAIR.js → chunk-NTFKFRQ2.js} +1 -1
- package/dist/{chunk-K4BJARWM.js → chunk-OBFKIEMP.js} +1 -1
- package/dist/{chunk-UBT6EDVJ.js → chunk-OFCJFZ4I.js} +1 -1
- package/dist/{chunk-XX4RRWOX.js → chunk-UXDODSDT.js} +8 -10
- package/dist/graphql/objects/index.d.cts +5 -4
- package/dist/graphql/objects/index.d.ts +5 -4
- package/dist/index-CKL5DodV.d.cts +214 -0
- package/dist/index-COm59SPw.d.ts +214 -0
- package/dist/index.cjs +4026 -1315
- package/dist/index.d.cts +764 -19
- package/dist/index.d.ts +764 -19
- package/dist/index.js +23 -27
- package/dist/index.node.cjs +4026 -1319
- package/dist/index.node.d.cts +10 -8
- package/dist/index.node.d.ts +10 -8
- package/dist/index.node.js +23 -31
- package/dist/native/index.cjs +4027 -1316
- package/dist/native/index.d.cts +281 -85
- package/dist/native/index.d.ts +281 -85
- package/dist/native/index.js +4018 -1307
- package/dist/{network-CfxLnaot.d.cts → network-Css46DAz.d.cts} +1 -1
- package/dist/{network-CroCOQ0B.d.ts → network-hynb7iTZ.d.ts} +1 -1
- package/dist/proto/lrc20.cjs +222 -19
- package/dist/proto/lrc20.d.cts +1 -1
- package/dist/proto/lrc20.d.ts +1 -1
- package/dist/proto/lrc20.js +2 -2
- package/dist/proto/spark.cjs +1154 -205
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +3 -1
- package/dist/proto/spark_token.cjs +1377 -58
- package/dist/proto/spark_token.d.cts +153 -15
- package/dist/proto/spark_token.d.ts +153 -15
- package/dist/proto/spark_token.js +40 -4
- package/dist/{sdk-types-CTbTdDbE.d.ts → sdk-types-CKBsylfW.d.ts} +1 -1
- package/dist/{sdk-types-BeCBoozO.d.cts → sdk-types-Ct8xmN7l.d.cts} +1 -1
- package/dist/services/config.cjs +2 -2
- package/dist/services/config.d.cts +5 -4
- package/dist/services/config.d.ts +5 -4
- package/dist/services/config.js +6 -6
- package/dist/services/connection.cjs +2438 -262
- package/dist/services/connection.d.cts +5 -4
- package/dist/services/connection.d.ts +5 -4
- package/dist/services/connection.js +4 -4
- package/dist/services/index.cjs +5937 -3154
- package/dist/services/index.d.cts +7 -6
- package/dist/services/index.d.ts +7 -6
- package/dist/services/index.js +17 -15
- package/dist/services/lrc-connection.cjs +223 -20
- package/dist/services/lrc-connection.d.cts +5 -4
- package/dist/services/lrc-connection.d.ts +5 -4
- package/dist/services/lrc-connection.js +4 -4
- package/dist/services/token-transactions.cjs +840 -236
- package/dist/services/token-transactions.d.cts +25 -7
- package/dist/services/token-transactions.d.ts +25 -7
- package/dist/services/token-transactions.js +5 -4
- package/dist/services/wallet-config.cjs +3 -1
- package/dist/services/wallet-config.d.cts +7 -5
- package/dist/services/wallet-config.d.ts +7 -5
- package/dist/services/wallet-config.js +3 -1
- package/dist/signer/signer.cjs +1 -1
- package/dist/signer/signer.d.cts +3 -2
- package/dist/signer/signer.d.ts +3 -2
- package/dist/signer/signer.js +2 -2
- package/dist/{signer-D7vfYik9.d.ts → signer-BP6F__oR.d.cts} +2 -6
- package/dist/{signer-DaY8c60s.d.cts → signer-BVZJXcq7.d.ts} +2 -6
- package/dist/{spark-C4ZrsgjC.d.cts → spark-DbzGfse6.d.cts} +93 -15
- package/dist/{spark-C4ZrsgjC.d.ts → spark-DbzGfse6.d.ts} +93 -15
- package/dist/spark_bindings/native/index.cjs +183 -0
- package/dist/spark_bindings/native/index.d.cts +14 -0
- package/dist/spark_bindings/native/index.d.ts +14 -0
- package/dist/spark_bindings/native/index.js +141 -0
- package/dist/spark_bindings/wasm/index.cjs +1093 -0
- package/dist/spark_bindings/wasm/index.d.cts +47 -0
- package/dist/spark_bindings/wasm/index.d.ts +47 -0
- package/dist/{chunk-K4C4W5FC.js → spark_bindings/wasm/index.js} +7 -6
- package/dist/types/index.cjs +1156 -208
- package/dist/types/index.d.cts +5 -4
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.js +2 -2
- package/dist/types-C-Rp0Oo7.d.cts +46 -0
- package/dist/types-C-Rp0Oo7.d.ts +46 -0
- package/dist/utils/index.cjs +65 -13
- package/dist/utils/index.d.cts +14 -134
- package/dist/utils/index.d.ts +14 -134
- package/dist/utils/index.js +13 -13
- package/package.json +22 -2
- package/src/index.node.ts +0 -1
- package/src/index.ts +0 -1
- package/src/native/index.ts +1 -2
- package/src/proto/common.ts +5 -5
- package/src/proto/google/protobuf/descriptor.ts +34 -34
- package/src/proto/google/protobuf/duration.ts +2 -2
- package/src/proto/google/protobuf/empty.ts +2 -2
- package/src/proto/google/protobuf/timestamp.ts +2 -2
- package/src/proto/mock.ts +4 -4
- package/src/proto/spark.ts +1452 -185
- package/src/proto/spark_authn.ts +7 -7
- package/src/proto/spark_token.ts +1668 -105
- package/src/proto/validate/validate.ts +24 -24
- package/src/services/bolt11-spark.ts +62 -187
- package/src/services/coop-exit.ts +3 -0
- package/src/services/lrc20.ts +1 -1
- package/src/services/token-transactions.ts +197 -9
- package/src/services/transfer.ts +22 -0
- package/src/services/tree-creation.ts +13 -0
- package/src/services/wallet-config.ts +2 -2
- package/src/spark-wallet/spark-wallet.node.ts +0 -4
- package/src/spark-wallet/spark-wallet.ts +76 -108
- package/src/spark-wallet/types.ts +39 -3
- package/src/tests/bolt11-spark.test.ts +7 -15
- package/src/tests/integration/ssp/coop-exit.test.ts +7 -7
- package/src/tests/integration/swap.test.ts +453 -433
- package/src/tests/integration/transfer.test.ts +261 -248
- package/src/tests/token-identifier.test.ts +54 -0
- package/src/tests/tokens.test.ts +218 -23
- package/src/utils/token-hashing.ts +320 -44
- package/src/utils/token-identifier.ts +88 -0
- package/src/utils/token-transaction-validation.ts +350 -5
- package/src/utils/token-transactions.ts +12 -8
- package/src/utils/transaction.ts +0 -6
- package/dist/chunk-B3AMIGJG.js +0 -1073
- package/dist/index-CZmDdSts.d.cts +0 -829
- package/dist/index-ClIRO_3y.d.ts +0 -829
- package/dist/wasm-7OWFHDMS.js +0 -21
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isReactNative
|
|
3
|
-
} from "./chunk-UBT6EDVJ.js";
|
|
4
1
|
import {
|
|
5
2
|
generateAdaptorFromSignature,
|
|
6
3
|
getRandomSigningNonce,
|
|
7
4
|
getSigningCommitmentFromNonce,
|
|
8
5
|
subtractPrivateKeys
|
|
9
6
|
} from "./chunk-NSJF5F5O.js";
|
|
7
|
+
import {
|
|
8
|
+
isReactNative
|
|
9
|
+
} from "./chunk-OFCJFZ4I.js";
|
|
10
10
|
import {
|
|
11
11
|
splitSecretWithProofs
|
|
12
12
|
} from "./chunk-QNNSEJ4P.js";
|
|
@@ -46,7 +46,7 @@ var getSparkFrostModule = async () => {
|
|
|
46
46
|
return void 0;
|
|
47
47
|
}
|
|
48
48
|
if (!sparkFrostModule) {
|
|
49
|
-
sparkFrostModule = await import("./wasm
|
|
49
|
+
sparkFrostModule = await import("./spark_bindings/wasm/index.js");
|
|
50
50
|
}
|
|
51
51
|
return sparkFrostModule;
|
|
52
52
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { isNode } from "@lightsparkdev/core";
|
|
3
3
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
4
4
|
var isBun = globalThis.Bun !== void 0;
|
|
5
|
-
var packageVersion = true ? "0.1.
|
|
5
|
+
var packageVersion = true ? "0.1.46" : "unknown";
|
|
6
6
|
var baseEnvStr = "unknown";
|
|
7
7
|
if (isBun) {
|
|
8
8
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
encodeSparkAddress
|
|
3
|
-
} from "./chunk-KEKGSH7B.js";
|
|
4
1
|
import {
|
|
5
2
|
getNetwork,
|
|
6
3
|
getNetworkFromAddress
|
|
@@ -8,16 +5,19 @@ import {
|
|
|
8
5
|
import {
|
|
9
6
|
ELECTRS_CREDENTIALS,
|
|
10
7
|
getElectrsUrl
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4EMV7HHW.js";
|
|
9
|
+
import {
|
|
10
|
+
encodeSparkAddress
|
|
11
|
+
} from "./chunk-KMUMFYFX.js";
|
|
12
|
+
import {
|
|
13
|
+
ValidationError
|
|
14
|
+
} from "./chunk-GSI4OLXZ.js";
|
|
12
15
|
import {
|
|
13
16
|
BitcoinNetwork_default
|
|
14
17
|
} from "./chunk-HMLOC6TE.js";
|
|
15
18
|
import {
|
|
16
19
|
TreeNode
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import {
|
|
19
|
-
ValidationError
|
|
20
|
-
} from "./chunk-GSI4OLXZ.js";
|
|
20
|
+
} from "./chunk-BGGEVUJK.js";
|
|
21
21
|
import {
|
|
22
22
|
Buffer
|
|
23
23
|
} from "./chunk-MVRQ5US7.js";
|
|
@@ -306,10 +306,8 @@ function checkIfValidSequence(currSequence) {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
function getNextTransactionSequence(currSequence, forRefresh) {
|
|
309
|
-
checkIfValidSequence(currSequence);
|
|
310
309
|
const currentTimelock = getCurrentTimelock(currSequence);
|
|
311
310
|
const nextTimelock = currentTimelock - TIME_LOCK_INTERVAL;
|
|
312
|
-
checkIfValidSequence(nextTimelock);
|
|
313
311
|
if (forRefresh && nextTimelock <= 100 && currentTimelock > 0) {
|
|
314
312
|
return {
|
|
315
313
|
nextSequence: 1 << 30 | nextTimelock,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { B as BitcoinNetwork } from '../../BitcoinNetwork-TnABML0T.cjs';
|
|
2
2
|
import { Query } from '@lightsparkdev/core';
|
|
3
|
-
import { k as CurrencyAmount, P as PageInfo, K as SspClient } from '../../RequestLightningSendInput-
|
|
4
|
-
export { C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitFeeQuote, h as CoopExitFeeQuoteInput, i as CoopExitRequest, l as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, m as LeavesSwapFeeEstimateOutput, o as LeavesSwapRequest, q as LightningReceiveRequest, r as LightningReceiveRequestStatus, s as LightningSendFeeEstimateOutput, u as LightningSendRequest, v as LightningSendRequestStatus, R as RequestCoopExitInput, w as RequestLeavesSwapInput, x as RequestLightningReceiveInput, y as RequestLightningSendInput, S as SparkCoopExitRequestStatus, z as SparkLeavesSwapRequestStatus, A as SparkTransferToLeavesConnection, B as StaticDepositQuoteInput, D as StaticDepositQuoteOutput, F as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitFeeQuoteQuery, j as getCoopExitRequestQuery, n as getLeavesSwapRequestQuery, p as getLightningReceiveRequestQuery, t as getLightningSendRequestQuery } from '../../RequestLightningSendInput-
|
|
3
|
+
import { k as CurrencyAmount, P as PageInfo, K as SspClient } from '../../RequestLightningSendInput-2cSh_In4.cjs';
|
|
4
|
+
export { C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitFeeQuote, h as CoopExitFeeQuoteInput, i as CoopExitRequest, l as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, m as LeavesSwapFeeEstimateOutput, o as LeavesSwapRequest, q as LightningReceiveRequest, r as LightningReceiveRequestStatus, s as LightningSendFeeEstimateOutput, u as LightningSendRequest, v as LightningSendRequestStatus, R as RequestCoopExitInput, w as RequestLeavesSwapInput, x as RequestLightningReceiveInput, y as RequestLightningSendInput, S as SparkCoopExitRequestStatus, z as SparkLeavesSwapRequestStatus, A as SparkTransferToLeavesConnection, B as StaticDepositQuoteInput, D as StaticDepositQuoteOutput, F as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitFeeQuoteQuery, j as getCoopExitRequestQuery, n as getLeavesSwapRequestQuery, p as getLightningReceiveRequestQuery, t as getLightningSendRequestQuery } from '../../RequestLightningSendInput-2cSh_In4.cjs';
|
|
5
5
|
export { L as LightningSendFeeEstimateInput } from '../../LightningSendFeeEstimateInput-BgOhEAI-.cjs';
|
|
6
|
-
import '../../signer-
|
|
6
|
+
import '../../signer-BP6F__oR.cjs';
|
|
7
7
|
import '@scure/bip32';
|
|
8
|
-
import '../../spark-
|
|
8
|
+
import '../../spark-DbzGfse6.cjs';
|
|
9
9
|
import '@bufbuild/protobuf/wire';
|
|
10
10
|
import 'nice-grpc-common';
|
|
11
|
+
import '../../types-C-Rp0Oo7.cjs';
|
|
11
12
|
import '@buildonspark/lrc20-sdk';
|
|
12
13
|
import '@scure/btc-signer';
|
|
13
14
|
import 'bitcoinjs-lib';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { B as BitcoinNetwork } from '../../BitcoinNetwork-TnABML0T.js';
|
|
2
2
|
import { Query } from '@lightsparkdev/core';
|
|
3
|
-
import { k as CurrencyAmount, P as PageInfo, K as SspClient } from '../../RequestLightningSendInput-
|
|
4
|
-
export { C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitFeeQuote, h as CoopExitFeeQuoteInput, i as CoopExitRequest, l as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, m as LeavesSwapFeeEstimateOutput, o as LeavesSwapRequest, q as LightningReceiveRequest, r as LightningReceiveRequestStatus, s as LightningSendFeeEstimateOutput, u as LightningSendRequest, v as LightningSendRequestStatus, R as RequestCoopExitInput, w as RequestLeavesSwapInput, x as RequestLightningReceiveInput, y as RequestLightningSendInput, S as SparkCoopExitRequestStatus, z as SparkLeavesSwapRequestStatus, A as SparkTransferToLeavesConnection, B as StaticDepositQuoteInput, D as StaticDepositQuoteOutput, F as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitFeeQuoteQuery, j as getCoopExitRequestQuery, n as getLeavesSwapRequestQuery, p as getLightningReceiveRequestQuery, t as getLightningSendRequestQuery } from '../../RequestLightningSendInput-
|
|
3
|
+
import { k as CurrencyAmount, P as PageInfo, K as SspClient } from '../../RequestLightningSendInput-CN6BNg_g.js';
|
|
4
|
+
export { C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitFeeQuote, h as CoopExitFeeQuoteInput, i as CoopExitRequest, l as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, m as LeavesSwapFeeEstimateOutput, o as LeavesSwapRequest, q as LightningReceiveRequest, r as LightningReceiveRequestStatus, s as LightningSendFeeEstimateOutput, u as LightningSendRequest, v as LightningSendRequestStatus, R as RequestCoopExitInput, w as RequestLeavesSwapInput, x as RequestLightningReceiveInput, y as RequestLightningSendInput, S as SparkCoopExitRequestStatus, z as SparkLeavesSwapRequestStatus, A as SparkTransferToLeavesConnection, B as StaticDepositQuoteInput, D as StaticDepositQuoteOutput, F as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitFeeQuoteQuery, j as getCoopExitRequestQuery, n as getLeavesSwapRequestQuery, p as getLightningReceiveRequestQuery, t as getLightningSendRequestQuery } from '../../RequestLightningSendInput-CN6BNg_g.js';
|
|
5
5
|
export { L as LightningSendFeeEstimateInput } from '../../LightningSendFeeEstimateInput-BgOhEAI-.js';
|
|
6
|
-
import '../../signer-
|
|
6
|
+
import '../../signer-BVZJXcq7.js';
|
|
7
7
|
import '@scure/bip32';
|
|
8
|
-
import '../../spark-
|
|
8
|
+
import '../../spark-DbzGfse6.js';
|
|
9
9
|
import '@bufbuild/protobuf/wire';
|
|
10
10
|
import 'nice-grpc-common';
|
|
11
|
+
import '../../types-C-Rp0Oo7.js';
|
|
11
12
|
import '@buildonspark/lrc20-sdk';
|
|
12
13
|
import '@scure/btc-signer';
|
|
13
14
|
import 'bitcoinjs-lib';
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as btc from '@scure/btc-signer';
|
|
2
|
+
import { Transaction } from '@scure/btc-signer';
|
|
3
|
+
import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
|
|
4
|
+
import { N as Network } from './network-Css46DAz.cjs';
|
|
5
|
+
import { S as SparkSigner, i as SigningNonce, h as SigningCommitment } from './signer-BP6F__oR.cjs';
|
|
6
|
+
import { j as OutputWithPreviousTransactionData, k as TransferPackage, g as SparkServiceClient } from './spark-DbzGfse6.cjs';
|
|
7
|
+
import { ConfigOptions } from './services/wallet-config.cjs';
|
|
8
|
+
import { SparkAddressFormat } from './address/index.cjs';
|
|
9
|
+
|
|
10
|
+
type HumanReadableTokenIdentifier = `btk1${string}` | `btkrt1${string}` | `btkt1${string}` | `btks1${string}` | `btkl1${string}`;
|
|
11
|
+
|
|
12
|
+
type CreateLightningInvoiceParams = {
|
|
13
|
+
amountSats: number;
|
|
14
|
+
memo?: string;
|
|
15
|
+
expirySeconds?: number;
|
|
16
|
+
includeSparkAddress?: boolean;
|
|
17
|
+
receiverIdentityPubkey?: string;
|
|
18
|
+
descriptionHash?: string;
|
|
19
|
+
};
|
|
20
|
+
type PayLightningInvoiceParams = {
|
|
21
|
+
invoice: string;
|
|
22
|
+
maxFeeSats: number;
|
|
23
|
+
preferSpark?: boolean;
|
|
24
|
+
amountSatsToSend?: number;
|
|
25
|
+
};
|
|
26
|
+
type TransferParams = {
|
|
27
|
+
amountSats: number;
|
|
28
|
+
receiverSparkAddress: string;
|
|
29
|
+
};
|
|
30
|
+
type DepositParams = {
|
|
31
|
+
signingPubKey: Uint8Array;
|
|
32
|
+
verifyingKey: Uint8Array;
|
|
33
|
+
depositTx: Transaction;
|
|
34
|
+
vout: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Token metadata containing essential information about a token.
|
|
38
|
+
* This is the wallet's internal representation with JavaScript-friendly types.
|
|
39
|
+
*
|
|
40
|
+
* rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
|
|
41
|
+
*
|
|
42
|
+
* tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const tokenMetadata: TokenMetadata = {
|
|
47
|
+
* rawTokenIdentifier: new Uint8Array([1, 2, 3]),
|
|
48
|
+
* tokenPublicKey: "0348fbb...",
|
|
49
|
+
* tokenName: "SparkToken",
|
|
50
|
+
* tokenTicker: "SPK",
|
|
51
|
+
* decimals: 8,
|
|
52
|
+
* maxSupply: 1000000n
|
|
53
|
+
* };
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
type TokenMetadata = {
|
|
57
|
+
/** Raw binary token identifier - This is used to encode the human readable token identifier */
|
|
58
|
+
rawTokenIdentifier: Uint8Array;
|
|
59
|
+
/** Hex-encoded public key of the token issuer - Same as issuerPublicKey */
|
|
60
|
+
tokenPublicKey: string;
|
|
61
|
+
/** Human-readable name of the token (e.g., SparkToken)*/
|
|
62
|
+
tokenName: string;
|
|
63
|
+
/** Short ticker symbol for the token (e.g., "SPK") */
|
|
64
|
+
tokenTicker: string;
|
|
65
|
+
/** Number of decimal places for token amounts */
|
|
66
|
+
decimals: number;
|
|
67
|
+
/** Maximum supply of tokens that can ever be minted */
|
|
68
|
+
maxSupply: bigint;
|
|
69
|
+
};
|
|
70
|
+
type TokenBalanceMap = Map<HumanReadableTokenIdentifier, {
|
|
71
|
+
balance: bigint;
|
|
72
|
+
tokenMetadata: TokenMetadata;
|
|
73
|
+
}>;
|
|
74
|
+
type InitWalletResponse = {
|
|
75
|
+
mnemonic?: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
interface SparkWalletProps {
|
|
78
|
+
mnemonicOrSeed?: Uint8Array | string;
|
|
79
|
+
accountNumber?: number;
|
|
80
|
+
signer?: SparkSigner;
|
|
81
|
+
options?: ConfigOptions;
|
|
82
|
+
}
|
|
83
|
+
interface SparkWalletEvents {
|
|
84
|
+
/** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
|
|
85
|
+
"transfer:claimed": (transferId: string, updatedBalance: number) => void;
|
|
86
|
+
/** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
|
|
87
|
+
"deposit:confirmed": (depositId: string, updatedBalance: number) => void;
|
|
88
|
+
/** Emitted when the stream is connected */
|
|
89
|
+
"stream:connected": () => void;
|
|
90
|
+
/** Emitted when the stream disconnects and fails to reconnect after max attempts */
|
|
91
|
+
"stream:disconnected": (reason: string) => void;
|
|
92
|
+
/** Emitted when attempting to reconnect the stream */
|
|
93
|
+
"stream:reconnecting": (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare function generateSignatureFromExistingAdaptor(signature: Uint8Array, adaptorPrivateKeyBytes: Uint8Array): Uint8Array;
|
|
97
|
+
declare function generateAdaptorFromSignature(signature: Uint8Array): {
|
|
98
|
+
adaptorSignature: Uint8Array;
|
|
99
|
+
adaptorPrivateKey: Uint8Array;
|
|
100
|
+
};
|
|
101
|
+
declare function validateOutboundAdaptorSignature(pubkey: Uint8Array, hash: Uint8Array, signature: Uint8Array, adaptorPubkey: Uint8Array): boolean;
|
|
102
|
+
declare function applyAdaptorToSignature(pubkey: Uint8Array, hash: Uint8Array, signature: Uint8Array, adaptorPrivateKeyBytes: Uint8Array): Uint8Array;
|
|
103
|
+
|
|
104
|
+
declare function computeTaprootKeyNoScript(pubkey: Uint8Array): Uint8Array;
|
|
105
|
+
declare function getP2TRScriptFromPublicKey(pubKey: Uint8Array, network: Network): Uint8Array;
|
|
106
|
+
declare function getP2TRAddressFromPublicKey(pubKey: Uint8Array, network: Network): string;
|
|
107
|
+
declare function getP2TRAddressFromPkScript(pkScript: Uint8Array, network: Network): string;
|
|
108
|
+
declare function getP2WPKHAddressFromPublicKey(pubKey: Uint8Array, network: Network): string;
|
|
109
|
+
declare function getTxFromRawTxHex(rawTxHex: string): btc.Transaction;
|
|
110
|
+
declare function getTxFromRawTxBytes(rawTxBytes: Uint8Array): btc.Transaction;
|
|
111
|
+
declare function getSigHashFromTx(tx: btc.Transaction, inputIndex: number, prevOutput: TransactionOutput): Uint8Array;
|
|
112
|
+
declare function getTxId(tx: btc.Transaction): string;
|
|
113
|
+
declare function getTxIdNoReverse(tx: btc.Transaction): string;
|
|
114
|
+
|
|
115
|
+
declare function addPublicKeys(a: Uint8Array, b: Uint8Array): Uint8Array;
|
|
116
|
+
declare function applyAdditiveTweakToPublicKey(pubkey: Uint8Array, tweak: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
117
|
+
declare function subtractPublicKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
118
|
+
declare function addPrivateKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
119
|
+
declare function subtractPrivateKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
120
|
+
declare function sumOfPrivateKeys(keys: Uint8Array[]): Uint8Array<ArrayBufferLike>;
|
|
121
|
+
declare function lastKeyWithTarget(target: Uint8Array, keys: Uint8Array[]): Uint8Array<ArrayBufferLike>;
|
|
122
|
+
|
|
123
|
+
declare function getLatestDepositTxId(address: string): Promise<string | null>;
|
|
124
|
+
declare function isTxBroadcast(txid: string, baseUrl: string, network?: any): Promise<boolean>;
|
|
125
|
+
|
|
126
|
+
declare function proofOfPossessionMessageHashForDepositAddress(userPubkey: Uint8Array, operatorPubkey: Uint8Array, depositAddress: string): Uint8Array;
|
|
127
|
+
|
|
128
|
+
declare function collectResponses<T>(responses: PromiseSettledResult<T>[]): T[];
|
|
129
|
+
|
|
130
|
+
declare function getRandomSigningNonce(): SigningNonce;
|
|
131
|
+
declare function createSigningNonce(binding: Uint8Array, hiding: Uint8Array): SigningNonce;
|
|
132
|
+
declare function getSigningCommitmentFromNonce(nonce: SigningNonce): SigningCommitment;
|
|
133
|
+
declare function encodeSigningNonceToBytes(nonce: SigningNonce): Uint8Array;
|
|
134
|
+
declare function decodeBytesToSigningNonce(bytes: Uint8Array): SigningNonce;
|
|
135
|
+
declare function createSigningCommitment(binding: Uint8Array, hiding: Uint8Array): SigningCommitment;
|
|
136
|
+
declare function encodeSigningCommitmentToBytes(commitment: SigningCommitment): Uint8Array;
|
|
137
|
+
declare function decodeBytesToSigningCommitment(bytes: Uint8Array): SigningCommitment;
|
|
138
|
+
|
|
139
|
+
declare function calculateAvailableTokenAmount(outputLeaves: OutputWithPreviousTransactionData[]): bigint;
|
|
140
|
+
declare function checkIfSelectedOutputsAreAvailable(selectedOutputs: OutputWithPreviousTransactionData[], tokenOutputs: Map<string, OutputWithPreviousTransactionData[]>, tokenPublicKey: Uint8Array): boolean;
|
|
141
|
+
declare function filterTokenBalanceForTokenPublicKey(tokenBalances: TokenBalanceMap, publicKey: string): {
|
|
142
|
+
balance: bigint;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
|
|
146
|
+
|
|
147
|
+
declare const DEFAULT_FEE_SATS: number;
|
|
148
|
+
/**
|
|
149
|
+
* Subtracts the default fee from the amount if it's greater than the fee.
|
|
150
|
+
* Returns the original amount if it's less than or equal to the fee.
|
|
151
|
+
*/
|
|
152
|
+
declare function maybeApplyFee(amount: bigint): bigint;
|
|
153
|
+
declare function createRefundTx(sequence: number, nodeOutPoint: TransactionInput, amountSats: bigint, receivingPubkey: Uint8Array, network: Network): Transaction;
|
|
154
|
+
declare function getCurrentTimelock(currSequence?: number): number;
|
|
155
|
+
declare function getTransactionSequence(currSequence?: number): number;
|
|
156
|
+
declare function checkIfValidSequence(currSequence?: number): void;
|
|
157
|
+
declare function getNextTransactionSequence(currSequence?: number, forRefresh?: boolean): {
|
|
158
|
+
nextSequence: number;
|
|
159
|
+
needRefresh: boolean;
|
|
160
|
+
};
|
|
161
|
+
declare function getEphemeralAnchorOutput(): TransactionOutput;
|
|
162
|
+
|
|
163
|
+
interface LeafInfo {
|
|
164
|
+
leafId: string;
|
|
165
|
+
nodeTx: string;
|
|
166
|
+
refundTx: string;
|
|
167
|
+
}
|
|
168
|
+
interface Utxo {
|
|
169
|
+
txid: string;
|
|
170
|
+
vout: number;
|
|
171
|
+
value: bigint;
|
|
172
|
+
script: string;
|
|
173
|
+
publicKey: string;
|
|
174
|
+
}
|
|
175
|
+
interface FeeRate {
|
|
176
|
+
satPerVbyte: number;
|
|
177
|
+
}
|
|
178
|
+
interface FeeBumpTxPackage {
|
|
179
|
+
tx: string;
|
|
180
|
+
feeBumpPsbt?: string;
|
|
181
|
+
}
|
|
182
|
+
interface FeeBumpTxChain {
|
|
183
|
+
leafId: string;
|
|
184
|
+
txPackages: FeeBumpTxPackage[];
|
|
185
|
+
}
|
|
186
|
+
interface TxChain {
|
|
187
|
+
leafId: string;
|
|
188
|
+
transactions: string[];
|
|
189
|
+
}
|
|
190
|
+
interface BroadcastConfig {
|
|
191
|
+
bitcoinCoreRpcUrl?: string;
|
|
192
|
+
rpcUsername?: string;
|
|
193
|
+
rpcPassword?: string;
|
|
194
|
+
autoBroadcast?: boolean;
|
|
195
|
+
network?: "MAINNET" | "REGTEST" | "TESTNET" | "SIGNET" | "LOCAL";
|
|
196
|
+
}
|
|
197
|
+
interface BroadcastResult {
|
|
198
|
+
success: boolean;
|
|
199
|
+
txids?: string[];
|
|
200
|
+
error?: string;
|
|
201
|
+
broadcastedPackages?: number;
|
|
202
|
+
}
|
|
203
|
+
declare function isEphemeralAnchorOutput(script?: Uint8Array, amount?: bigint): boolean;
|
|
204
|
+
declare function constructUnilateralExitTxs(nodeHexStrings: string[], sparkClient?: SparkServiceClient, network?: any): Promise<TxChain[]>;
|
|
205
|
+
declare function constructUnilateralExitFeeBumpPackages(nodeHexStrings: string[], utxos: Utxo[], feeRate: FeeRate, electrsUrl: string, sparkClient?: SparkServiceClient, network?: any): Promise<FeeBumpTxChain[]>;
|
|
206
|
+
declare function constructFeeBumpTx(txHex: string, utxos: Utxo[], feeRate: FeeRate, previousFeeBumpTx?: string): {
|
|
207
|
+
feeBumpPsbt: string;
|
|
208
|
+
usedUtxos: Utxo[];
|
|
209
|
+
correctedParentTx?: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
declare function getSparkAddressFromTaproot(taprootAddress: string): SparkAddressFormat;
|
|
213
|
+
|
|
214
|
+
export { getEphemeralAnchorOutput as $, proofOfPossessionMessageHashForDepositAddress as A, collectResponses as B, type CreateLightningInvoiceParams as C, type DepositParams as D, getRandomSigningNonce as E, createSigningNonce as F, getSigningCommitmentFromNonce as G, encodeSigningNonceToBytes as H, type InitWalletResponse as I, decodeBytesToSigningNonce as J, createSigningCommitment as K, encodeSigningCommitmentToBytes as L, decodeBytesToSigningCommitment as M, calculateAvailableTokenAmount as N, checkIfSelectedOutputsAreAvailable as O, type PayLightningInvoiceParams as P, filterTokenBalanceForTokenPublicKey as Q, getTransferPackageSigningPayload as R, type SparkWalletProps as S, type TransferParams as T, DEFAULT_FEE_SATS as U, maybeApplyFee as V, createRefundTx as W, getCurrentTimelock as X, getTransactionSequence as Y, checkIfValidSequence as Z, getNextTransactionSequence as _, type TokenMetadata as a, type LeafInfo as a0, type Utxo as a1, type FeeRate as a2, type FeeBumpTxPackage as a3, type FeeBumpTxChain as a4, type TxChain as a5, type BroadcastConfig as a6, type BroadcastResult as a7, isEphemeralAnchorOutput as a8, constructUnilateralExitTxs as a9, constructUnilateralExitFeeBumpPackages as aa, constructFeeBumpTx as ab, getSparkAddressFromTaproot as ac, type TokenBalanceMap as b, type SparkWalletEvents as c, generateAdaptorFromSignature as d, applyAdaptorToSignature as e, computeTaprootKeyNoScript as f, generateSignatureFromExistingAdaptor as g, getP2TRScriptFromPublicKey as h, getP2TRAddressFromPublicKey as i, getP2TRAddressFromPkScript as j, getP2WPKHAddressFromPublicKey as k, getTxFromRawTxHex as l, getTxFromRawTxBytes as m, getSigHashFromTx as n, getTxId as o, getTxIdNoReverse as p, addPublicKeys as q, applyAdditiveTweakToPublicKey as r, subtractPublicKeys as s, addPrivateKeys as t, subtractPrivateKeys as u, validateOutboundAdaptorSignature as v, sumOfPrivateKeys as w, lastKeyWithTarget as x, getLatestDepositTxId as y, isTxBroadcast as z };
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as btc from '@scure/btc-signer';
|
|
2
|
+
import { Transaction } from '@scure/btc-signer';
|
|
3
|
+
import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
|
|
4
|
+
import { N as Network } from './network-hynb7iTZ.js';
|
|
5
|
+
import { S as SparkSigner, i as SigningNonce, h as SigningCommitment } from './signer-BVZJXcq7.js';
|
|
6
|
+
import { j as OutputWithPreviousTransactionData, k as TransferPackage, g as SparkServiceClient } from './spark-DbzGfse6.js';
|
|
7
|
+
import { ConfigOptions } from './services/wallet-config.js';
|
|
8
|
+
import { SparkAddressFormat } from './address/index.js';
|
|
9
|
+
|
|
10
|
+
type HumanReadableTokenIdentifier = `btk1${string}` | `btkrt1${string}` | `btkt1${string}` | `btks1${string}` | `btkl1${string}`;
|
|
11
|
+
|
|
12
|
+
type CreateLightningInvoiceParams = {
|
|
13
|
+
amountSats: number;
|
|
14
|
+
memo?: string;
|
|
15
|
+
expirySeconds?: number;
|
|
16
|
+
includeSparkAddress?: boolean;
|
|
17
|
+
receiverIdentityPubkey?: string;
|
|
18
|
+
descriptionHash?: string;
|
|
19
|
+
};
|
|
20
|
+
type PayLightningInvoiceParams = {
|
|
21
|
+
invoice: string;
|
|
22
|
+
maxFeeSats: number;
|
|
23
|
+
preferSpark?: boolean;
|
|
24
|
+
amountSatsToSend?: number;
|
|
25
|
+
};
|
|
26
|
+
type TransferParams = {
|
|
27
|
+
amountSats: number;
|
|
28
|
+
receiverSparkAddress: string;
|
|
29
|
+
};
|
|
30
|
+
type DepositParams = {
|
|
31
|
+
signingPubKey: Uint8Array;
|
|
32
|
+
verifyingKey: Uint8Array;
|
|
33
|
+
depositTx: Transaction;
|
|
34
|
+
vout: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Token metadata containing essential information about a token.
|
|
38
|
+
* This is the wallet's internal representation with JavaScript-friendly types.
|
|
39
|
+
*
|
|
40
|
+
* rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
|
|
41
|
+
*
|
|
42
|
+
* tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const tokenMetadata: TokenMetadata = {
|
|
47
|
+
* rawTokenIdentifier: new Uint8Array([1, 2, 3]),
|
|
48
|
+
* tokenPublicKey: "0348fbb...",
|
|
49
|
+
* tokenName: "SparkToken",
|
|
50
|
+
* tokenTicker: "SPK",
|
|
51
|
+
* decimals: 8,
|
|
52
|
+
* maxSupply: 1000000n
|
|
53
|
+
* };
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
type TokenMetadata = {
|
|
57
|
+
/** Raw binary token identifier - This is used to encode the human readable token identifier */
|
|
58
|
+
rawTokenIdentifier: Uint8Array;
|
|
59
|
+
/** Hex-encoded public key of the token issuer - Same as issuerPublicKey */
|
|
60
|
+
tokenPublicKey: string;
|
|
61
|
+
/** Human-readable name of the token (e.g., SparkToken)*/
|
|
62
|
+
tokenName: string;
|
|
63
|
+
/** Short ticker symbol for the token (e.g., "SPK") */
|
|
64
|
+
tokenTicker: string;
|
|
65
|
+
/** Number of decimal places for token amounts */
|
|
66
|
+
decimals: number;
|
|
67
|
+
/** Maximum supply of tokens that can ever be minted */
|
|
68
|
+
maxSupply: bigint;
|
|
69
|
+
};
|
|
70
|
+
type TokenBalanceMap = Map<HumanReadableTokenIdentifier, {
|
|
71
|
+
balance: bigint;
|
|
72
|
+
tokenMetadata: TokenMetadata;
|
|
73
|
+
}>;
|
|
74
|
+
type InitWalletResponse = {
|
|
75
|
+
mnemonic?: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
interface SparkWalletProps {
|
|
78
|
+
mnemonicOrSeed?: Uint8Array | string;
|
|
79
|
+
accountNumber?: number;
|
|
80
|
+
signer?: SparkSigner;
|
|
81
|
+
options?: ConfigOptions;
|
|
82
|
+
}
|
|
83
|
+
interface SparkWalletEvents {
|
|
84
|
+
/** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
|
|
85
|
+
"transfer:claimed": (transferId: string, updatedBalance: number) => void;
|
|
86
|
+
/** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
|
|
87
|
+
"deposit:confirmed": (depositId: string, updatedBalance: number) => void;
|
|
88
|
+
/** Emitted when the stream is connected */
|
|
89
|
+
"stream:connected": () => void;
|
|
90
|
+
/** Emitted when the stream disconnects and fails to reconnect after max attempts */
|
|
91
|
+
"stream:disconnected": (reason: string) => void;
|
|
92
|
+
/** Emitted when attempting to reconnect the stream */
|
|
93
|
+
"stream:reconnecting": (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare function generateSignatureFromExistingAdaptor(signature: Uint8Array, adaptorPrivateKeyBytes: Uint8Array): Uint8Array;
|
|
97
|
+
declare function generateAdaptorFromSignature(signature: Uint8Array): {
|
|
98
|
+
adaptorSignature: Uint8Array;
|
|
99
|
+
adaptorPrivateKey: Uint8Array;
|
|
100
|
+
};
|
|
101
|
+
declare function validateOutboundAdaptorSignature(pubkey: Uint8Array, hash: Uint8Array, signature: Uint8Array, adaptorPubkey: Uint8Array): boolean;
|
|
102
|
+
declare function applyAdaptorToSignature(pubkey: Uint8Array, hash: Uint8Array, signature: Uint8Array, adaptorPrivateKeyBytes: Uint8Array): Uint8Array;
|
|
103
|
+
|
|
104
|
+
declare function computeTaprootKeyNoScript(pubkey: Uint8Array): Uint8Array;
|
|
105
|
+
declare function getP2TRScriptFromPublicKey(pubKey: Uint8Array, network: Network): Uint8Array;
|
|
106
|
+
declare function getP2TRAddressFromPublicKey(pubKey: Uint8Array, network: Network): string;
|
|
107
|
+
declare function getP2TRAddressFromPkScript(pkScript: Uint8Array, network: Network): string;
|
|
108
|
+
declare function getP2WPKHAddressFromPublicKey(pubKey: Uint8Array, network: Network): string;
|
|
109
|
+
declare function getTxFromRawTxHex(rawTxHex: string): btc.Transaction;
|
|
110
|
+
declare function getTxFromRawTxBytes(rawTxBytes: Uint8Array): btc.Transaction;
|
|
111
|
+
declare function getSigHashFromTx(tx: btc.Transaction, inputIndex: number, prevOutput: TransactionOutput): Uint8Array;
|
|
112
|
+
declare function getTxId(tx: btc.Transaction): string;
|
|
113
|
+
declare function getTxIdNoReverse(tx: btc.Transaction): string;
|
|
114
|
+
|
|
115
|
+
declare function addPublicKeys(a: Uint8Array, b: Uint8Array): Uint8Array;
|
|
116
|
+
declare function applyAdditiveTweakToPublicKey(pubkey: Uint8Array, tweak: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
117
|
+
declare function subtractPublicKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
118
|
+
declare function addPrivateKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
119
|
+
declare function subtractPrivateKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
120
|
+
declare function sumOfPrivateKeys(keys: Uint8Array[]): Uint8Array<ArrayBufferLike>;
|
|
121
|
+
declare function lastKeyWithTarget(target: Uint8Array, keys: Uint8Array[]): Uint8Array<ArrayBufferLike>;
|
|
122
|
+
|
|
123
|
+
declare function getLatestDepositTxId(address: string): Promise<string | null>;
|
|
124
|
+
declare function isTxBroadcast(txid: string, baseUrl: string, network?: any): Promise<boolean>;
|
|
125
|
+
|
|
126
|
+
declare function proofOfPossessionMessageHashForDepositAddress(userPubkey: Uint8Array, operatorPubkey: Uint8Array, depositAddress: string): Uint8Array;
|
|
127
|
+
|
|
128
|
+
declare function collectResponses<T>(responses: PromiseSettledResult<T>[]): T[];
|
|
129
|
+
|
|
130
|
+
declare function getRandomSigningNonce(): SigningNonce;
|
|
131
|
+
declare function createSigningNonce(binding: Uint8Array, hiding: Uint8Array): SigningNonce;
|
|
132
|
+
declare function getSigningCommitmentFromNonce(nonce: SigningNonce): SigningCommitment;
|
|
133
|
+
declare function encodeSigningNonceToBytes(nonce: SigningNonce): Uint8Array;
|
|
134
|
+
declare function decodeBytesToSigningNonce(bytes: Uint8Array): SigningNonce;
|
|
135
|
+
declare function createSigningCommitment(binding: Uint8Array, hiding: Uint8Array): SigningCommitment;
|
|
136
|
+
declare function encodeSigningCommitmentToBytes(commitment: SigningCommitment): Uint8Array;
|
|
137
|
+
declare function decodeBytesToSigningCommitment(bytes: Uint8Array): SigningCommitment;
|
|
138
|
+
|
|
139
|
+
declare function calculateAvailableTokenAmount(outputLeaves: OutputWithPreviousTransactionData[]): bigint;
|
|
140
|
+
declare function checkIfSelectedOutputsAreAvailable(selectedOutputs: OutputWithPreviousTransactionData[], tokenOutputs: Map<string, OutputWithPreviousTransactionData[]>, tokenPublicKey: Uint8Array): boolean;
|
|
141
|
+
declare function filterTokenBalanceForTokenPublicKey(tokenBalances: TokenBalanceMap, publicKey: string): {
|
|
142
|
+
balance: bigint;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
|
|
146
|
+
|
|
147
|
+
declare const DEFAULT_FEE_SATS: number;
|
|
148
|
+
/**
|
|
149
|
+
* Subtracts the default fee from the amount if it's greater than the fee.
|
|
150
|
+
* Returns the original amount if it's less than or equal to the fee.
|
|
151
|
+
*/
|
|
152
|
+
declare function maybeApplyFee(amount: bigint): bigint;
|
|
153
|
+
declare function createRefundTx(sequence: number, nodeOutPoint: TransactionInput, amountSats: bigint, receivingPubkey: Uint8Array, network: Network): Transaction;
|
|
154
|
+
declare function getCurrentTimelock(currSequence?: number): number;
|
|
155
|
+
declare function getTransactionSequence(currSequence?: number): number;
|
|
156
|
+
declare function checkIfValidSequence(currSequence?: number): void;
|
|
157
|
+
declare function getNextTransactionSequence(currSequence?: number, forRefresh?: boolean): {
|
|
158
|
+
nextSequence: number;
|
|
159
|
+
needRefresh: boolean;
|
|
160
|
+
};
|
|
161
|
+
declare function getEphemeralAnchorOutput(): TransactionOutput;
|
|
162
|
+
|
|
163
|
+
interface LeafInfo {
|
|
164
|
+
leafId: string;
|
|
165
|
+
nodeTx: string;
|
|
166
|
+
refundTx: string;
|
|
167
|
+
}
|
|
168
|
+
interface Utxo {
|
|
169
|
+
txid: string;
|
|
170
|
+
vout: number;
|
|
171
|
+
value: bigint;
|
|
172
|
+
script: string;
|
|
173
|
+
publicKey: string;
|
|
174
|
+
}
|
|
175
|
+
interface FeeRate {
|
|
176
|
+
satPerVbyte: number;
|
|
177
|
+
}
|
|
178
|
+
interface FeeBumpTxPackage {
|
|
179
|
+
tx: string;
|
|
180
|
+
feeBumpPsbt?: string;
|
|
181
|
+
}
|
|
182
|
+
interface FeeBumpTxChain {
|
|
183
|
+
leafId: string;
|
|
184
|
+
txPackages: FeeBumpTxPackage[];
|
|
185
|
+
}
|
|
186
|
+
interface TxChain {
|
|
187
|
+
leafId: string;
|
|
188
|
+
transactions: string[];
|
|
189
|
+
}
|
|
190
|
+
interface BroadcastConfig {
|
|
191
|
+
bitcoinCoreRpcUrl?: string;
|
|
192
|
+
rpcUsername?: string;
|
|
193
|
+
rpcPassword?: string;
|
|
194
|
+
autoBroadcast?: boolean;
|
|
195
|
+
network?: "MAINNET" | "REGTEST" | "TESTNET" | "SIGNET" | "LOCAL";
|
|
196
|
+
}
|
|
197
|
+
interface BroadcastResult {
|
|
198
|
+
success: boolean;
|
|
199
|
+
txids?: string[];
|
|
200
|
+
error?: string;
|
|
201
|
+
broadcastedPackages?: number;
|
|
202
|
+
}
|
|
203
|
+
declare function isEphemeralAnchorOutput(script?: Uint8Array, amount?: bigint): boolean;
|
|
204
|
+
declare function constructUnilateralExitTxs(nodeHexStrings: string[], sparkClient?: SparkServiceClient, network?: any): Promise<TxChain[]>;
|
|
205
|
+
declare function constructUnilateralExitFeeBumpPackages(nodeHexStrings: string[], utxos: Utxo[], feeRate: FeeRate, electrsUrl: string, sparkClient?: SparkServiceClient, network?: any): Promise<FeeBumpTxChain[]>;
|
|
206
|
+
declare function constructFeeBumpTx(txHex: string, utxos: Utxo[], feeRate: FeeRate, previousFeeBumpTx?: string): {
|
|
207
|
+
feeBumpPsbt: string;
|
|
208
|
+
usedUtxos: Utxo[];
|
|
209
|
+
correctedParentTx?: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
declare function getSparkAddressFromTaproot(taprootAddress: string): SparkAddressFormat;
|
|
213
|
+
|
|
214
|
+
export { getEphemeralAnchorOutput as $, proofOfPossessionMessageHashForDepositAddress as A, collectResponses as B, type CreateLightningInvoiceParams as C, type DepositParams as D, getRandomSigningNonce as E, createSigningNonce as F, getSigningCommitmentFromNonce as G, encodeSigningNonceToBytes as H, type InitWalletResponse as I, decodeBytesToSigningNonce as J, createSigningCommitment as K, encodeSigningCommitmentToBytes as L, decodeBytesToSigningCommitment as M, calculateAvailableTokenAmount as N, checkIfSelectedOutputsAreAvailable as O, type PayLightningInvoiceParams as P, filterTokenBalanceForTokenPublicKey as Q, getTransferPackageSigningPayload as R, type SparkWalletProps as S, type TransferParams as T, DEFAULT_FEE_SATS as U, maybeApplyFee as V, createRefundTx as W, getCurrentTimelock as X, getTransactionSequence as Y, checkIfValidSequence as Z, getNextTransactionSequence as _, type TokenMetadata as a, type LeafInfo as a0, type Utxo as a1, type FeeRate as a2, type FeeBumpTxPackage as a3, type FeeBumpTxChain as a4, type TxChain as a5, type BroadcastConfig as a6, type BroadcastResult as a7, isEphemeralAnchorOutput as a8, constructUnilateralExitTxs as a9, constructUnilateralExitFeeBumpPackages as aa, constructFeeBumpTx as ab, getSparkAddressFromTaproot as ac, type TokenBalanceMap as b, type SparkWalletEvents as c, generateAdaptorFromSignature as d, applyAdaptorToSignature as e, computeTaprootKeyNoScript as f, generateSignatureFromExistingAdaptor as g, getP2TRScriptFromPublicKey as h, getP2TRAddressFromPublicKey as i, getP2TRAddressFromPkScript as j, getP2WPKHAddressFromPublicKey as k, getTxFromRawTxHex as l, getTxFromRawTxBytes as m, getSigHashFromTx as n, getTxId as o, getTxIdNoReverse as p, addPublicKeys as q, applyAdditiveTweakToPublicKey as r, subtractPublicKeys as s, addPrivateKeys as t, subtractPrivateKeys as u, validateOutboundAdaptorSignature as v, sumOfPrivateKeys as w, lastKeyWithTarget as x, getLatestDepositTxId as y, isTxBroadcast as z };
|