@qntx/spark 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-Bq6pNclo.d.mts → index-CsGON46O.d.mts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +9 -8
- package/dist/server.d.mts +1 -1
- package/dist/signer.d.mts +2 -2
- package/dist/signer.mjs +2 -2
- package/dist/{token-DmojVTWi.mjs → token-C3vqRH-k.mjs} +13 -12
- package/dist/{transactions-DjTZU8ev.d.mts → transactions-p89sj_IQ.d.mts} +5 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as SparkOperatorConfig, n as SparkNetwork, o as Signature, r as SparkNetworkConfig } from "./lightning-address-CRULmi9v.mjs";
|
|
2
|
-
import { v as SparkSigner } from "./transactions-
|
|
2
|
+
import { v as SparkSigner } from "./transactions-p89sj_IQ.mjs";
|
|
3
3
|
import "@bufbuild/protobuf/codegenv2";
|
|
4
4
|
import "@bufbuild/protobuf/wkt";
|
|
5
5
|
import { Message, UnknownEnum } from "@bufbuild/protobuf";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as SparkTokenBroadcastError, i as SparkRequestError, n as SparkError, r as SparkInputError, t as SparkCryptoError } from "./index-D1fBaHTa.mjs";
|
|
2
2
|
import { a as sparkNetworkConfig, i as SparkOperatorConfig, n as SparkNetwork, r as SparkNetworkConfig } from "./lightning-address-CRULmi9v.mjs";
|
|
3
3
|
import { i as isExpired, n as Bolt11Network, r as decodeBolt11, t as Bolt11Invoice } from "./bolt11-DsNTTS_O.mjs";
|
|
4
|
-
import { A as CooperativeExitSpeed, C as ExitTransaction, D as createMemorySparkStore, E as SparkStore, F as StaticDepositUtxo, I as UnusedDepositAddress, L as SparkLeaf, M as MIN_STATIC_REFUND_FEE_SATS, N as StaticDepositClaim, O as CooperativeExitQuote, P as StaticDepositRefund, R as SparkEvent, S as WatchtowerExitedLeaf, T as SparkExitChain, _ as LightningSendOutcome, a as createSparkClient, b as LightningPayment, c as buildCpfpChild, d as SparkTransferLeaf, f as SparkTokenBalance, g as LightningReceiveStatus, h as SparkWalletSettings, i as SparkInvoiceStatus, j as CooperativeExitStatus, k as CooperativeExitResult, l as SparkPayment, m as SparkTokenOutputStatus, n as SparkClient, o as StaticDepositClaimResult, p as SparkTokenOutput, r as SparkClientOptions, s as FundingInput, t as ClaimPendingResult, u as SparkTransfer, v as LightningSendStatus, w as exitTransactions, x as LightningInvoice, y as LightningSendStatusRequest } from "./index-
|
|
5
|
-
import { n as EPHEMERAL_ANCHOR_SCRIPT, t as
|
|
4
|
+
import { A as CooperativeExitSpeed, C as ExitTransaction, D as createMemorySparkStore, E as SparkStore, F as StaticDepositUtxo, I as UnusedDepositAddress, L as SparkLeaf, M as MIN_STATIC_REFUND_FEE_SATS, N as StaticDepositClaim, O as CooperativeExitQuote, P as StaticDepositRefund, R as SparkEvent, S as WatchtowerExitedLeaf, T as SparkExitChain, _ as LightningSendOutcome, a as createSparkClient, b as LightningPayment, c as buildCpfpChild, d as SparkTransferLeaf, f as SparkTokenBalance, g as LightningReceiveStatus, h as SparkWalletSettings, i as SparkInvoiceStatus, j as CooperativeExitStatus, k as CooperativeExitResult, l as SparkPayment, m as SparkTokenOutputStatus, n as SparkClient, o as StaticDepositClaimResult, p as SparkTokenOutput, r as SparkClientOptions, s as FundingInput, t as ClaimPendingResult, u as SparkTransfer, v as LightningSendStatus, w as exitTransactions, x as LightningInvoice, y as LightningSendStatusRequest } from "./index-CsGON46O.mjs";
|
|
5
|
+
import { n as EPHEMERAL_ANCHOR_SCRIPT, t as bitcoinAddressScript, v as SparkSigner } from "./transactions-p89sj_IQ.mjs";
|
|
6
6
|
//#region src/core/invoice.d.ts
|
|
7
7
|
/** Payment carried by a Spark invoice: satoshis or BTKN tokens. */
|
|
8
8
|
type SparkInvoicePayment = {
|
|
@@ -120,4 +120,4 @@ export declare function parseSparkInvoice(text: string, options: {
|
|
|
120
120
|
readonly now: number;
|
|
121
121
|
}): ParsedSparkInvoice;
|
|
122
122
|
//#endregion
|
|
123
|
-
export { type Bolt11Invoice, type Bolt11Network, type ClaimPendingResult, type CooperativeExitQuote, type CooperativeExitResult, type CooperativeExitSpeed, type CooperativeExitStatus, EPHEMERAL_ANCHOR_SCRIPT, type ExitTransaction, type FundingInput, type LightningInvoice, type LightningPayment, type LightningReceiveStatus, type LightningSendOutcome, type LightningSendStatus, type LightningSendStatusRequest, MIN_STATIC_REFUND_FEE_SATS, type ParsedSparkInvoice, type SparkAddress, type SparkClient, type SparkClientOptions, SparkCryptoError, SparkError, type SparkEvent, type SparkExitChain, SparkInputError, type SparkInvoiceFields, type SparkInvoicePayment, type SparkInvoiceStatus, type SparkLeaf, type SparkNetwork, type SparkNetworkConfig, type SparkOperatorConfig, type SparkPayment, SparkRequestError, type SparkStore, type SparkTokenBalance, SparkTokenBroadcastError, type SparkTokenIdentifierData, type SparkTokenOutput, type SparkTokenOutputStatus, type SparkTransfer, type SparkTransferLeaf, type SparkWalletSettings, type StaticDepositClaim, type StaticDepositClaimResult, type StaticDepositRefund, type StaticDepositUtxo, type UnusedDepositAddress, type WatchtowerExitedLeaf,
|
|
123
|
+
export { type Bolt11Invoice, type Bolt11Network, type ClaimPendingResult, type CooperativeExitQuote, type CooperativeExitResult, type CooperativeExitSpeed, type CooperativeExitStatus, EPHEMERAL_ANCHOR_SCRIPT, type ExitTransaction, type FundingInput, type LightningInvoice, type LightningPayment, type LightningReceiveStatus, type LightningSendOutcome, type LightningSendStatus, type LightningSendStatusRequest, MIN_STATIC_REFUND_FEE_SATS, type ParsedSparkInvoice, type SparkAddress, type SparkClient, type SparkClientOptions, SparkCryptoError, SparkError, type SparkEvent, type SparkExitChain, SparkInputError, type SparkInvoiceFields, type SparkInvoicePayment, type SparkInvoiceStatus, type SparkLeaf, type SparkNetwork, type SparkNetworkConfig, type SparkOperatorConfig, type SparkPayment, SparkRequestError, type SparkStore, type SparkTokenBalance, SparkTokenBroadcastError, type SparkTokenIdentifierData, type SparkTokenOutput, type SparkTokenOutputStatus, type SparkTransfer, type SparkTransferLeaf, type SparkWalletSettings, type StaticDepositClaim, type StaticDepositClaimResult, type StaticDepositRefund, type StaticDepositUtxo, type UnusedDepositAddress, type WatchtowerExitedLeaf, bitcoinAddressScript, buildCpfpChild, createMemorySparkStore, createSparkClient, decodeBolt11, exitTransactions, isExpired, sparkNetworkConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as SparkTokenBroadcastError, i as SparkRequestError, n as SparkError, r as SparkInputError, t as SparkCryptoError } from "./errors-5xLkExNL.mjs";
|
|
2
|
-
import { $ as SparkAuthnService, A as EPHEMERAL_ANCHOR_SCRIPT, B as parseTransaction, Bt as TransferReceiverStatus, C as createInitialTimelockRefundTxs, Ct as InitiatePreimageSwapRequest_Reason, D as txId, Dt as RenewNodeTimelockSigningJobSchema, E as estimateVbytes, Et as Order, Ft as SparkAddressSchema, G as PartialTokenOutputSchema, Gt as SignatureScheme, Ht as TransferType, I as doesTxnNeedRenewed, It as SparkInvoiceFieldsSchema, J as SparkTokenService, K as PartialTokenTransactionSchema, L as getNextHTLCTransactionSequence, Lt as SparkService, M as computeTaprootKeyNoScript, N as p2trScriptFromPublicKey, Nt as SenderTransferPackageSchema, O as txIdInputBytes, Ot as RenewNodeZeroTimelockSigningJobSchema, P as xOnlyPublicKey, Pt as SigningJobSchema, Q as ChallengeSchema, R as getTimelockFromSequence, Rt as StartTransferRequestSchema, S as createInitialTimelockNodeTx, St as HashVariant, T as createZeroTimelockNodeTx, Tt as InvoiceStatus, U as CommitStatus, Ut as TreeNodeStatus, V as taprootKeySpendSighash, Vt as TransferStatus, W as InvoiceAttachmentSchema, Wt as UserSignedTxSigningJobSchema, X as TokenTransactionMetadataSchema, Y as TokenOutputStatus, Z as TokenTransactionStatus, _ as
|
|
2
|
+
import { $ as SparkAuthnService, A as EPHEMERAL_ANCHOR_SCRIPT, B as parseTransaction, Bt as TransferReceiverStatus, C as createInitialTimelockRefundTxs, Ct as InitiatePreimageSwapRequest_Reason, D as txId, Dt as RenewNodeTimelockSigningJobSchema, E as estimateVbytes, Et as Order, Ft as SparkAddressSchema, G as PartialTokenOutputSchema, Gt as SignatureScheme, Ht as TransferType, I as doesTxnNeedRenewed, It as SparkInvoiceFieldsSchema, J as SparkTokenService, K as PartialTokenTransactionSchema, L as getNextHTLCTransactionSequence, Lt as SparkService, M as computeTaprootKeyNoScript, N as p2trScriptFromPublicKey, Nt as SenderTransferPackageSchema, O as txIdInputBytes, Ot as RenewNodeZeroTimelockSigningJobSchema, P as xOnlyPublicKey, Pt as SigningJobSchema, Q as ChallengeSchema, R as getTimelockFromSequence, Rt as StartTransferRequestSchema, S as createInitialTimelockNodeTx, St as HashVariant, T as createZeroTimelockNodeTx, Tt as InvoiceStatus, U as CommitStatus, Ut as TreeNodeStatus, V as taprootKeySpendSighash, Vt as TransferStatus, W as InvoiceAttachmentSchema, Wt as UserSignedTxSigningJobSchema, X as TokenTransactionMetadataSchema, Y as TokenOutputStatus, Z as TokenTransactionStatus, _ as bitcoinAddressScript, _t as AdaptorPublicKeyPackageSchema, a as proofOfPossessionDigest, at as uuidToBytes, b as createDecrementedTimelockNodeTx, bt as ClaimPackageSchema, d as LIGHTNING_HTLC_SEQUENCE, dt as assertU32, et as hashSparkInvoice, f as constructHtlcSenderSpend, ft as requireLength, g as lightningHtlcOutputScript, gt as sparkNetworkProto, h as finalizeHtlcSpend, ht as sparkNetworkFromProto, it as uuidFromBytes, j as btcNetwork, k as verifyFinalizedTaprootSignature, kt as RenewRefundTimelockSigningJobSchema, lt as assertCompressedKey, mt as sparkNetworkConfig, nt as protoInvoiceToPlain, o as sendLeafSigningDigest, ot as uuidv7, p as createRefundTxsForLightning, pt as u64ToSats, q as SignatureWithIndexSchema, rt as validateInvoiceFields, st as compareBytes, t as hashFinalTokenTransaction, tt as encodeInvoiceFields, ut as assertSats, v as createConnectorRefundTxs, w as createMultiInputRootTx, wt as InputSigningDataSchema, x as createDecrementedTimelockRefundTxs, xt as Direction, y as createCurrentTimelockRefundTxs, z as isZeroTimelock, zt as TransferPackageSchema } from "./token-C3vqRH-k.mjs";
|
|
3
3
|
import { n as isExpired, t as decodeBolt11 } from "./bolt11-rfxnyLcb.mjs";
|
|
4
4
|
import { t as serverErrorText } from "./text-CDhN7qo4.mjs";
|
|
5
5
|
import { bytesToHex, hexToBytes, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
@@ -2376,7 +2376,7 @@ function validateCoopExitPayoutTransaction(params) {
|
|
|
2376
2376
|
}
|
|
2377
2377
|
function p2trAddressScript(address, network) {
|
|
2378
2378
|
try {
|
|
2379
|
-
return
|
|
2379
|
+
return bitcoinAddressScript(address, network);
|
|
2380
2380
|
} catch (error) {
|
|
2381
2381
|
throw new SparkInputError("expectedPayoutAddress: could not decode the withdrawal address", { cause: error });
|
|
2382
2382
|
}
|
|
@@ -3192,7 +3192,7 @@ function depositScript(verifyingKey, network) {
|
|
|
3192
3192
|
/** Output script of a coordinator-supplied address, decoded under our network only. */
|
|
3193
3193
|
function depositAddressScript(address, network) {
|
|
3194
3194
|
try {
|
|
3195
|
-
return
|
|
3195
|
+
return bitcoinAddressScript(address, network);
|
|
3196
3196
|
} catch (error) {
|
|
3197
3197
|
throw new SparkError("deposit: address does not decode under our network", { cause: error });
|
|
3198
3198
|
}
|
|
@@ -6666,7 +6666,7 @@ async function payLightningInvoice(deps, options) {
|
|
|
6666
6666
|
*/
|
|
6667
6667
|
async function sweepHtlcTimeout(deps, options) {
|
|
6668
6668
|
if (!Number.isFinite(options.feeRateSatPerVbyte) || options.feeRateSatPerVbyte <= 0) throw new SparkInputError("feeRateSatPerVbyte: must be a positive finite number");
|
|
6669
|
-
const destinationScript =
|
|
6669
|
+
const destinationScript = bitcoinAddressScript(options.destinationAddress, deps.network);
|
|
6670
6670
|
const htlc = parseTransaction(options.htlcTx);
|
|
6671
6671
|
if (!Number.isSafeInteger(options.vout) || options.vout < 0 || options.vout >= htlc.outputsLength) throw new SparkInputError("vout: out of range for the HTLC transaction's outputs");
|
|
6672
6672
|
const output = htlc.getOutput(options.vout);
|
|
@@ -6777,7 +6777,8 @@ function createLightning(context) {
|
|
|
6777
6777
|
receiveStatus: async (request) => lightningReceiveStatus(context.sspClient, request),
|
|
6778
6778
|
sweepHtlcTimeout: async (options) => sweepHtlcTimeout({
|
|
6779
6779
|
signer: context.signer,
|
|
6780
|
-
sspIdentityPublicKey: context.config.ssp.identityPublicKey
|
|
6780
|
+
sspIdentityPublicKey: context.config.ssp.identityPublicKey,
|
|
6781
|
+
network: context.network
|
|
6781
6782
|
}, options)
|
|
6782
6783
|
};
|
|
6783
6784
|
}
|
|
@@ -6946,7 +6947,7 @@ const COMPLETE_RETRY_DELAY_MS = 2e3;
|
|
|
6946
6947
|
/** `address` must decode under this client's network before any signer or SSP work runs. */
|
|
6947
6948
|
function checkWithdrawalAddress(address, network) {
|
|
6948
6949
|
try {
|
|
6949
|
-
|
|
6950
|
+
bitcoinAddressScript(address, network);
|
|
6950
6951
|
} catch (error) {
|
|
6951
6952
|
throw new SparkInputError(`coop exit: invalid withdrawal address for ${network}`, { cause: error });
|
|
6952
6953
|
}
|
|
@@ -6965,7 +6966,7 @@ function prevout0(txBytes, context) {
|
|
|
6965
6966
|
}
|
|
6966
6967
|
/** The sats `rawCoopExitTransaction` pays to `address` — an exit not paying it is an error. */
|
|
6967
6968
|
function payoutSatsForAddress(rawCoopExitTransaction, address, network) {
|
|
6968
|
-
const expectedScript =
|
|
6969
|
+
const expectedScript = bitcoinAddressScript(address, network);
|
|
6969
6970
|
const tx = parseTransaction(rawCoopExitTransaction);
|
|
6970
6971
|
for (let i = 0; i < tx.outputsLength; i++) {
|
|
6971
6972
|
const output = tx.getOutput(i);
|
|
@@ -7723,4 +7724,4 @@ function createMemorySparkStore() {
|
|
|
7723
7724
|
};
|
|
7724
7725
|
}
|
|
7725
7726
|
//#endregion
|
|
7726
|
-
export { EPHEMERAL_ANCHOR_SCRIPT, MIN_STATIC_REFUND_FEE_SATS, SparkCryptoError, SparkError, SparkInputError, SparkRequestError, SparkTokenBroadcastError,
|
|
7727
|
+
export { EPHEMERAL_ANCHOR_SCRIPT, MIN_STATIC_REFUND_FEE_SATS, SparkCryptoError, SparkError, SparkInputError, SparkRequestError, SparkTokenBroadcastError, bitcoinAddressScript, buildCpfpChild, createMemorySparkStore, createSatsInvoice, createSparkClient, createTokensInvoice, decodeBolt11, decodeSparkAddress, decodeTokenIdentifier, encodeSparkAddress, encodeTokenIdentifier, exitTransactions, isExpired, parseSparkInvoice, sparkNetworkConfig, uuidv7, verifySparkAddressSignature };
|
package/dist/server.d.mts
CHANGED
package/dist/signer.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as SparkCrypto } from "./index-DUSx3L3J.mjs";
|
|
2
2
|
import { a as sparkNetworkConfig, n as SparkNetwork } from "./lightning-address-CRULmi9v.mjs";
|
|
3
3
|
import { r as decodeBolt11 } from "./bolt11-DsNTTS_O.mjs";
|
|
4
|
-
import { _ as SparkOperator, a as HtlcTimeoutSignRequest, b as SigningTarget, c as PrepareClaimRequest, d as PreparedLightningReceive, f as PreparedTransfer, g as SparkLeafKey, h as SparkKey, i as FrostSignJob, l as PrepareTransferRequest, m as SigningCommitment, n as EPHEMERAL_ANCHOR_SCRIPT, o as IdentityStatement, p as PreparedTransferLeaf, r as FrostAggregateJob, s as OperatorCommitment, t as
|
|
4
|
+
import { _ as SparkOperator, a as HtlcTimeoutSignRequest, b as SigningTarget, c as PrepareClaimRequest, d as PreparedLightningReceive, f as PreparedTransfer, g as SparkLeafKey, h as SparkKey, i as FrostSignJob, l as PrepareTransferRequest, m as SigningCommitment, n as EPHEMERAL_ANCHOR_SCRIPT, o as IdentityStatement, p as PreparedTransferLeaf, r as FrostAggregateJob, s as OperatorCommitment, t as bitcoinAddressScript, u as PreparedClaim, v as SparkSigner, y as StaticDepositClaimRequest } from "./transactions-p89sj_IQ.mjs";
|
|
5
5
|
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
6
6
|
//#region src/signer/outflow.d.ts
|
|
7
7
|
/** What an authorized signature sends out, derived inside the signer (never caller-supplied). */
|
|
@@ -139,4 +139,4 @@ export declare function createLnurlAuthSigner(options: {
|
|
|
139
139
|
readonly rootKey: Uint8Array;
|
|
140
140
|
}): LnurlAuthSigner;
|
|
141
141
|
//#endregion
|
|
142
|
-
export { type AuthorizeOutflow, EPHEMERAL_ANCHOR_SCRIPT, type FrostAggregateJob, type FrostSignJob, type HtlcTimeoutSignRequest, type IdentityStatement, type LnurlAuthSigner, type OperatorCommitment, type PrepareClaimRequest, type PrepareTransferRequest, type PreparedClaim, type PreparedLightningReceive, type PreparedTransfer, type PreparedTransferLeaf, type SigningCommitment, type SigningTarget, type SparkKey, type SparkLeafKey, type SparkNetwork, type SparkOperator, type SparkOutflow, type SparkSigner, type StaticDepositClaimRequest,
|
|
142
|
+
export { type AuthorizeOutflow, EPHEMERAL_ANCHOR_SCRIPT, type FrostAggregateJob, type FrostSignJob, type HtlcTimeoutSignRequest, type IdentityStatement, type LnurlAuthSigner, type OperatorCommitment, type PrepareClaimRequest, type PrepareTransferRequest, type PreparedClaim, type PreparedLightningReceive, type PreparedTransfer, type PreparedTransferLeaf, type SigningCommitment, type SigningTarget, type SparkKey, type SparkLeafKey, type SparkNetwork, type SparkOperator, type SparkOutflow, type SparkSigner, type StaticDepositClaimRequest, bitcoinAddressScript, decodeBolt11, sparkNetworkConfig };
|
package/dist/signer.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as SparkError, r as SparkInputError, t as SparkCryptoError } from "./errors-5xLkExNL.mjs";
|
|
2
|
-
import { A as EPHEMERAL_ANCHOR_SCRIPT, At as SecretShareSchema, B as parseTransaction, F as checkIfValidSequence, H as taprootScriptSpendSighash, It as SparkInvoiceFieldsSchema, K as PartialTokenTransactionSchema, Mt as SendLeafKeyTweaksSchema, N as p2trScriptFromPublicKey, O as txIdInputBytes, Q as ChallengeSchema, R as getTimelockFromSequence, V as taprootKeySpendSighash, _ as
|
|
2
|
+
import { A as EPHEMERAL_ANCHOR_SCRIPT, At as SecretShareSchema, B as parseTransaction, F as checkIfValidSequence, H as taprootScriptSpendSighash, It as SparkInvoiceFieldsSchema, K as PartialTokenTransactionSchema, Mt as SendLeafKeyTweaksSchema, N as p2trScriptFromPublicKey, O as txIdInputBytes, Q as ChallengeSchema, R as getTimelockFromSequence, V as taprootKeySpendSighash, _ as bitcoinAddressScript, bt as ClaimPackageSchema, c as staticDepositStatementDigest, ct as uint64be, d as LIGHTNING_HTLC_SEQUENCE, et as hashSparkInvoice, ft as requireLength, g as lightningHtlcOutputScript, i as claimPackageDigest, jt as SendLeafKeyTweakSchema, l as transferPackageDigest, m as createSequenceLockScript, mt as sparkNetworkConfig, n as hashPartialTokenTransaction, nt as protoInvoiceToPlain, o as sendLeafSigningDigest, r as authnChallengeDigest, s as sspChallengeDigest, u as watchtowerRecoveryStatementDigest, vt as ClaimLeafKeyTweakSchema, yt as ClaimLeafKeyTweaksSchema, zt as TransferPackageSchema } from "./token-C3vqRH-k.mjs";
|
|
3
3
|
import { t as decodeBolt11 } from "./bolt11-rfxnyLcb.mjs";
|
|
4
4
|
import { i as lightningAddressMessageDigest, r as lightningAddressMessage } from "./lightning-address-CZrb8x4p.mjs";
|
|
5
5
|
import "./crypto.mjs";
|
|
@@ -1424,4 +1424,4 @@ function createLnurlAuthSigner(options) {
|
|
|
1424
1424
|
};
|
|
1425
1425
|
}
|
|
1426
1426
|
//#endregion
|
|
1427
|
-
export { EPHEMERAL_ANCHOR_SCRIPT,
|
|
1427
|
+
export { EPHEMERAL_ANCHOR_SCRIPT, bitcoinAddressScript, createLnurlAuthSigner, createSparkSigner, decodeBolt11, lightningSendHtlcScript, lnurlAuthRootKey, sparkAccountKey, sparkNetworkConfig };
|
|
@@ -1208,15 +1208,16 @@ function prevOutAt(tx, vout) {
|
|
|
1208
1208
|
};
|
|
1209
1209
|
}
|
|
1210
1210
|
/**
|
|
1211
|
-
* Decodes a Bitcoin address to its output script under
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1211
|
+
* Decodes a Bitcoin address to its output script under `network` — bech32 HRP and base58 version
|
|
1212
|
+
* bytes must match. An address that only decodes under the other network is an input error, not a
|
|
1213
|
+
* silent retry: a coop-exit or sweep to a foreign-network address would burn sats.
|
|
1214
1214
|
*/
|
|
1215
|
-
function
|
|
1216
|
-
|
|
1217
|
-
return OutScript.encode(Address(
|
|
1218
|
-
} catch {
|
|
1219
|
-
|
|
1215
|
+
function bitcoinAddressScript(address, network) {
|
|
1216
|
+
try {
|
|
1217
|
+
return OutScript.encode(Address(btcNetwork(network)).decode(address));
|
|
1218
|
+
} catch (error) {
|
|
1219
|
+
throw new SparkInputError(`address: not a ${network} Bitcoin address`, { cause: error });
|
|
1220
|
+
}
|
|
1220
1221
|
}
|
|
1221
1222
|
/**
|
|
1222
1223
|
* Shared builder for node/refund transactions: one input spending `parentTxBytes`'s `vout`, one
|
|
@@ -1255,10 +1256,10 @@ function buildSingleOutputTx(parentTxBytes, vout, outputScript, sequence, applyF
|
|
|
1255
1256
|
* anchor output at `sequence`; the direct variant deducts the fee, has no anchor, and uses
|
|
1256
1257
|
* `directSequence`.
|
|
1257
1258
|
*/
|
|
1258
|
-
function constructNodeTxPair(parentTx, vout, address, sequence, directSequence, feeSats) {
|
|
1259
|
+
function constructNodeTxPair(parentTx, vout, address, network, sequence, directSequence, feeSats) {
|
|
1259
1260
|
checkIfValidSequence(sequence);
|
|
1260
1261
|
checkIfValidSequence(directSequence);
|
|
1261
|
-
const outputScript =
|
|
1262
|
+
const outputScript = bitcoinAddressScript(address, network);
|
|
1262
1263
|
return {
|
|
1263
1264
|
cpfp: buildSingleOutputTx(parentTx, vout, outputScript, sequence, false, feeSats, true),
|
|
1264
1265
|
direct: buildSingleOutputTx(parentTx, vout, outputScript, directSequence, true, feeSats, false)
|
|
@@ -1284,7 +1285,7 @@ function constructRefundTxTrio(cpfpNodeTx, directNodeTx, vout, receivingPublicKe
|
|
|
1284
1285
|
function createNodeTxs(params) {
|
|
1285
1286
|
const address = p2trAddressFromScript(prevOutAt(parseTransaction(params.parentTx), params.vout).script, params.network);
|
|
1286
1287
|
const directSequence = params.directSequence ?? params.sequence + 50;
|
|
1287
|
-
return constructNodeTxPair(params.parentTx, params.vout, address, params.sequence, directSequence, 955);
|
|
1288
|
+
return constructNodeTxPair(params.parentTx, params.vout, address, params.network, params.sequence, directSequence, 955);
|
|
1288
1289
|
}
|
|
1289
1290
|
/** Zero-timelock node transactions over output 0 (root variant of `createNodeTxs`). */
|
|
1290
1291
|
function createZeroTimelockNodeTx(parentTx, network) {
|
|
@@ -2119,4 +2120,4 @@ function hashFinalTokenTransaction(finalTokenTransaction) {
|
|
|
2119
2120
|
return hashProto(FinalTokenTransactionSchema, finalTokenTransaction);
|
|
2120
2121
|
}
|
|
2121
2122
|
//#endregion
|
|
2122
|
-
export { SparkAuthnService as $, EPHEMERAL_ANCHOR_SCRIPT as A, SecretShareSchema as At, parseTransaction as B, TransferReceiverStatus as Bt, createInitialTimelockRefundTxs as C, InitiatePreimageSwapRequest_Reason as Ct, txId as D, RenewNodeTimelockSigningJobSchema as Dt, estimateVbytes as E, Order as Et, checkIfValidSequence as F, SparkAddressSchema as Ft, PartialTokenOutputSchema as G, SignatureScheme as Gt, taprootScriptSpendSighash as H, TransferType as Ht, doesTxnNeedRenewed as I, SparkInvoiceFieldsSchema as It, SparkTokenService as J, PartialTokenTransactionSchema as K, getNextHTLCTransactionSequence as L, SparkService as Lt, computeTaprootKeyNoScript as M, SendLeafKeyTweaksSchema as Mt, p2trScriptFromPublicKey as N, SenderTransferPackageSchema as Nt, txIdInputBytes as O, RenewNodeZeroTimelockSigningJobSchema as Ot, xOnlyPublicKey as P, SigningJobSchema as Pt, ChallengeSchema as Q, getTimelockFromSequence as R, StartTransferRequestSchema as Rt, createInitialTimelockNodeTx as S, HashVariant as St, createZeroTimelockNodeTx as T, InvoiceStatus as Tt, CommitStatus as U, TreeNodeStatus as Ut, taprootKeySpendSighash as V, TransferStatus as Vt, InvoiceAttachmentSchema as W, UserSignedTxSigningJobSchema as Wt, TokenTransactionMetadataSchema as X, TokenOutputStatus as Y, TokenTransactionStatus as Z,
|
|
2123
|
+
export { SparkAuthnService as $, EPHEMERAL_ANCHOR_SCRIPT as A, SecretShareSchema as At, parseTransaction as B, TransferReceiverStatus as Bt, createInitialTimelockRefundTxs as C, InitiatePreimageSwapRequest_Reason as Ct, txId as D, RenewNodeTimelockSigningJobSchema as Dt, estimateVbytes as E, Order as Et, checkIfValidSequence as F, SparkAddressSchema as Ft, PartialTokenOutputSchema as G, SignatureScheme as Gt, taprootScriptSpendSighash as H, TransferType as Ht, doesTxnNeedRenewed as I, SparkInvoiceFieldsSchema as It, SparkTokenService as J, PartialTokenTransactionSchema as K, getNextHTLCTransactionSequence as L, SparkService as Lt, computeTaprootKeyNoScript as M, SendLeafKeyTweaksSchema as Mt, p2trScriptFromPublicKey as N, SenderTransferPackageSchema as Nt, txIdInputBytes as O, RenewNodeZeroTimelockSigningJobSchema as Ot, xOnlyPublicKey as P, SigningJobSchema as Pt, ChallengeSchema as Q, getTimelockFromSequence as R, StartTransferRequestSchema as Rt, createInitialTimelockNodeTx as S, HashVariant as St, createZeroTimelockNodeTx as T, InvoiceStatus as Tt, CommitStatus as U, TreeNodeStatus as Ut, taprootKeySpendSighash as V, TransferStatus as Vt, InvoiceAttachmentSchema as W, UserSignedTxSigningJobSchema as Wt, TokenTransactionMetadataSchema as X, TokenOutputStatus as Y, TokenTransactionStatus as Z, bitcoinAddressScript as _, AdaptorPublicKeyPackageSchema as _t, proofOfPossessionDigest as a, uuidToBytes as at, createDecrementedTimelockNodeTx as b, ClaimPackageSchema as bt, staticDepositStatementDigest as c, uint64be as ct, LIGHTNING_HTLC_SEQUENCE as d, assertU32 as dt, hashSparkInvoice as et, constructHtlcSenderSpend as f, requireLength as ft, lightningHtlcOutputScript as g, sparkNetworkProto as gt, finalizeHtlcSpend as h, sparkNetworkFromProto as ht, claimPackageDigest as i, uuidFromBytes as it, btcNetwork as j, SendLeafKeyTweakSchema as jt, verifyFinalizedTaprootSignature as k, RenewRefundTimelockSigningJobSchema as kt, transferPackageDigest as l, assertCompressedKey as lt, createSequenceLockScript as m, sparkNetworkConfig as mt, hashPartialTokenTransaction as n, protoInvoiceToPlain as nt, sendLeafSigningDigest as o, uuidv7 as ot, createRefundTxsForLightning as p, u64ToSats as pt, SignatureWithIndexSchema as q, authnChallengeDigest as r, validateInvoiceFields as rt, sspChallengeDigest as s, compareBytes as st, hashFinalTokenTransaction as t, encodeInvoiceFields as tt, watchtowerRecoveryStatementDigest as u, assertSats as ut, createConnectorRefundTxs as v, ClaimLeafKeyTweakSchema as vt, createMultiInputRootTx as w, InputSigningDataSchema as wt, createDecrementedTimelockRefundTxs as x, Direction as xt, createCurrentTimelockRefundTxs as y, ClaimLeafKeyTweaksSchema as yt, isZeroTimelock as z, TransferPackageSchema as zt };
|
|
@@ -336,10 +336,10 @@ declare const EPHEMERAL_ANCHOR_SCRIPT: Uint8Array;
|
|
|
336
336
|
//#endregion
|
|
337
337
|
//#region src/core/bitcoin/transactions.d.ts
|
|
338
338
|
/**
|
|
339
|
-
* Decodes a Bitcoin address to its output script under
|
|
340
|
-
*
|
|
341
|
-
*
|
|
339
|
+
* Decodes a Bitcoin address to its output script under `network` — bech32 HRP and base58 version
|
|
340
|
+
* bytes must match. An address that only decodes under the other network is an input error, not a
|
|
341
|
+
* silent retry: a coop-exit or sweep to a foreign-network address would burn sats.
|
|
342
342
|
*/
|
|
343
|
-
declare function
|
|
343
|
+
declare function bitcoinAddressScript(address: string, network: SparkNetwork): Uint8Array;
|
|
344
344
|
//#endregion
|
|
345
|
-
export { SparkOperator as _, HtlcTimeoutSignRequest as a, SigningTarget as b, PrepareClaimRequest as c, PreparedLightningReceive as d, PreparedTransfer as f, SparkLeafKey as g, SparkKey as h, FrostSignJob as i, PrepareTransferRequest as l, SigningCommitment as m, EPHEMERAL_ANCHOR_SCRIPT as n, IdentityStatement as o, PreparedTransferLeaf as p, FrostAggregateJob as r, OperatorCommitment as s,
|
|
345
|
+
export { SparkOperator as _, HtlcTimeoutSignRequest as a, SigningTarget as b, PrepareClaimRequest as c, PreparedLightningReceive as d, PreparedTransfer as f, SparkLeafKey as g, SparkKey as h, FrostSignJob as i, PrepareTransferRequest as l, SigningCommitment as m, EPHEMERAL_ANCHOR_SCRIPT as n, IdentityStatement as o, PreparedTransferLeaf as p, FrostAggregateJob as r, OperatorCommitment as s, bitcoinAddressScript as t, PreparedClaim as u, SparkSigner as v, StaticDepositClaimRequest as y };
|