@buildonspark/spark-sdk 0.3.2 → 0.3.3
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 +6 -0
- package/dist/bare/index.cjs +16 -167
- package/dist/bare/index.d.cts +4 -19
- package/dist/bare/index.d.ts +4 -19
- package/dist/bare/index.js +16 -167
- package/dist/{chunk-4KGN75J4.js → chunk-55XNR6DM.js} +1 -1
- package/dist/{chunk-JDQKNT7G.js → chunk-SXXM52XH.js} +16 -167
- package/dist/debug.cjs +16 -167
- package/dist/debug.d.cts +2 -2
- package/dist/debug.d.ts +2 -2
- package/dist/debug.js +1 -1
- package/dist/index.cjs +16 -167
- 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 +16 -167
- 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-Bt2FNHFR.d.cts → logging-CGeEoKYd.d.cts} +3 -3
- package/dist/{logging-IsaT3wjW.d.ts → logging-DpSsvFVM.d.ts} +3 -3
- package/dist/native/index.cjs +16 -167
- package/dist/native/index.d.cts +4 -19
- package/dist/native/index.d.ts +4 -19
- package/dist/native/index.js +16 -167
- package/dist/{spark-wallet-V03V4Tgm.d.cts → spark-wallet-BVBrWYKL.d.cts} +2 -17
- package/dist/{spark-wallet-KI68-_jO.d.ts → spark-wallet-CFPm6wZs.d.ts} +2 -17
- package/dist/{spark-wallet.node-BtkqW5vn.d.cts → spark-wallet.node-B_00X-1j.d.cts} +1 -1
- package/dist/{spark-wallet.node-Cuvw8Kvq.d.ts → spark-wallet.node-e1gncoIZ.d.ts} +1 -1
- package/dist/tests/test-utils.cjs +5 -4
- 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-fTnCtBpp.d.cts → token-transactions-BZGtwFFM.d.cts} +1 -1
- package/dist/{token-transactions-5XxBewhV.d.ts → token-transactions-BkAqlmY6.d.ts} +1 -1
- package/package.json +1 -1
- package/src/services/transfer.ts +2 -213
- package/src/utils/transaction.ts +8 -8
- package/src/tests/integration/swap.test.ts +0 -780
package/dist/debug.cjs
CHANGED
|
@@ -18483,7 +18483,7 @@ var isWebExtension = (
|
|
|
18483
18483
|
"chrome" in globalThis && globalThis.chrome.runtime?.id
|
|
18484
18484
|
);
|
|
18485
18485
|
var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
|
|
18486
|
-
var packageVersion = true ? "0.3.
|
|
18486
|
+
var packageVersion = true ? "0.3.3" : "unknown";
|
|
18487
18487
|
var baseEnvStr = "unknown";
|
|
18488
18488
|
if (isBun) {
|
|
18489
18489
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -23987,10 +23987,10 @@ var INITIAL_TIMELOCK = 2e3;
|
|
|
23987
23987
|
var TEST_UNILATERAL_TIMELOCK = 100;
|
|
23988
23988
|
var TIME_LOCK_INTERVAL = 100;
|
|
23989
23989
|
var DIRECT_TIMELOCK_OFFSET = 50;
|
|
23990
|
-
var INITIAL_SEQUENCE = INITIAL_TIMELOCK;
|
|
23991
|
-
var INITIAL_DIRECT_SEQUENCE = INITIAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
|
|
23992
|
-
var TEST_UNILATERAL_SEQUENCE = TEST_UNILATERAL_TIMELOCK;
|
|
23993
|
-
var TEST_UNILATERAL_DIRECT_SEQUENCE = TEST_UNILATERAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
|
|
23990
|
+
var INITIAL_SEQUENCE = 1 << 30 | INITIAL_TIMELOCK;
|
|
23991
|
+
var INITIAL_DIRECT_SEQUENCE = 1 << 30 | INITIAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
|
|
23992
|
+
var TEST_UNILATERAL_SEQUENCE = 1 << 30 | TEST_UNILATERAL_TIMELOCK;
|
|
23993
|
+
var TEST_UNILATERAL_DIRECT_SEQUENCE = 1 << 30 | TEST_UNILATERAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
|
|
23994
23994
|
var ESTIMATED_TX_SIZE = 191;
|
|
23995
23995
|
var DEFAULT_SATS_PER_VBYTE = 5;
|
|
23996
23996
|
var DEFAULT_FEE_SATS = ESTIMATED_TX_SIZE * DEFAULT_SATS_PER_VBYTE;
|
|
@@ -24261,8 +24261,8 @@ function getCurrentTimelock(currSequence) {
|
|
|
24261
24261
|
function getTransactionSequence(currSequence) {
|
|
24262
24262
|
const timelock = getCurrentTimelock(currSequence);
|
|
24263
24263
|
return {
|
|
24264
|
-
nextSequence: timelock,
|
|
24265
|
-
nextDirectSequence: timelock + DIRECT_TIMELOCK_OFFSET
|
|
24264
|
+
nextSequence: 1 << 30 | timelock,
|
|
24265
|
+
nextDirectSequence: 1 << 30 | timelock + DIRECT_TIMELOCK_OFFSET
|
|
24266
24266
|
};
|
|
24267
24267
|
}
|
|
24268
24268
|
function checkIfValidSequence(currSequence) {
|
|
@@ -24305,8 +24305,8 @@ function getNextTransactionSequence(currSequence, isNodeTx) {
|
|
|
24305
24305
|
});
|
|
24306
24306
|
}
|
|
24307
24307
|
return {
|
|
24308
|
-
nextSequence: nextTimelock,
|
|
24309
|
-
nextDirectSequence: nextTimelock + DIRECT_TIMELOCK_OFFSET
|
|
24308
|
+
nextSequence: 1 << 30 | nextTimelock,
|
|
24309
|
+
nextDirectSequence: 1 << 30 | nextTimelock + DIRECT_TIMELOCK_OFFSET
|
|
24310
24310
|
};
|
|
24311
24311
|
}
|
|
24312
24312
|
function getEphemeralAnchorOutput() {
|
|
@@ -24369,51 +24369,6 @@ var BaseTransferService = class {
|
|
|
24369
24369
|
this.connectionManager = connectionManager;
|
|
24370
24370
|
this.signingService = signingService;
|
|
24371
24371
|
}
|
|
24372
|
-
async sendTransferTweakKey(transfer, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
|
|
24373
|
-
const keyTweakInputMap = await this.prepareSendTransferKeyTweaks(
|
|
24374
|
-
transfer.id,
|
|
24375
|
-
transfer.receiverIdentityPublicKey,
|
|
24376
|
-
leaves,
|
|
24377
|
-
cpfpRefundSignatureMap,
|
|
24378
|
-
directRefundSignatureMap,
|
|
24379
|
-
directFromCpfpRefundSignatureMap
|
|
24380
|
-
);
|
|
24381
|
-
let updatedTransfer;
|
|
24382
|
-
const coordinatorOperator = this.config.getSigningOperators()[this.config.getCoordinatorIdentifier()];
|
|
24383
|
-
if (!coordinatorOperator) {
|
|
24384
|
-
throw new ValidationError("Coordinator operator not found", {
|
|
24385
|
-
field: "coordinator"
|
|
24386
|
-
});
|
|
24387
|
-
}
|
|
24388
|
-
for (const [identifier, operator] of Object.entries(
|
|
24389
|
-
this.config.getSigningOperators()
|
|
24390
|
-
).filter(([_, op]) => op.address !== this.config.getCoordinatorAddress())) {
|
|
24391
|
-
updatedTransfer = await this.finalizeTransfer(
|
|
24392
|
-
operator,
|
|
24393
|
-
identifier,
|
|
24394
|
-
keyTweakInputMap,
|
|
24395
|
-
transfer,
|
|
24396
|
-
updatedTransfer
|
|
24397
|
-
);
|
|
24398
|
-
}
|
|
24399
|
-
updatedTransfer = await this.finalizeTransfer(
|
|
24400
|
-
coordinatorOperator,
|
|
24401
|
-
this.config.getCoordinatorIdentifier(),
|
|
24402
|
-
keyTweakInputMap,
|
|
24403
|
-
transfer,
|
|
24404
|
-
updatedTransfer
|
|
24405
|
-
);
|
|
24406
|
-
if (!updatedTransfer) {
|
|
24407
|
-
throw new ValidationError(
|
|
24408
|
-
"No transfer response received from any operator",
|
|
24409
|
-
{
|
|
24410
|
-
field: "operators",
|
|
24411
|
-
value: Object.keys(this.config.getSigningOperators()).length
|
|
24412
|
-
}
|
|
24413
|
-
);
|
|
24414
|
-
}
|
|
24415
|
-
return updatedTransfer;
|
|
24416
|
-
}
|
|
24417
24372
|
async deliverTransferPackage(transfer, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
|
|
24418
24373
|
const keyTweakInputMap = await this.prepareSendTransferKeyTweaks(
|
|
24419
24374
|
transfer.id,
|
|
@@ -24555,55 +24510,7 @@ var BaseTransferService = class {
|
|
|
24555
24510
|
transferPackage.userSignature = new Uint8Array(signature);
|
|
24556
24511
|
return transferPackage;
|
|
24557
24512
|
}
|
|
24558
|
-
async
|
|
24559
|
-
const sparkClient = await this.connectionManager.createSparkClient(
|
|
24560
|
-
operator.address
|
|
24561
|
-
);
|
|
24562
|
-
const leavesToSend = keyTweakInputMap.get(identifier);
|
|
24563
|
-
if (!leavesToSend) {
|
|
24564
|
-
throw new ValidationError("No leaves to send for operator", {
|
|
24565
|
-
field: "operator",
|
|
24566
|
-
value: identifier
|
|
24567
|
-
});
|
|
24568
|
-
}
|
|
24569
|
-
let transferResp;
|
|
24570
|
-
try {
|
|
24571
|
-
transferResp = await sparkClient.finalize_transfer({
|
|
24572
|
-
transferId: transfer.id,
|
|
24573
|
-
ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
24574
|
-
leavesToSend
|
|
24575
|
-
});
|
|
24576
|
-
} catch (error) {
|
|
24577
|
-
throw new NetworkError(
|
|
24578
|
-
"Failed to finalize transfer",
|
|
24579
|
-
{
|
|
24580
|
-
method: "POST"
|
|
24581
|
-
},
|
|
24582
|
-
error
|
|
24583
|
-
);
|
|
24584
|
-
}
|
|
24585
|
-
if (!updatedTransfer) {
|
|
24586
|
-
updatedTransfer = transferResp.transfer;
|
|
24587
|
-
} else {
|
|
24588
|
-
if (!transferResp.transfer) {
|
|
24589
|
-
throw new ValidationError("No transfer response from operator", {
|
|
24590
|
-
field: "transfer",
|
|
24591
|
-
value: transfer.id
|
|
24592
|
-
});
|
|
24593
|
-
}
|
|
24594
|
-
if (!this.compareTransfers(updatedTransfer, transferResp.transfer)) {
|
|
24595
|
-
throw new ValidationError(
|
|
24596
|
-
"Inconsistent transfer response from operators",
|
|
24597
|
-
{
|
|
24598
|
-
field: "transfer",
|
|
24599
|
-
value: transfer.id
|
|
24600
|
-
}
|
|
24601
|
-
);
|
|
24602
|
-
}
|
|
24603
|
-
}
|
|
24604
|
-
return updatedTransfer;
|
|
24605
|
-
}
|
|
24606
|
-
async signRefunds(leafDataMap, operatorSigningResults, cpfpAdaptorPubKey, directAdaptorPubKey, directFromCpfpAdaptorPubKey) {
|
|
24513
|
+
async signRefunds(leafDataMap, operatorSigningResults) {
|
|
24607
24514
|
const nodeSignatures = [];
|
|
24608
24515
|
for (const operatorSigningResult of operatorSigningResults) {
|
|
24609
24516
|
const leafData = leafDataMap.get(operatorSigningResult.leafId);
|
|
@@ -24632,7 +24539,6 @@ var BaseTransferService = class {
|
|
|
24632
24539
|
keyDerivation: leafData.keyDerivation,
|
|
24633
24540
|
selfCommitment: leafData.signingNonceCommitment,
|
|
24634
24541
|
statechainCommitments: operatorSigningResult.refundTxSigningResult?.signingNonceCommitments,
|
|
24635
|
-
adaptorPubKey: cpfpAdaptorPubKey,
|
|
24636
24542
|
verifyingKey: operatorSigningResult.verifyingKey
|
|
24637
24543
|
});
|
|
24638
24544
|
const cpfpRefundAggregate = await this.config.signer.aggregateFrost({
|
|
@@ -24643,8 +24549,7 @@ var BaseTransferService = class {
|
|
|
24643
24549
|
statechainCommitments: operatorSigningResult.refundTxSigningResult?.signingNonceCommitments,
|
|
24644
24550
|
selfCommitment: leafData.signingNonceCommitment,
|
|
24645
24551
|
publicKey,
|
|
24646
|
-
selfSignature: cpfpUserSignature
|
|
24647
|
-
adaptorPubKey: cpfpAdaptorPubKey
|
|
24552
|
+
selfSignature: cpfpUserSignature
|
|
24648
24553
|
});
|
|
24649
24554
|
let directRefundAggregate;
|
|
24650
24555
|
let directFromCpfpRefundAggregate;
|
|
@@ -24662,7 +24567,6 @@ var BaseTransferService = class {
|
|
|
24662
24567
|
keyDerivation: leafData.keyDerivation,
|
|
24663
24568
|
selfCommitment: leafData.directSigningNonceCommitment,
|
|
24664
24569
|
statechainCommitments: operatorSigningResult.directRefundTxSigningResult?.signingNonceCommitments,
|
|
24665
|
-
adaptorPubKey: directAdaptorPubKey,
|
|
24666
24570
|
verifyingKey: operatorSigningResult.verifyingKey
|
|
24667
24571
|
});
|
|
24668
24572
|
directRefundAggregate = await this.config.signer.aggregateFrost({
|
|
@@ -24673,8 +24577,7 @@ var BaseTransferService = class {
|
|
|
24673
24577
|
statechainCommitments: operatorSigningResult.directRefundTxSigningResult?.signingNonceCommitments,
|
|
24674
24578
|
selfCommitment: leafData.directSigningNonceCommitment,
|
|
24675
24579
|
publicKey,
|
|
24676
|
-
selfSignature: directUserSignature
|
|
24677
|
-
adaptorPubKey: directAdaptorPubKey
|
|
24580
|
+
selfSignature: directUserSignature
|
|
24678
24581
|
});
|
|
24679
24582
|
}
|
|
24680
24583
|
if (leafData.directFromCpfpRefundTx) {
|
|
@@ -24689,7 +24592,6 @@ var BaseTransferService = class {
|
|
|
24689
24592
|
keyDerivation: leafData.keyDerivation,
|
|
24690
24593
|
selfCommitment: leafData.directFromCpfpRefundSigningNonceCommitment,
|
|
24691
24594
|
statechainCommitments: operatorSigningResult.directFromCpfpRefundTxSigningResult?.signingNonceCommitments,
|
|
24692
|
-
adaptorPubKey: directFromCpfpAdaptorPubKey,
|
|
24693
24595
|
verifyingKey: operatorSigningResult.verifyingKey
|
|
24694
24596
|
});
|
|
24695
24597
|
directFromCpfpRefundAggregate = await this.config.signer.aggregateFrost({
|
|
@@ -24700,8 +24602,7 @@ var BaseTransferService = class {
|
|
|
24700
24602
|
statechainCommitments: operatorSigningResult.directFromCpfpRefundTxSigningResult?.signingNonceCommitments,
|
|
24701
24603
|
selfCommitment: leafData.directFromCpfpRefundSigningNonceCommitment,
|
|
24702
24604
|
publicKey,
|
|
24703
|
-
selfSignature: directFromCpfpUserSignature
|
|
24704
|
-
adaptorPubKey: directFromCpfpAdaptorPubKey
|
|
24605
|
+
selfSignature: directFromCpfpUserSignature
|
|
24705
24606
|
});
|
|
24706
24607
|
}
|
|
24707
24608
|
}
|
|
@@ -24817,30 +24718,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
24817
24718
|
constructor(config, connectionManager, signingService) {
|
|
24818
24719
|
super(config, connectionManager, signingService);
|
|
24819
24720
|
}
|
|
24820
|
-
/**
|
|
24821
|
-
* @deprecated Use sendTransferWithKeyTweaks instead
|
|
24822
|
-
* Deprecated in v0.1.32
|
|
24823
|
-
*/
|
|
24824
|
-
async sendTransfer(leaves, receiverIdentityPubkey) {
|
|
24825
|
-
const {
|
|
24826
|
-
transfer,
|
|
24827
|
-
signatureMap,
|
|
24828
|
-
directSignatureMap,
|
|
24829
|
-
directFromCpfpSignatureMap
|
|
24830
|
-
} = await this.sendTransferSignRefund(
|
|
24831
|
-
leaves,
|
|
24832
|
-
receiverIdentityPubkey,
|
|
24833
|
-
new Date(Date.now() + DEFAULT_EXPIRY_TIME)
|
|
24834
|
-
);
|
|
24835
|
-
const transferWithTweakedKeys = await this.sendTransferTweakKey(
|
|
24836
|
-
transfer,
|
|
24837
|
-
leaves,
|
|
24838
|
-
signatureMap,
|
|
24839
|
-
directSignatureMap,
|
|
24840
|
-
directFromCpfpSignatureMap
|
|
24841
|
-
);
|
|
24842
|
-
return transferWithTweakedKeys;
|
|
24843
|
-
}
|
|
24844
24721
|
async claimTransfer(transfer, leaves) {
|
|
24845
24722
|
let proofMap;
|
|
24846
24723
|
if (transfer.status === 2 /* TRANSFER_STATUS_SENDER_KEY_TWEAKED */) {
|
|
@@ -24984,18 +24861,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
24984
24861
|
leafDataMap
|
|
24985
24862
|
};
|
|
24986
24863
|
}
|
|
24987
|
-
async
|
|
24988
|
-
return this.sendTransferSignRefundInternal(
|
|
24989
|
-
leaves,
|
|
24990
|
-
receiverIdentityPubkey,
|
|
24991
|
-
expiryTime,
|
|
24992
|
-
true,
|
|
24993
|
-
cpfpAdaptorPubKey,
|
|
24994
|
-
directAdaptorPubKey,
|
|
24995
|
-
directFromCpfpAdaptorPubKey
|
|
24996
|
-
);
|
|
24997
|
-
}
|
|
24998
|
-
async sendTransferSignRefundInternal(leaves, receiverIdentityPubkey, expiryTime, forSwap, cpfpAdaptorPubKey, directAdaptorPubKey, directFromCpfpAdaptorPubKey) {
|
|
24864
|
+
async sendTransferSignRefundInternal(leaves, receiverIdentityPubkey, expiryTime, forSwap) {
|
|
24999
24865
|
const transferId = (0, import_uuidv7.uuidv7)();
|
|
25000
24866
|
const leafDataMap = /* @__PURE__ */ new Map();
|
|
25001
24867
|
for (const leaf of leaves) {
|
|
@@ -25030,21 +24896,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
25030
24896
|
);
|
|
25031
24897
|
let response;
|
|
25032
24898
|
try {
|
|
25033
|
-
if (
|
|
25034
|
-
response = await sparkClient.counter_leaf_swap_v2({
|
|
25035
|
-
transfer: {
|
|
25036
|
-
transferId,
|
|
25037
|
-
leavesToSend: signingJobs,
|
|
25038
|
-
ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
25039
|
-
receiverIdentityPublicKey: receiverIdentityPubkey,
|
|
25040
|
-
expiryTime
|
|
25041
|
-
},
|
|
25042
|
-
swapId: (0, import_uuidv7.uuidv7)(),
|
|
25043
|
-
adaptorPublicKey: cpfpAdaptorPubKey,
|
|
25044
|
-
directAdaptorPublicKey: directAdaptorPubKey,
|
|
25045
|
-
directFromCpfpAdaptorPublicKey: directFromCpfpAdaptorPubKey
|
|
25046
|
-
});
|
|
25047
|
-
} else if (forSwap) {
|
|
24899
|
+
if (forSwap) {
|
|
25048
24900
|
response = await sparkClient.start_leaf_swap_v2({
|
|
25049
24901
|
transferId,
|
|
25050
24902
|
leavesToSend: signingJobs,
|
|
@@ -25069,10 +24921,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
25069
24921
|
}
|
|
25070
24922
|
const signatures = await this.signRefunds(
|
|
25071
24923
|
leafDataMap,
|
|
25072
|
-
response.signingResults
|
|
25073
|
-
cpfpAdaptorPubKey,
|
|
25074
|
-
directAdaptorPubKey,
|
|
25075
|
-
directFromCpfpAdaptorPubKey
|
|
24924
|
+
response.signingResults
|
|
25076
24925
|
);
|
|
25077
24926
|
const cpfpSignatureMap = /* @__PURE__ */ new Map();
|
|
25078
24927
|
const directSignatureMap = /* @__PURE__ */ new Map();
|
package/dist/debug.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as Bech32mTokenIdentifier, s as Bech32mTokenIdentifierData, D as DecodedSparkAddressData, L as LRC_WALLET_NETWORK, N as Network, n as NetworkToProto, m as NetworkType, c as SparkAddressData, S as SparkAddressFormat, k as bech32mDecode, w as decodeBech32mTokenIdentifier, f as decodeSparkAddress, u as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, o as getNetwork, q as getNetworkFromAddress, x as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, r as getNetworkFromString, l as isSafeForNumber, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature, Z 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, s as Bech32mTokenIdentifierData, D as DecodedSparkAddressData, L as LRC_WALLET_NETWORK, N as Network, n as NetworkToProto, m as NetworkType, c as SparkAddressData, S as SparkAddressFormat, k as bech32mDecode, w as decodeBech32mTokenIdentifier, f as decodeSparkAddress, u as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, o as getNetwork, q as getNetworkFromAddress, x as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, r as getNetworkFromString, l as isSafeForNumber, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature, Z as SparkWallet, b as ConfigOptions } from './spark-wallet-BVBrWYKL.cjs';
|
|
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-CGeEoKYd.cjs';
|
|
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-DUFejFfn.cjs';
|
|
4
4
|
import './spark-CLz4-Ln8.cjs';
|
|
5
5
|
import '@bufbuild/protobuf/wire';
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as Bech32mTokenIdentifier, s as Bech32mTokenIdentifierData, D as DecodedSparkAddressData, L as LRC_WALLET_NETWORK, N as Network, n as NetworkToProto, m as NetworkType, c as SparkAddressData, S as SparkAddressFormat, k as bech32mDecode, w as decodeBech32mTokenIdentifier, f as decodeSparkAddress, u as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, o as getNetwork, q as getNetworkFromAddress, x as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, r as getNetworkFromString, l as isSafeForNumber, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature, Z 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, s as Bech32mTokenIdentifierData, D as DecodedSparkAddressData, L as LRC_WALLET_NETWORK, N as Network, n as NetworkToProto, m as NetworkType, c as SparkAddressData, S as SparkAddressFormat, k as bech32mDecode, w as decodeBech32mTokenIdentifier, f as decodeSparkAddress, u as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, o as getNetwork, q as getNetworkFromAddress, x as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, r as getNetworkFromString, l as isSafeForNumber, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature, Z as SparkWallet, b as ConfigOptions } from './spark-wallet-CFPm6wZs.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-DpSsvFVM.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-DrjQwET9.js';
|
|
4
4
|
import './spark-CLz4-Ln8.js';
|
|
5
5
|
import '@bufbuild/protobuf/wire';
|
package/dist/debug.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -19257,10 +19257,10 @@ var INITIAL_TIMELOCK = 2e3;
|
|
|
19257
19257
|
var TEST_UNILATERAL_TIMELOCK = 100;
|
|
19258
19258
|
var TIME_LOCK_INTERVAL = 100;
|
|
19259
19259
|
var DIRECT_TIMELOCK_OFFSET = 50;
|
|
19260
|
-
var INITIAL_SEQUENCE = INITIAL_TIMELOCK;
|
|
19261
|
-
var INITIAL_DIRECT_SEQUENCE = INITIAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
|
|
19262
|
-
var TEST_UNILATERAL_SEQUENCE = TEST_UNILATERAL_TIMELOCK;
|
|
19263
|
-
var TEST_UNILATERAL_DIRECT_SEQUENCE = TEST_UNILATERAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
|
|
19260
|
+
var INITIAL_SEQUENCE = 1 << 30 | INITIAL_TIMELOCK;
|
|
19261
|
+
var INITIAL_DIRECT_SEQUENCE = 1 << 30 | INITIAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
|
|
19262
|
+
var TEST_UNILATERAL_SEQUENCE = 1 << 30 | TEST_UNILATERAL_TIMELOCK;
|
|
19263
|
+
var TEST_UNILATERAL_DIRECT_SEQUENCE = 1 << 30 | TEST_UNILATERAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
|
|
19264
19264
|
var ESTIMATED_TX_SIZE = 191;
|
|
19265
19265
|
var DEFAULT_SATS_PER_VBYTE = 5;
|
|
19266
19266
|
var DEFAULT_FEE_SATS = ESTIMATED_TX_SIZE * DEFAULT_SATS_PER_VBYTE;
|
|
@@ -19531,8 +19531,8 @@ function getCurrentTimelock(currSequence) {
|
|
|
19531
19531
|
function getTransactionSequence(currSequence) {
|
|
19532
19532
|
const timelock = getCurrentTimelock(currSequence);
|
|
19533
19533
|
return {
|
|
19534
|
-
nextSequence: timelock,
|
|
19535
|
-
nextDirectSequence: timelock + DIRECT_TIMELOCK_OFFSET
|
|
19534
|
+
nextSequence: 1 << 30 | timelock,
|
|
19535
|
+
nextDirectSequence: 1 << 30 | timelock + DIRECT_TIMELOCK_OFFSET
|
|
19536
19536
|
};
|
|
19537
19537
|
}
|
|
19538
19538
|
function checkIfValidSequence(currSequence) {
|
|
@@ -19575,8 +19575,8 @@ function getNextTransactionSequence(currSequence, isNodeTx) {
|
|
|
19575
19575
|
});
|
|
19576
19576
|
}
|
|
19577
19577
|
return {
|
|
19578
|
-
nextSequence: nextTimelock,
|
|
19579
|
-
nextDirectSequence: nextTimelock + DIRECT_TIMELOCK_OFFSET
|
|
19578
|
+
nextSequence: 1 << 30 | nextTimelock,
|
|
19579
|
+
nextDirectSequence: 1 << 30 | nextTimelock + DIRECT_TIMELOCK_OFFSET
|
|
19580
19580
|
};
|
|
19581
19581
|
}
|
|
19582
19582
|
function getEphemeralAnchorOutput() {
|
|
@@ -20112,7 +20112,7 @@ var isWebExtension = (
|
|
|
20112
20112
|
"chrome" in globalThis && globalThis.chrome.runtime?.id
|
|
20113
20113
|
);
|
|
20114
20114
|
var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
|
|
20115
|
-
var packageVersion = true ? "0.3.
|
|
20115
|
+
var packageVersion = true ? "0.3.3" : "unknown";
|
|
20116
20116
|
var baseEnvStr = "unknown";
|
|
20117
20117
|
if (isBun) {
|
|
20118
20118
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -26066,51 +26066,6 @@ var BaseTransferService = class {
|
|
|
26066
26066
|
this.connectionManager = connectionManager;
|
|
26067
26067
|
this.signingService = signingService;
|
|
26068
26068
|
}
|
|
26069
|
-
async sendTransferTweakKey(transfer, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
|
|
26070
|
-
const keyTweakInputMap = await this.prepareSendTransferKeyTweaks(
|
|
26071
|
-
transfer.id,
|
|
26072
|
-
transfer.receiverIdentityPublicKey,
|
|
26073
|
-
leaves,
|
|
26074
|
-
cpfpRefundSignatureMap,
|
|
26075
|
-
directRefundSignatureMap,
|
|
26076
|
-
directFromCpfpRefundSignatureMap
|
|
26077
|
-
);
|
|
26078
|
-
let updatedTransfer;
|
|
26079
|
-
const coordinatorOperator = this.config.getSigningOperators()[this.config.getCoordinatorIdentifier()];
|
|
26080
|
-
if (!coordinatorOperator) {
|
|
26081
|
-
throw new ValidationError("Coordinator operator not found", {
|
|
26082
|
-
field: "coordinator"
|
|
26083
|
-
});
|
|
26084
|
-
}
|
|
26085
|
-
for (const [identifier, operator] of Object.entries(
|
|
26086
|
-
this.config.getSigningOperators()
|
|
26087
|
-
).filter(([_, op]) => op.address !== this.config.getCoordinatorAddress())) {
|
|
26088
|
-
updatedTransfer = await this.finalizeTransfer(
|
|
26089
|
-
operator,
|
|
26090
|
-
identifier,
|
|
26091
|
-
keyTweakInputMap,
|
|
26092
|
-
transfer,
|
|
26093
|
-
updatedTransfer
|
|
26094
|
-
);
|
|
26095
|
-
}
|
|
26096
|
-
updatedTransfer = await this.finalizeTransfer(
|
|
26097
|
-
coordinatorOperator,
|
|
26098
|
-
this.config.getCoordinatorIdentifier(),
|
|
26099
|
-
keyTweakInputMap,
|
|
26100
|
-
transfer,
|
|
26101
|
-
updatedTransfer
|
|
26102
|
-
);
|
|
26103
|
-
if (!updatedTransfer) {
|
|
26104
|
-
throw new ValidationError(
|
|
26105
|
-
"No transfer response received from any operator",
|
|
26106
|
-
{
|
|
26107
|
-
field: "operators",
|
|
26108
|
-
value: Object.keys(this.config.getSigningOperators()).length
|
|
26109
|
-
}
|
|
26110
|
-
);
|
|
26111
|
-
}
|
|
26112
|
-
return updatedTransfer;
|
|
26113
|
-
}
|
|
26114
26069
|
async deliverTransferPackage(transfer, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
|
|
26115
26070
|
const keyTweakInputMap = await this.prepareSendTransferKeyTweaks(
|
|
26116
26071
|
transfer.id,
|
|
@@ -26252,55 +26207,7 @@ var BaseTransferService = class {
|
|
|
26252
26207
|
transferPackage.userSignature = new Uint8Array(signature);
|
|
26253
26208
|
return transferPackage;
|
|
26254
26209
|
}
|
|
26255
|
-
async
|
|
26256
|
-
const sparkClient = await this.connectionManager.createSparkClient(
|
|
26257
|
-
operator.address
|
|
26258
|
-
);
|
|
26259
|
-
const leavesToSend = keyTweakInputMap.get(identifier);
|
|
26260
|
-
if (!leavesToSend) {
|
|
26261
|
-
throw new ValidationError("No leaves to send for operator", {
|
|
26262
|
-
field: "operator",
|
|
26263
|
-
value: identifier
|
|
26264
|
-
});
|
|
26265
|
-
}
|
|
26266
|
-
let transferResp;
|
|
26267
|
-
try {
|
|
26268
|
-
transferResp = await sparkClient.finalize_transfer({
|
|
26269
|
-
transferId: transfer.id,
|
|
26270
|
-
ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
26271
|
-
leavesToSend
|
|
26272
|
-
});
|
|
26273
|
-
} catch (error) {
|
|
26274
|
-
throw new NetworkError(
|
|
26275
|
-
"Failed to finalize transfer",
|
|
26276
|
-
{
|
|
26277
|
-
method: "POST"
|
|
26278
|
-
},
|
|
26279
|
-
error
|
|
26280
|
-
);
|
|
26281
|
-
}
|
|
26282
|
-
if (!updatedTransfer) {
|
|
26283
|
-
updatedTransfer = transferResp.transfer;
|
|
26284
|
-
} else {
|
|
26285
|
-
if (!transferResp.transfer) {
|
|
26286
|
-
throw new ValidationError("No transfer response from operator", {
|
|
26287
|
-
field: "transfer",
|
|
26288
|
-
value: transfer.id
|
|
26289
|
-
});
|
|
26290
|
-
}
|
|
26291
|
-
if (!this.compareTransfers(updatedTransfer, transferResp.transfer)) {
|
|
26292
|
-
throw new ValidationError(
|
|
26293
|
-
"Inconsistent transfer response from operators",
|
|
26294
|
-
{
|
|
26295
|
-
field: "transfer",
|
|
26296
|
-
value: transfer.id
|
|
26297
|
-
}
|
|
26298
|
-
);
|
|
26299
|
-
}
|
|
26300
|
-
}
|
|
26301
|
-
return updatedTransfer;
|
|
26302
|
-
}
|
|
26303
|
-
async signRefunds(leafDataMap, operatorSigningResults, cpfpAdaptorPubKey, directAdaptorPubKey, directFromCpfpAdaptorPubKey) {
|
|
26210
|
+
async signRefunds(leafDataMap, operatorSigningResults) {
|
|
26304
26211
|
const nodeSignatures = [];
|
|
26305
26212
|
for (const operatorSigningResult of operatorSigningResults) {
|
|
26306
26213
|
const leafData = leafDataMap.get(operatorSigningResult.leafId);
|
|
@@ -26329,7 +26236,6 @@ var BaseTransferService = class {
|
|
|
26329
26236
|
keyDerivation: leafData.keyDerivation,
|
|
26330
26237
|
selfCommitment: leafData.signingNonceCommitment,
|
|
26331
26238
|
statechainCommitments: operatorSigningResult.refundTxSigningResult?.signingNonceCommitments,
|
|
26332
|
-
adaptorPubKey: cpfpAdaptorPubKey,
|
|
26333
26239
|
verifyingKey: operatorSigningResult.verifyingKey
|
|
26334
26240
|
});
|
|
26335
26241
|
const cpfpRefundAggregate = await this.config.signer.aggregateFrost({
|
|
@@ -26340,8 +26246,7 @@ var BaseTransferService = class {
|
|
|
26340
26246
|
statechainCommitments: operatorSigningResult.refundTxSigningResult?.signingNonceCommitments,
|
|
26341
26247
|
selfCommitment: leafData.signingNonceCommitment,
|
|
26342
26248
|
publicKey,
|
|
26343
|
-
selfSignature: cpfpUserSignature
|
|
26344
|
-
adaptorPubKey: cpfpAdaptorPubKey
|
|
26249
|
+
selfSignature: cpfpUserSignature
|
|
26345
26250
|
});
|
|
26346
26251
|
let directRefundAggregate;
|
|
26347
26252
|
let directFromCpfpRefundAggregate;
|
|
@@ -26359,7 +26264,6 @@ var BaseTransferService = class {
|
|
|
26359
26264
|
keyDerivation: leafData.keyDerivation,
|
|
26360
26265
|
selfCommitment: leafData.directSigningNonceCommitment,
|
|
26361
26266
|
statechainCommitments: operatorSigningResult.directRefundTxSigningResult?.signingNonceCommitments,
|
|
26362
|
-
adaptorPubKey: directAdaptorPubKey,
|
|
26363
26267
|
verifyingKey: operatorSigningResult.verifyingKey
|
|
26364
26268
|
});
|
|
26365
26269
|
directRefundAggregate = await this.config.signer.aggregateFrost({
|
|
@@ -26370,8 +26274,7 @@ var BaseTransferService = class {
|
|
|
26370
26274
|
statechainCommitments: operatorSigningResult.directRefundTxSigningResult?.signingNonceCommitments,
|
|
26371
26275
|
selfCommitment: leafData.directSigningNonceCommitment,
|
|
26372
26276
|
publicKey,
|
|
26373
|
-
selfSignature: directUserSignature
|
|
26374
|
-
adaptorPubKey: directAdaptorPubKey
|
|
26277
|
+
selfSignature: directUserSignature
|
|
26375
26278
|
});
|
|
26376
26279
|
}
|
|
26377
26280
|
if (leafData.directFromCpfpRefundTx) {
|
|
@@ -26386,7 +26289,6 @@ var BaseTransferService = class {
|
|
|
26386
26289
|
keyDerivation: leafData.keyDerivation,
|
|
26387
26290
|
selfCommitment: leafData.directFromCpfpRefundSigningNonceCommitment,
|
|
26388
26291
|
statechainCommitments: operatorSigningResult.directFromCpfpRefundTxSigningResult?.signingNonceCommitments,
|
|
26389
|
-
adaptorPubKey: directFromCpfpAdaptorPubKey,
|
|
26390
26292
|
verifyingKey: operatorSigningResult.verifyingKey
|
|
26391
26293
|
});
|
|
26392
26294
|
directFromCpfpRefundAggregate = await this.config.signer.aggregateFrost({
|
|
@@ -26397,8 +26299,7 @@ var BaseTransferService = class {
|
|
|
26397
26299
|
statechainCommitments: operatorSigningResult.directFromCpfpRefundTxSigningResult?.signingNonceCommitments,
|
|
26398
26300
|
selfCommitment: leafData.directFromCpfpRefundSigningNonceCommitment,
|
|
26399
26301
|
publicKey,
|
|
26400
|
-
selfSignature: directFromCpfpUserSignature
|
|
26401
|
-
adaptorPubKey: directFromCpfpAdaptorPubKey
|
|
26302
|
+
selfSignature: directFromCpfpUserSignature
|
|
26402
26303
|
});
|
|
26403
26304
|
}
|
|
26404
26305
|
}
|
|
@@ -26514,30 +26415,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
26514
26415
|
constructor(config, connectionManager, signingService) {
|
|
26515
26416
|
super(config, connectionManager, signingService);
|
|
26516
26417
|
}
|
|
26517
|
-
/**
|
|
26518
|
-
* @deprecated Use sendTransferWithKeyTweaks instead
|
|
26519
|
-
* Deprecated in v0.1.32
|
|
26520
|
-
*/
|
|
26521
|
-
async sendTransfer(leaves, receiverIdentityPubkey) {
|
|
26522
|
-
const {
|
|
26523
|
-
transfer,
|
|
26524
|
-
signatureMap,
|
|
26525
|
-
directSignatureMap,
|
|
26526
|
-
directFromCpfpSignatureMap
|
|
26527
|
-
} = await this.sendTransferSignRefund(
|
|
26528
|
-
leaves,
|
|
26529
|
-
receiverIdentityPubkey,
|
|
26530
|
-
new Date(Date.now() + DEFAULT_EXPIRY_TIME)
|
|
26531
|
-
);
|
|
26532
|
-
const transferWithTweakedKeys = await this.sendTransferTweakKey(
|
|
26533
|
-
transfer,
|
|
26534
|
-
leaves,
|
|
26535
|
-
signatureMap,
|
|
26536
|
-
directSignatureMap,
|
|
26537
|
-
directFromCpfpSignatureMap
|
|
26538
|
-
);
|
|
26539
|
-
return transferWithTweakedKeys;
|
|
26540
|
-
}
|
|
26541
26418
|
async claimTransfer(transfer, leaves) {
|
|
26542
26419
|
let proofMap;
|
|
26543
26420
|
if (transfer.status === 2 /* TRANSFER_STATUS_SENDER_KEY_TWEAKED */) {
|
|
@@ -26681,18 +26558,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26681
26558
|
leafDataMap
|
|
26682
26559
|
};
|
|
26683
26560
|
}
|
|
26684
|
-
async
|
|
26685
|
-
return this.sendTransferSignRefundInternal(
|
|
26686
|
-
leaves,
|
|
26687
|
-
receiverIdentityPubkey,
|
|
26688
|
-
expiryTime,
|
|
26689
|
-
true,
|
|
26690
|
-
cpfpAdaptorPubKey,
|
|
26691
|
-
directAdaptorPubKey,
|
|
26692
|
-
directFromCpfpAdaptorPubKey
|
|
26693
|
-
);
|
|
26694
|
-
}
|
|
26695
|
-
async sendTransferSignRefundInternal(leaves, receiverIdentityPubkey, expiryTime, forSwap, cpfpAdaptorPubKey, directAdaptorPubKey, directFromCpfpAdaptorPubKey) {
|
|
26561
|
+
async sendTransferSignRefundInternal(leaves, receiverIdentityPubkey, expiryTime, forSwap) {
|
|
26696
26562
|
const transferId = (0, import_uuidv72.uuidv7)();
|
|
26697
26563
|
const leafDataMap = /* @__PURE__ */ new Map();
|
|
26698
26564
|
for (const leaf of leaves) {
|
|
@@ -26727,21 +26593,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26727
26593
|
);
|
|
26728
26594
|
let response;
|
|
26729
26595
|
try {
|
|
26730
|
-
if (
|
|
26731
|
-
response = await sparkClient.counter_leaf_swap_v2({
|
|
26732
|
-
transfer: {
|
|
26733
|
-
transferId,
|
|
26734
|
-
leavesToSend: signingJobs,
|
|
26735
|
-
ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
26736
|
-
receiverIdentityPublicKey: receiverIdentityPubkey,
|
|
26737
|
-
expiryTime
|
|
26738
|
-
},
|
|
26739
|
-
swapId: (0, import_uuidv72.uuidv7)(),
|
|
26740
|
-
adaptorPublicKey: cpfpAdaptorPubKey,
|
|
26741
|
-
directAdaptorPublicKey: directAdaptorPubKey,
|
|
26742
|
-
directFromCpfpAdaptorPublicKey: directFromCpfpAdaptorPubKey
|
|
26743
|
-
});
|
|
26744
|
-
} else if (forSwap) {
|
|
26596
|
+
if (forSwap) {
|
|
26745
26597
|
response = await sparkClient.start_leaf_swap_v2({
|
|
26746
26598
|
transferId,
|
|
26747
26599
|
leavesToSend: signingJobs,
|
|
@@ -26766,10 +26618,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26766
26618
|
}
|
|
26767
26619
|
const signatures = await this.signRefunds(
|
|
26768
26620
|
leafDataMap,
|
|
26769
|
-
response.signingResults
|
|
26770
|
-
cpfpAdaptorPubKey,
|
|
26771
|
-
directAdaptorPubKey,
|
|
26772
|
-
directFromCpfpAdaptorPubKey
|
|
26621
|
+
response.signingResults
|
|
26773
26622
|
);
|
|
26774
26623
|
const cpfpSignatureMap = /* @__PURE__ */ new Map();
|
|
26775
26624
|
const directSignatureMap = /* @__PURE__ */ new Map();
|
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 { Z as SparkWallet, Q as SparkWalletProps } from './spark-wallet-
|
|
3
|
-
export { B as Bech32mTokenIdentifier, s as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, y as CreateLightningInvoiceParams, D as DecodedSparkAddressData, H as DepositParams, F as FulfillSparkInvoiceResponse, G as GroupSparkInvoicesResult, O as InitWalletResponse, I as InvalidInvoice, L as LRC_WALLET_NETWORK, N as Network, n as NetworkToProto, m as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, V as SparkWalletEvent, X as SparkWalletEventType, Y as SparkWalletEvents, J as TokenBalanceMap, E as TokenInvoice, M as TokenMetadataMap, K as TokenOutputsMap, T as TransferParams, A as TransferWithInvoiceOutcome, z as TransferWithInvoiceParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, w as decodeBech32mTokenIdentifier, f as decodeSparkAddress, u as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, o as getNetwork, q as getNetworkFromAddress, x as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, r as getNetworkFromString, l as isSafeForNumber, 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-BZGtwFFM.cjs';
|
|
2
|
+
import { Z as SparkWallet, Q as SparkWalletProps } from './spark-wallet-BVBrWYKL.cjs';
|
|
3
|
+
export { B as Bech32mTokenIdentifier, s as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, y as CreateLightningInvoiceParams, D as DecodedSparkAddressData, H as DepositParams, F as FulfillSparkInvoiceResponse, G as GroupSparkInvoicesResult, O as InitWalletResponse, I as InvalidInvoice, L as LRC_WALLET_NETWORK, N as Network, n as NetworkToProto, m as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, V as SparkWalletEvent, X as SparkWalletEventType, Y as SparkWalletEvents, J as TokenBalanceMap, E as TokenInvoice, M as TokenMetadataMap, K as TokenOutputsMap, T as TransferParams, A as TransferWithInvoiceOutcome, z as TransferWithInvoiceParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, k as bech32mDecode, w as decodeBech32mTokenIdentifier, f as decodeSparkAddress, u as encodeBech32mTokenIdentifier, e as encodeSparkAddress, d as encodeSparkAddressWithSignature, o as getNetwork, q as getNetworkFromAddress, x as getNetworkFromBech32mTokenIdentifier, j as getNetworkFromSparkAddress, r as getNetworkFromString, l as isSafeForNumber, g as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork, t as toProtoTimestamp, v as validateSparkInvoiceFields, h as validateSparkInvoiceSignature } from './spark-wallet-BVBrWYKL.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-CGeEoKYd.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-DUFejFfn.cjs';
|
|
6
6
|
export { I as IKeyPackage } from './types-B3hMoTYO.cjs';
|
|
7
7
|
import './spark-CLz4-Ln8.cjs';
|