@buildonspark/spark-sdk 0.2.12 → 0.2.13
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 +7 -0
- package/dist/bare/index.cjs +59 -38
- package/dist/bare/index.d.cts +23 -8
- package/dist/bare/index.d.ts +23 -8
- package/dist/bare/index.js +59 -38
- package/dist/{chunk-NQMQVXR5.js → chunk-CKHJFQUA.js} +1 -1
- package/dist/{chunk-OEK3R57K.js → chunk-LX45BCZW.js} +59 -38
- package/dist/debug.cjs +59 -38
- package/dist/debug.d.cts +2 -2
- package/dist/debug.d.ts +2 -2
- package/dist/debug.js +1 -1
- package/dist/index.cjs +59 -38
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/index.node.cjs +59 -38
- package/dist/index.node.d.cts +4 -4
- package/dist/index.node.d.ts +4 -4
- package/dist/index.node.js +1 -1
- package/dist/{logging-D3kvES69.d.cts → logging-BfTyKwqb.d.cts} +1 -1
- package/dist/{logging-ClNhGzus.d.ts → logging-CaNpBgiE.d.ts} +1 -1
- package/dist/native/index.cjs +59 -38
- package/dist/native/index.d.cts +23 -8
- package/dist/native/index.d.ts +23 -8
- package/dist/native/index.js +59 -38
- package/dist/{spark-wallet-DiHSU-pz.d.ts → spark-wallet-D0Df_P_x.d.ts} +23 -8
- package/dist/{spark-wallet-Dg5IRQe2.d.cts → spark-wallet-Dvh1BLP6.d.cts} +23 -8
- package/dist/{spark-wallet.node-DSWb18zh.d.cts → spark-wallet.node-B3V8_fgw.d.cts} +1 -1
- package/dist/{spark-wallet.node-BZrxwomN.d.ts → spark-wallet.node-bGmy8-T8.d.ts} +1 -1
- package/dist/tests/test-utils.cjs +1 -1
- package/dist/tests/test-utils.d.cts +2 -2
- package/dist/tests/test-utils.d.ts +2 -2
- package/dist/tests/test-utils.js +2 -2
- package/dist/{token-transactions-B-WqFYpW.d.cts → token-transactions-D1ta-sHH.d.cts} +1 -1
- package/dist/{token-transactions-DovxHIxV.d.ts → token-transactions-DINiKBzd.d.ts} +1 -1
- package/package.json +3 -3
- package/src/services/transfer.ts +0 -26
- package/src/spark-wallet/proto-descriptors.ts +22 -0
- package/src/spark-wallet/proto-hash.ts +743 -0
- package/src/spark-wallet/proto-reflection.ts +193 -0
- package/src/spark-wallet/spark-wallet.ts +70 -24
- package/src/spark_descriptors.pb +0 -0
- package/src/tests/bufbuild-reflection.test.ts +151 -0
- package/src/tests/cross-language-hash.test.ts +79 -0
- package/src/tests/integration/address.test.ts +3 -12
- package/src/tests/integration/ssp/static_deposit.test.ts +15 -9
- package/src/tests/integration/static_deposit.test.ts +26 -0
- package/src/tests/integration/transfer.test.ts +0 -124
package/dist/debug.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, D as DecodedSparkAddressData, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, c as SparkAddressData, S as SparkAddressFormat, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature, H as SparkWallet, b as ConfigOptions } from './spark-wallet-
|
|
2
|
-
import { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-
|
|
1
|
+
import { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, D as DecodedSparkAddressData, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, c as SparkAddressData, S as SparkAddressFormat, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature, H as SparkWallet, b as ConfigOptions } from './spark-wallet-D0Df_P_x.js';
|
|
2
|
+
import { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-CaNpBgiE.js';
|
|
3
3
|
import { V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-D7KDa4Ih.js';
|
|
4
4
|
import './spark-C7OG9mGJ.js';
|
|
5
5
|
import '@bufbuild/protobuf/wire';
|
package/dist/debug.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -19828,7 +19828,7 @@ init_buffer();
|
|
|
19828
19828
|
var import_core9 = require("@lightsparkdev/core");
|
|
19829
19829
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
19830
19830
|
var isBun = globalThis.Bun !== void 0;
|
|
19831
|
-
var packageVersion = true ? "0.2.
|
|
19831
|
+
var packageVersion = true ? "0.2.13" : "unknown";
|
|
19832
19832
|
var baseEnvStr = "unknown";
|
|
19833
19833
|
if (isBun) {
|
|
19834
19834
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -26719,24 +26719,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
26719
26719
|
throw new Error(`Error finalizing node signatures in transfer: ${error}`);
|
|
26720
26720
|
}
|
|
26721
26721
|
}
|
|
26722
|
-
async cancelTransfer(transfer, operatorAddress) {
|
|
26723
|
-
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
26724
|
-
try {
|
|
26725
|
-
const response = await sparkClient.cancel_transfer({
|
|
26726
|
-
transferId: transfer.id,
|
|
26727
|
-
senderIdentityPublicKey: await this.config.signer.getIdentityPublicKey()
|
|
26728
|
-
});
|
|
26729
|
-
return response.transfer;
|
|
26730
|
-
} catch (error) {
|
|
26731
|
-
throw new NetworkError(
|
|
26732
|
-
"Failed to cancel transfer",
|
|
26733
|
-
{
|
|
26734
|
-
method: "POST"
|
|
26735
|
-
},
|
|
26736
|
-
error
|
|
26737
|
-
);
|
|
26738
|
-
}
|
|
26739
|
-
}
|
|
26740
26722
|
async queryPendingTransfersBySender(operatorAddress) {
|
|
26741
26723
|
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
26742
26724
|
try {
|
|
@@ -33175,7 +33157,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33175
33157
|
message: e.message,
|
|
33176
33158
|
stack: e.stack
|
|
33177
33159
|
});
|
|
33178
|
-
await this.cancelAllSenderInitiatedTransfers();
|
|
33179
33160
|
throw new Error(`Failed to request leaves swap: ${e}`);
|
|
33180
33161
|
}
|
|
33181
33162
|
}
|
|
@@ -33638,6 +33619,64 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33638
33619
|
});
|
|
33639
33620
|
return tx.hex;
|
|
33640
33621
|
}
|
|
33622
|
+
/**
|
|
33623
|
+
* Refunds a static deposit and broadcasts the transaction to the network.
|
|
33624
|
+
*
|
|
33625
|
+
* @param {Object} params - The refund parameters
|
|
33626
|
+
* @param {string} params.depositTransactionId - The ID of the transaction
|
|
33627
|
+
* @param {number} [params.outputIndex] - The index of the output
|
|
33628
|
+
* @param {string} params.destinationAddress - The destination address
|
|
33629
|
+
* @param {number} [params.satsPerVbyteFee] - The fee per vbyte to refund
|
|
33630
|
+
* @returns {Promise<string>} The transaction ID
|
|
33631
|
+
*/
|
|
33632
|
+
async refundAndBroadcastStaticDeposit({
|
|
33633
|
+
depositTransactionId,
|
|
33634
|
+
outputIndex,
|
|
33635
|
+
destinationAddress,
|
|
33636
|
+
satsPerVbyteFee
|
|
33637
|
+
}) {
|
|
33638
|
+
const txHex = await this.refundStaticDeposit({
|
|
33639
|
+
depositTransactionId,
|
|
33640
|
+
outputIndex,
|
|
33641
|
+
destinationAddress,
|
|
33642
|
+
satsPerVbyteFee
|
|
33643
|
+
});
|
|
33644
|
+
return await this.broadcastTx(txHex);
|
|
33645
|
+
}
|
|
33646
|
+
/**
|
|
33647
|
+
* Broadcasts a transaction to the network.
|
|
33648
|
+
*
|
|
33649
|
+
* @param {string} txHex - The hex of the transaction
|
|
33650
|
+
* @returns {Promise<string>} The transaction ID
|
|
33651
|
+
*/
|
|
33652
|
+
async broadcastTx(txHex) {
|
|
33653
|
+
if (!txHex) {
|
|
33654
|
+
throw new ValidationError("Transaction hex cannot be empty", {
|
|
33655
|
+
field: "txHex"
|
|
33656
|
+
});
|
|
33657
|
+
}
|
|
33658
|
+
const { fetch, Headers: Headers2 } = getFetch();
|
|
33659
|
+
const baseUrl = this.config.getElectrsUrl();
|
|
33660
|
+
const headers = new Headers2();
|
|
33661
|
+
if (this.config.getNetwork() === 4 /* LOCAL */) {
|
|
33662
|
+
const localFaucet = BitcoinFaucet.getInstance();
|
|
33663
|
+
const response = await localFaucet.broadcastTx(txHex);
|
|
33664
|
+
return response;
|
|
33665
|
+
} else {
|
|
33666
|
+
if (this.config.getNetwork() === 3 /* REGTEST */) {
|
|
33667
|
+
const auth = btoa(
|
|
33668
|
+
`${ELECTRS_CREDENTIALS.username}:${ELECTRS_CREDENTIALS.password}`
|
|
33669
|
+
);
|
|
33670
|
+
headers.set("Authorization", `Basic ${auth}`);
|
|
33671
|
+
}
|
|
33672
|
+
const response = await fetch(`${baseUrl}/tx`, {
|
|
33673
|
+
method: "POST",
|
|
33674
|
+
body: txHex,
|
|
33675
|
+
headers
|
|
33676
|
+
});
|
|
33677
|
+
return response.text();
|
|
33678
|
+
}
|
|
33679
|
+
}
|
|
33641
33680
|
async getStaticDepositSigningPayload(transactionID, outputIndex, network, requestType, creditAmountSats, sspSignature) {
|
|
33642
33681
|
const encoder = new TextEncoder();
|
|
33643
33682
|
const parts = [];
|
|
@@ -34376,24 +34415,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34376
34415
|
(result) => result.status === "fulfilled" && result.value !== null
|
|
34377
34416
|
).map((result) => result.value);
|
|
34378
34417
|
}
|
|
34379
|
-
/**
|
|
34380
|
-
* Cancels all sender-initiated transfers.
|
|
34381
|
-
*
|
|
34382
|
-
* @returns {Promise<void>}
|
|
34383
|
-
* @private
|
|
34384
|
-
*/
|
|
34385
|
-
async cancelAllSenderInitiatedTransfers() {
|
|
34386
|
-
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
34387
|
-
const transfers = await this.transferService.queryPendingTransfersBySender(
|
|
34388
|
-
operator.address
|
|
34389
|
-
);
|
|
34390
|
-
for (const transfer of transfers.transfers) {
|
|
34391
|
-
if (transfer.status === 0 /* TRANSFER_STATUS_SENDER_INITIATED */) {
|
|
34392
|
-
await this.transferService.cancelTransfer(transfer, operator.address);
|
|
34393
|
-
}
|
|
34394
|
-
}
|
|
34395
|
-
}
|
|
34396
|
-
}
|
|
34397
34418
|
// ***** Lightning Flow *****
|
|
34398
34419
|
/**
|
|
34399
34420
|
* Creates a Lightning invoice for receiving payments.
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-
|
|
2
|
-
import { H as SparkWallet, F as SparkWalletProps } from './spark-wallet-
|
|
3
|
-
export { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, x as CreateLightningInvoiceParams, D as DecodedSparkAddressData, y as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, G as SparkWalletEvents, z as TokenBalanceMap, E as TokenMetadataMap, A as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-
|
|
4
|
-
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-
|
|
1
|
+
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-D1ta-sHH.cjs';
|
|
2
|
+
import { H as SparkWallet, F as SparkWalletProps } from './spark-wallet-Dvh1BLP6.cjs';
|
|
3
|
+
export { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, x as CreateLightningInvoiceParams, D as DecodedSparkAddressData, y as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, G as SparkWalletEvents, z as TokenBalanceMap, E as TokenMetadataMap, A as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-Dvh1BLP6.cjs';
|
|
4
|
+
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-BfTyKwqb.cjs';
|
|
5
5
|
export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-DVuA5-7M.cjs';
|
|
6
6
|
export { I as IKeyPackage } from './types-B3hMoTYO.cjs';
|
|
7
7
|
import './spark-C7OG9mGJ.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-
|
|
2
|
-
import { H as SparkWallet, F as SparkWalletProps } from './spark-wallet-
|
|
3
|
-
export { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, x as CreateLightningInvoiceParams, D as DecodedSparkAddressData, y as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, G as SparkWalletEvents, z as TokenBalanceMap, E as TokenMetadataMap, A as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-
|
|
4
|
-
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-
|
|
1
|
+
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-DINiKBzd.js';
|
|
2
|
+
import { H as SparkWallet, F as SparkWalletProps } from './spark-wallet-D0Df_P_x.js';
|
|
3
|
+
export { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, x as CreateLightningInvoiceParams, D as DecodedSparkAddressData, y as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, G as SparkWalletEvents, z as TokenBalanceMap, E as TokenMetadataMap, A as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-D0Df_P_x.js';
|
|
4
|
+
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-CaNpBgiE.js';
|
|
5
5
|
export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-D7KDa4Ih.js';
|
|
6
6
|
export { I as IKeyPackage } from './types-B3hMoTYO.js';
|
|
7
7
|
import './spark-C7OG9mGJ.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SparkWalletBrowser,
|
|
3
3
|
initializeTracerEnvBrowser
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CKHJFQUA.js";
|
|
5
5
|
import "./chunk-BYXBJQAS.js";
|
|
6
6
|
import {
|
|
7
7
|
AuthenticationError,
|
|
@@ -114,7 +114,7 @@ import {
|
|
|
114
114
|
validateShare,
|
|
115
115
|
validateSparkInvoiceFields,
|
|
116
116
|
validateSparkInvoiceSignature
|
|
117
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-LX45BCZW.js";
|
|
118
118
|
import {
|
|
119
119
|
LOGGER_NAMES,
|
|
120
120
|
SparkSdkLogger
|
package/dist/index.node.cjs
CHANGED
|
@@ -19829,7 +19829,7 @@ init_buffer();
|
|
|
19829
19829
|
var import_core9 = require("@lightsparkdev/core");
|
|
19830
19830
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
19831
19831
|
var isBun = globalThis.Bun !== void 0;
|
|
19832
|
-
var packageVersion = true ? "0.2.
|
|
19832
|
+
var packageVersion = true ? "0.2.13" : "unknown";
|
|
19833
19833
|
var baseEnvStr = "unknown";
|
|
19834
19834
|
if (isBun) {
|
|
19835
19835
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -26720,24 +26720,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
26720
26720
|
throw new Error(`Error finalizing node signatures in transfer: ${error}`);
|
|
26721
26721
|
}
|
|
26722
26722
|
}
|
|
26723
|
-
async cancelTransfer(transfer, operatorAddress) {
|
|
26724
|
-
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
26725
|
-
try {
|
|
26726
|
-
const response = await sparkClient.cancel_transfer({
|
|
26727
|
-
transferId: transfer.id,
|
|
26728
|
-
senderIdentityPublicKey: await this.config.signer.getIdentityPublicKey()
|
|
26729
|
-
});
|
|
26730
|
-
return response.transfer;
|
|
26731
|
-
} catch (error) {
|
|
26732
|
-
throw new NetworkError(
|
|
26733
|
-
"Failed to cancel transfer",
|
|
26734
|
-
{
|
|
26735
|
-
method: "POST"
|
|
26736
|
-
},
|
|
26737
|
-
error
|
|
26738
|
-
);
|
|
26739
|
-
}
|
|
26740
|
-
}
|
|
26741
26723
|
async queryPendingTransfersBySender(operatorAddress) {
|
|
26742
26724
|
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
26743
26725
|
try {
|
|
@@ -33176,7 +33158,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33176
33158
|
message: e.message,
|
|
33177
33159
|
stack: e.stack
|
|
33178
33160
|
});
|
|
33179
|
-
await this.cancelAllSenderInitiatedTransfers();
|
|
33180
33161
|
throw new Error(`Failed to request leaves swap: ${e}`);
|
|
33181
33162
|
}
|
|
33182
33163
|
}
|
|
@@ -33639,6 +33620,64 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33639
33620
|
});
|
|
33640
33621
|
return tx.hex;
|
|
33641
33622
|
}
|
|
33623
|
+
/**
|
|
33624
|
+
* Refunds a static deposit and broadcasts the transaction to the network.
|
|
33625
|
+
*
|
|
33626
|
+
* @param {Object} params - The refund parameters
|
|
33627
|
+
* @param {string} params.depositTransactionId - The ID of the transaction
|
|
33628
|
+
* @param {number} [params.outputIndex] - The index of the output
|
|
33629
|
+
* @param {string} params.destinationAddress - The destination address
|
|
33630
|
+
* @param {number} [params.satsPerVbyteFee] - The fee per vbyte to refund
|
|
33631
|
+
* @returns {Promise<string>} The transaction ID
|
|
33632
|
+
*/
|
|
33633
|
+
async refundAndBroadcastStaticDeposit({
|
|
33634
|
+
depositTransactionId,
|
|
33635
|
+
outputIndex,
|
|
33636
|
+
destinationAddress,
|
|
33637
|
+
satsPerVbyteFee
|
|
33638
|
+
}) {
|
|
33639
|
+
const txHex = await this.refundStaticDeposit({
|
|
33640
|
+
depositTransactionId,
|
|
33641
|
+
outputIndex,
|
|
33642
|
+
destinationAddress,
|
|
33643
|
+
satsPerVbyteFee
|
|
33644
|
+
});
|
|
33645
|
+
return await this.broadcastTx(txHex);
|
|
33646
|
+
}
|
|
33647
|
+
/**
|
|
33648
|
+
* Broadcasts a transaction to the network.
|
|
33649
|
+
*
|
|
33650
|
+
* @param {string} txHex - The hex of the transaction
|
|
33651
|
+
* @returns {Promise<string>} The transaction ID
|
|
33652
|
+
*/
|
|
33653
|
+
async broadcastTx(txHex) {
|
|
33654
|
+
if (!txHex) {
|
|
33655
|
+
throw new ValidationError("Transaction hex cannot be empty", {
|
|
33656
|
+
field: "txHex"
|
|
33657
|
+
});
|
|
33658
|
+
}
|
|
33659
|
+
const { fetch, Headers: Headers2 } = getFetch();
|
|
33660
|
+
const baseUrl = this.config.getElectrsUrl();
|
|
33661
|
+
const headers = new Headers2();
|
|
33662
|
+
if (this.config.getNetwork() === 4 /* LOCAL */) {
|
|
33663
|
+
const localFaucet = BitcoinFaucet.getInstance();
|
|
33664
|
+
const response = await localFaucet.broadcastTx(txHex);
|
|
33665
|
+
return response;
|
|
33666
|
+
} else {
|
|
33667
|
+
if (this.config.getNetwork() === 3 /* REGTEST */) {
|
|
33668
|
+
const auth = btoa(
|
|
33669
|
+
`${ELECTRS_CREDENTIALS.username}:${ELECTRS_CREDENTIALS.password}`
|
|
33670
|
+
);
|
|
33671
|
+
headers.set("Authorization", `Basic ${auth}`);
|
|
33672
|
+
}
|
|
33673
|
+
const response = await fetch(`${baseUrl}/tx`, {
|
|
33674
|
+
method: "POST",
|
|
33675
|
+
body: txHex,
|
|
33676
|
+
headers
|
|
33677
|
+
});
|
|
33678
|
+
return response.text();
|
|
33679
|
+
}
|
|
33680
|
+
}
|
|
33642
33681
|
async getStaticDepositSigningPayload(transactionID, outputIndex, network, requestType, creditAmountSats, sspSignature) {
|
|
33643
33682
|
const encoder = new TextEncoder();
|
|
33644
33683
|
const parts = [];
|
|
@@ -34377,24 +34416,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34377
34416
|
(result) => result.status === "fulfilled" && result.value !== null
|
|
34378
34417
|
).map((result) => result.value);
|
|
34379
34418
|
}
|
|
34380
|
-
/**
|
|
34381
|
-
* Cancels all sender-initiated transfers.
|
|
34382
|
-
*
|
|
34383
|
-
* @returns {Promise<void>}
|
|
34384
|
-
* @private
|
|
34385
|
-
*/
|
|
34386
|
-
async cancelAllSenderInitiatedTransfers() {
|
|
34387
|
-
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
34388
|
-
const transfers = await this.transferService.queryPendingTransfersBySender(
|
|
34389
|
-
operator.address
|
|
34390
|
-
);
|
|
34391
|
-
for (const transfer of transfers.transfers) {
|
|
34392
|
-
if (transfer.status === 0 /* TRANSFER_STATUS_SENDER_INITIATED */) {
|
|
34393
|
-
await this.transferService.cancelTransfer(transfer, operator.address);
|
|
34394
|
-
}
|
|
34395
|
-
}
|
|
34396
|
-
}
|
|
34397
|
-
}
|
|
34398
34419
|
// ***** Lightning Flow *****
|
|
34399
34420
|
/**
|
|
34400
34421
|
* Creates a Lightning invoice for receiving payments.
|
package/dist/index.node.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-
|
|
2
|
-
export { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, x as CreateLightningInvoiceParams, D as DecodedSparkAddressData, y as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, G as SparkWalletEvents, F as SparkWalletProps, z as TokenBalanceMap, E as TokenMetadataMap, A as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-
|
|
3
|
-
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-
|
|
1
|
+
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-D1ta-sHH.cjs';
|
|
2
|
+
export { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, x as CreateLightningInvoiceParams, D as DecodedSparkAddressData, y as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, G as SparkWalletEvents, F as SparkWalletProps, z as TokenBalanceMap, E as TokenMetadataMap, A as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-Dvh1BLP6.cjs';
|
|
3
|
+
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-BfTyKwqb.cjs';
|
|
4
4
|
export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-DVuA5-7M.cjs';
|
|
5
5
|
export { I as IKeyPackage } from './types-B3hMoTYO.cjs';
|
|
6
|
-
export { S as SparkWallet, i as initializeTracerEnv } from './spark-wallet.node-
|
|
6
|
+
export { S as SparkWallet, i as initializeTracerEnv } from './spark-wallet.node-B3V8_fgw.cjs';
|
|
7
7
|
import './spark-C7OG9mGJ.cjs';
|
|
8
8
|
import '@bufbuild/protobuf/wire';
|
|
9
9
|
import 'nice-grpc-common';
|
package/dist/index.node.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-
|
|
2
|
-
export { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, x as CreateLightningInvoiceParams, D as DecodedSparkAddressData, y as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, G as SparkWalletEvents, F as SparkWalletProps, z as TokenBalanceMap, E as TokenMetadataMap, A as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-
|
|
3
|
-
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-
|
|
1
|
+
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-DINiKBzd.js';
|
|
2
|
+
export { B as Bech32mTokenIdentifier, r as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, x as CreateLightningInvoiceParams, D as DecodedSparkAddressData, y as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, N as Network, m as NetworkToProto, l as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, G as SparkWalletEvents, F as SparkWalletProps, z as TokenBalanceMap, E as TokenMetadataMap, A as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, u as decodeBech32mTokenIdentifier, f as decodeSparkAddress, s as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, n as getNetwork, o as getNetworkFromAddress, w as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, q as getNetworkFromString, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-D0Df_P_x.js';
|
|
3
|
+
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, ai as LOGGER_NAMES, a5 as LeafInfo, aj as LoggerName, ak as SparkSdkLogger, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './logging-CaNpBgiE.js';
|
|
4
4
|
export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-D7KDa4Ih.js';
|
|
5
5
|
export { I as IKeyPackage } from './types-B3hMoTYO.js';
|
|
6
|
-
export { S as SparkWallet, i as initializeTracerEnv } from './spark-wallet.node-
|
|
6
|
+
export { S as SparkWallet, i as initializeTracerEnv } from './spark-wallet.node-bGmy8-T8.js';
|
|
7
7
|
import './spark-C7OG9mGJ.js';
|
|
8
8
|
import '@bufbuild/protobuf/wire';
|
|
9
9
|
import 'nice-grpc-common';
|
package/dist/index.node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as btc from '@scure/btc-signer';
|
|
2
2
|
import { Transaction } from '@scure/btc-signer';
|
|
3
3
|
import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
|
|
4
|
-
import { N as Network, A as TokenOutputsMap, B as Bech32mTokenIdentifier, z as TokenBalanceMap, S as SparkAddressFormat } from './spark-wallet-
|
|
4
|
+
import { N as Network, A as TokenOutputsMap, B as Bech32mTokenIdentifier, z as TokenBalanceMap, S as SparkAddressFormat } from './spark-wallet-Dvh1BLP6.cjs';
|
|
5
5
|
import { j as SigningNonce, k as SigningCommitment } from './client-DVuA5-7M.cjs';
|
|
6
6
|
import { O as OutputWithPreviousTransactionData, f as TransferPackage, c as SparkServiceClient } from './spark-C7OG9mGJ.cjs';
|
|
7
7
|
import { Logger, LoggingLevel } from '@lightsparkdev/core';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as btc from '@scure/btc-signer';
|
|
2
2
|
import { Transaction } from '@scure/btc-signer';
|
|
3
3
|
import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
|
|
4
|
-
import { N as Network, A as TokenOutputsMap, B as Bech32mTokenIdentifier, z as TokenBalanceMap, S as SparkAddressFormat } from './spark-wallet-
|
|
4
|
+
import { N as Network, A as TokenOutputsMap, B as Bech32mTokenIdentifier, z as TokenBalanceMap, S as SparkAddressFormat } from './spark-wallet-D0Df_P_x.js';
|
|
5
5
|
import { j as SigningNonce, k as SigningCommitment } from './client-D7KDa4Ih.js';
|
|
6
6
|
import { O as OutputWithPreviousTransactionData, f as TransferPackage, c as SparkServiceClient } from './spark-C7OG9mGJ.js';
|
|
7
7
|
import { Logger, LoggingLevel } from '@lightsparkdev/core';
|
package/dist/native/index.cjs
CHANGED
|
@@ -19954,7 +19954,7 @@ init_buffer();
|
|
|
19954
19954
|
var import_core9 = require("@lightsparkdev/core");
|
|
19955
19955
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
19956
19956
|
var isBun = globalThis.Bun !== void 0;
|
|
19957
|
-
var packageVersion = true ? "0.2.
|
|
19957
|
+
var packageVersion = true ? "0.2.13" : "unknown";
|
|
19958
19958
|
var baseEnvStr = "unknown";
|
|
19959
19959
|
if (isBun) {
|
|
19960
19960
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -26775,24 +26775,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
26775
26775
|
throw new Error(`Error finalizing node signatures in transfer: ${error}`);
|
|
26776
26776
|
}
|
|
26777
26777
|
}
|
|
26778
|
-
async cancelTransfer(transfer, operatorAddress) {
|
|
26779
|
-
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
26780
|
-
try {
|
|
26781
|
-
const response = await sparkClient.cancel_transfer({
|
|
26782
|
-
transferId: transfer.id,
|
|
26783
|
-
senderIdentityPublicKey: await this.config.signer.getIdentityPublicKey()
|
|
26784
|
-
});
|
|
26785
|
-
return response.transfer;
|
|
26786
|
-
} catch (error) {
|
|
26787
|
-
throw new NetworkError(
|
|
26788
|
-
"Failed to cancel transfer",
|
|
26789
|
-
{
|
|
26790
|
-
method: "POST"
|
|
26791
|
-
},
|
|
26792
|
-
error
|
|
26793
|
-
);
|
|
26794
|
-
}
|
|
26795
|
-
}
|
|
26796
26778
|
async queryPendingTransfersBySender(operatorAddress) {
|
|
26797
26779
|
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
26798
26780
|
try {
|
|
@@ -33231,7 +33213,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33231
33213
|
message: e.message,
|
|
33232
33214
|
stack: e.stack
|
|
33233
33215
|
});
|
|
33234
|
-
await this.cancelAllSenderInitiatedTransfers();
|
|
33235
33216
|
throw new Error(`Failed to request leaves swap: ${e}`);
|
|
33236
33217
|
}
|
|
33237
33218
|
}
|
|
@@ -33694,6 +33675,64 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33694
33675
|
});
|
|
33695
33676
|
return tx.hex;
|
|
33696
33677
|
}
|
|
33678
|
+
/**
|
|
33679
|
+
* Refunds a static deposit and broadcasts the transaction to the network.
|
|
33680
|
+
*
|
|
33681
|
+
* @param {Object} params - The refund parameters
|
|
33682
|
+
* @param {string} params.depositTransactionId - The ID of the transaction
|
|
33683
|
+
* @param {number} [params.outputIndex] - The index of the output
|
|
33684
|
+
* @param {string} params.destinationAddress - The destination address
|
|
33685
|
+
* @param {number} [params.satsPerVbyteFee] - The fee per vbyte to refund
|
|
33686
|
+
* @returns {Promise<string>} The transaction ID
|
|
33687
|
+
*/
|
|
33688
|
+
async refundAndBroadcastStaticDeposit({
|
|
33689
|
+
depositTransactionId,
|
|
33690
|
+
outputIndex,
|
|
33691
|
+
destinationAddress,
|
|
33692
|
+
satsPerVbyteFee
|
|
33693
|
+
}) {
|
|
33694
|
+
const txHex = await this.refundStaticDeposit({
|
|
33695
|
+
depositTransactionId,
|
|
33696
|
+
outputIndex,
|
|
33697
|
+
destinationAddress,
|
|
33698
|
+
satsPerVbyteFee
|
|
33699
|
+
});
|
|
33700
|
+
return await this.broadcastTx(txHex);
|
|
33701
|
+
}
|
|
33702
|
+
/**
|
|
33703
|
+
* Broadcasts a transaction to the network.
|
|
33704
|
+
*
|
|
33705
|
+
* @param {string} txHex - The hex of the transaction
|
|
33706
|
+
* @returns {Promise<string>} The transaction ID
|
|
33707
|
+
*/
|
|
33708
|
+
async broadcastTx(txHex) {
|
|
33709
|
+
if (!txHex) {
|
|
33710
|
+
throw new ValidationError("Transaction hex cannot be empty", {
|
|
33711
|
+
field: "txHex"
|
|
33712
|
+
});
|
|
33713
|
+
}
|
|
33714
|
+
const { fetch, Headers: Headers2 } = getFetch();
|
|
33715
|
+
const baseUrl = this.config.getElectrsUrl();
|
|
33716
|
+
const headers = new Headers2();
|
|
33717
|
+
if (this.config.getNetwork() === 4 /* LOCAL */) {
|
|
33718
|
+
const localFaucet = BitcoinFaucet.getInstance();
|
|
33719
|
+
const response = await localFaucet.broadcastTx(txHex);
|
|
33720
|
+
return response;
|
|
33721
|
+
} else {
|
|
33722
|
+
if (this.config.getNetwork() === 3 /* REGTEST */) {
|
|
33723
|
+
const auth = btoa(
|
|
33724
|
+
`${ELECTRS_CREDENTIALS.username}:${ELECTRS_CREDENTIALS.password}`
|
|
33725
|
+
);
|
|
33726
|
+
headers.set("Authorization", `Basic ${auth}`);
|
|
33727
|
+
}
|
|
33728
|
+
const response = await fetch(`${baseUrl}/tx`, {
|
|
33729
|
+
method: "POST",
|
|
33730
|
+
body: txHex,
|
|
33731
|
+
headers
|
|
33732
|
+
});
|
|
33733
|
+
return response.text();
|
|
33734
|
+
}
|
|
33735
|
+
}
|
|
33697
33736
|
async getStaticDepositSigningPayload(transactionID, outputIndex, network, requestType, creditAmountSats, sspSignature) {
|
|
33698
33737
|
const encoder = new TextEncoder();
|
|
33699
33738
|
const parts = [];
|
|
@@ -34432,24 +34471,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34432
34471
|
(result) => result.status === "fulfilled" && result.value !== null
|
|
34433
34472
|
).map((result) => result.value);
|
|
34434
34473
|
}
|
|
34435
|
-
/**
|
|
34436
|
-
* Cancels all sender-initiated transfers.
|
|
34437
|
-
*
|
|
34438
|
-
* @returns {Promise<void>}
|
|
34439
|
-
* @private
|
|
34440
|
-
*/
|
|
34441
|
-
async cancelAllSenderInitiatedTransfers() {
|
|
34442
|
-
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
34443
|
-
const transfers = await this.transferService.queryPendingTransfersBySender(
|
|
34444
|
-
operator.address
|
|
34445
|
-
);
|
|
34446
|
-
for (const transfer of transfers.transfers) {
|
|
34447
|
-
if (transfer.status === 0 /* TRANSFER_STATUS_SENDER_INITIATED */) {
|
|
34448
|
-
await this.transferService.cancelTransfer(transfer, operator.address);
|
|
34449
|
-
}
|
|
34450
|
-
}
|
|
34451
|
-
}
|
|
34452
|
-
}
|
|
34453
34474
|
// ***** Lightning Flow *****
|
|
34454
34475
|
/**
|
|
34455
34476
|
* Creates a Lightning invoice for receiving payments.
|
package/dist/native/index.d.cts
CHANGED
|
@@ -3330,7 +3330,6 @@ declare class TransferService extends BaseTransferService {
|
|
|
3330
3330
|
private prepareClaimLeafKeyTweaks;
|
|
3331
3331
|
claimTransferSignRefunds(transfer: Transfer$1, leafKeys: LeafKeyTweak[], proofMap?: Map<string, Uint8Array[]>): Promise<NodeSignatures[]>;
|
|
3332
3332
|
private finalizeNodeSignatures;
|
|
3333
|
-
cancelTransfer(transfer: Transfer$1, operatorAddress: string): Promise<Transfer$1 | undefined>;
|
|
3334
3333
|
queryPendingTransfersBySender(operatorAddress: string): Promise<QueryTransfersResponse>;
|
|
3335
3334
|
private refreshTimelockNodesInternal;
|
|
3336
3335
|
refreshTimelockNodes(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
|
|
@@ -3591,6 +3590,29 @@ declare class SparkWallet extends EventEmitter {
|
|
|
3591
3590
|
/** @deprecated use `satsPerVbyteFee` */ fee?: number;
|
|
3592
3591
|
satsPerVbyteFee?: number;
|
|
3593
3592
|
}): Promise<string>;
|
|
3593
|
+
/**
|
|
3594
|
+
* Refunds a static deposit and broadcasts the transaction to the network.
|
|
3595
|
+
*
|
|
3596
|
+
* @param {Object} params - The refund parameters
|
|
3597
|
+
* @param {string} params.depositTransactionId - The ID of the transaction
|
|
3598
|
+
* @param {number} [params.outputIndex] - The index of the output
|
|
3599
|
+
* @param {string} params.destinationAddress - The destination address
|
|
3600
|
+
* @param {number} [params.satsPerVbyteFee] - The fee per vbyte to refund
|
|
3601
|
+
* @returns {Promise<string>} The transaction ID
|
|
3602
|
+
*/
|
|
3603
|
+
refundAndBroadcastStaticDeposit({ depositTransactionId, outputIndex, destinationAddress, satsPerVbyteFee, }: {
|
|
3604
|
+
depositTransactionId: string;
|
|
3605
|
+
outputIndex?: number;
|
|
3606
|
+
destinationAddress: string;
|
|
3607
|
+
satsPerVbyteFee?: number;
|
|
3608
|
+
}): Promise<string>;
|
|
3609
|
+
/**
|
|
3610
|
+
* Broadcasts a transaction to the network.
|
|
3611
|
+
*
|
|
3612
|
+
* @param {string} txHex - The hex of the transaction
|
|
3613
|
+
* @returns {Promise<string>} The transaction ID
|
|
3614
|
+
*/
|
|
3615
|
+
private broadcastTx;
|
|
3594
3616
|
private getStaticDepositSigningPayload;
|
|
3595
3617
|
private getDepositTransactionVout;
|
|
3596
3618
|
private getDepositTransaction;
|
|
@@ -3676,13 +3698,6 @@ declare class SparkWallet extends EventEmitter {
|
|
|
3676
3698
|
* @private
|
|
3677
3699
|
*/
|
|
3678
3700
|
private claimTransfers;
|
|
3679
|
-
/**
|
|
3680
|
-
* Cancels all sender-initiated transfers.
|
|
3681
|
-
*
|
|
3682
|
-
* @returns {Promise<void>}
|
|
3683
|
-
* @private
|
|
3684
|
-
*/
|
|
3685
|
-
private cancelAllSenderInitiatedTransfers;
|
|
3686
3701
|
/**
|
|
3687
3702
|
* Creates a Lightning invoice for receiving payments.
|
|
3688
3703
|
*
|