@qntx/wallet-worker 0.8.1 → 0.10.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/kernel.manifest.json +19 -14
- package/dist/kernel.node.js +2666 -751
- package/dist/kernel.worker.js +2667 -752
- package/dist/{node-366p4fej.js → node-k5etevb7.js} +50 -40
- package/dist/{signer-gs57sjgx.js → signer-h69ffzx5.js} +1 -1
- package/dist/{worker-366p4fej.js → worker-k5etevb7.js} +50 -40
- package/package.json +5 -5
|
@@ -865,6 +865,16 @@ function numberToBytesBE(n, len) {
|
|
|
865
865
|
function numberToBytesLE(n, len) {
|
|
866
866
|
return numberToBytesBE(n, len).reverse();
|
|
867
867
|
}
|
|
868
|
+
function equalBytes(a, b) {
|
|
869
|
+
a = abytes2(a);
|
|
870
|
+
b = abytes2(b);
|
|
871
|
+
if (a.length !== b.length)
|
|
872
|
+
return false;
|
|
873
|
+
let diff = 0;
|
|
874
|
+
for (let i = 0;i < a.length; i++)
|
|
875
|
+
diff |= a[i] ^ b[i];
|
|
876
|
+
return diff === 0;
|
|
877
|
+
}
|
|
868
878
|
function copyBytes(bytes) {
|
|
869
879
|
return Uint8Array.from(abytes2(bytes));
|
|
870
880
|
}
|
|
@@ -3995,7 +4005,7 @@ var validateFieldName = (name, label) => {
|
|
|
3995
4005
|
if (restrictedKeys.has(name))
|
|
3996
4006
|
throw new Error(`${label} ${name} is reserved`);
|
|
3997
4007
|
};
|
|
3998
|
-
function
|
|
4008
|
+
function equalBytes2(a, b) {
|
|
3999
4009
|
if (a.length !== b.length)
|
|
4000
4010
|
return false;
|
|
4001
4011
|
for (let i = 0;i < a.length; i++)
|
|
@@ -4035,7 +4045,7 @@ function equal(a, b) {
|
|
|
4035
4045
|
const aBytes = isBytes4(a);
|
|
4036
4046
|
const bBytes = isBytes4(b);
|
|
4037
4047
|
if (aBytes || bBytes)
|
|
4038
|
-
return aBytes && bBytes &&
|
|
4048
|
+
return aBytes && bBytes && equalBytes2(a, b);
|
|
4039
4049
|
return a === b;
|
|
4040
4050
|
}
|
|
4041
4051
|
function isBytes4(a) {
|
|
@@ -4072,7 +4082,7 @@ function isNum(num) {
|
|
|
4072
4082
|
}
|
|
4073
4083
|
var hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
4074
4084
|
var utils = /* @__PURE__ */ Object.freeze({
|
|
4075
|
-
equalBytes,
|
|
4085
|
+
equalBytes: equalBytes2,
|
|
4076
4086
|
isBytes: isBytes4,
|
|
4077
4087
|
isCoder,
|
|
4078
4088
|
checkBounds,
|
|
@@ -5093,7 +5103,7 @@ var flag = (flagValue, xor = false) => {
|
|
|
5093
5103
|
decodeStream: (r) => {
|
|
5094
5104
|
let hasFlag = r.leftBytes >= marker.length;
|
|
5095
5105
|
if (hasFlag) {
|
|
5096
|
-
hasFlag =
|
|
5106
|
+
hasFlag = equalBytes2(r.bytes(marker.length, true), marker);
|
|
5097
5107
|
if (hasFlag)
|
|
5098
5108
|
r.bytes(marker.length);
|
|
5099
5109
|
}
|
|
@@ -5249,7 +5259,7 @@ function array(len, inner) {
|
|
|
5249
5259
|
inner.encodeStream(w, elm);
|
|
5250
5260
|
if (terminator && terminator.length <= _w.pos - startPos) {
|
|
5251
5261
|
const data = _w.finish(false).subarray(startPos, _w.pos);
|
|
5252
|
-
if (
|
|
5262
|
+
if (equalBytes2(data.subarray(0, terminator.length), terminator))
|
|
5253
5263
|
throw _w.err(`array: inner element encoding same as separator. elm=${elm} data=${data}`);
|
|
5254
5264
|
}
|
|
5255
5265
|
_w.exitField();
|
|
@@ -5275,7 +5285,7 @@ function array(len, inner) {
|
|
|
5275
5285
|
}
|
|
5276
5286
|
} else if (terminator) {
|
|
5277
5287
|
for (let i = 0;; i++) {
|
|
5278
|
-
if (
|
|
5288
|
+
if (equalBytes2(r.bytes(terminator.length, true), terminator)) {
|
|
5279
5289
|
r.bytes(terminator.length);
|
|
5280
5290
|
break;
|
|
5281
5291
|
}
|
|
@@ -5341,7 +5351,7 @@ var _2n5 = /* @__PURE__ */ BigInt(2);
|
|
|
5341
5351
|
var hasEven2 = (y) => y % _2n5 === _0n8;
|
|
5342
5352
|
var isBytes5 = /* @__PURE__ */ (() => utils.isBytes)();
|
|
5343
5353
|
var concatBytes4 = /* @__PURE__ */ (() => utils.concatBytes)();
|
|
5344
|
-
var
|
|
5354
|
+
var equalBytes3 = /* @__PURE__ */ (() => utils.equalBytes)();
|
|
5345
5355
|
var sha2562 = /* @__PURE__ */ (() => sha256)();
|
|
5346
5356
|
var hash1602 = (msg) => ripemd160(sha2562(msg));
|
|
5347
5357
|
var sha256x2 = (...msgs) => sha2562(sha2562(concatBytes4(...msgs)));
|
|
@@ -6298,7 +6308,7 @@ function mergeKeyMap(psbtEnum, val, cur, allowedFields, unknown = "strip", propr
|
|
|
6298
6308
|
let current = _cur[k];
|
|
6299
6309
|
if (typeof current === "string")
|
|
6300
6310
|
current = vC.decode(hex.decode(current));
|
|
6301
|
-
if (!
|
|
6311
|
+
if (!equalBytes3(vC.encode(res[k]), vC.encode(current)))
|
|
6302
6312
|
throw new Error(`Cannot change signed field=${k}`);
|
|
6303
6313
|
}
|
|
6304
6314
|
}
|
|
@@ -6350,7 +6360,7 @@ function combineKeyMap(psbtEnum, current, other, unknown = "strip", proprietary
|
|
|
6350
6360
|
a = valueCoder.decode(hex.decode(a));
|
|
6351
6361
|
if (typeof b === "string")
|
|
6352
6362
|
b = valueCoder.decode(hex.decode(b));
|
|
6353
|
-
if (!
|
|
6363
|
+
if (!equalBytes3(valueCoder.encode(a), valueCoder.encode(b)))
|
|
6354
6364
|
throw new Error(`Cannot combine conflicting field=${k}`);
|
|
6355
6365
|
}
|
|
6356
6366
|
return mergeKeyMap(psbtEnum, _other, _current, undefined, unknown, proprietary);
|
|
@@ -6362,7 +6372,7 @@ var RawPSBTV2 = /* @__PURE__ */ (() => Object.freeze(validate(_RawPSBTV2, valida
|
|
|
6362
6372
|
var P2A_PROGRAM = /* @__PURE__ */ Uint8Array.from([78, 115]);
|
|
6363
6373
|
var OutP2A = {
|
|
6364
6374
|
encode(from) {
|
|
6365
|
-
if (from.length !== 2 || from[0] !== 1 || !isBytes5(from[1]) || !
|
|
6375
|
+
if (from.length !== 2 || from[0] !== 1 || !isBytes5(from[1]) || !equalBytes3(from[1], P2A_PROGRAM))
|
|
6366
6376
|
return;
|
|
6367
6377
|
return { type: "p2a", script: Script.encode(from) };
|
|
6368
6378
|
},
|
|
@@ -6593,13 +6603,13 @@ var _WitnessOutScript = /* @__PURE__ */ (() => Object.freeze(wrap({
|
|
|
6593
6603
|
decodeStream: (r) => {
|
|
6594
6604
|
const raw = r.bytes(r.leftBytes);
|
|
6595
6605
|
const out = OutScript.decode(raw);
|
|
6596
|
-
if (out && (out.type === "p2a" || out.type === "wpkh" || out.type === "wsh" || out.type === "tr") && !
|
|
6606
|
+
if (out && (out.type === "p2a" || out.type === "wpkh" || out.type === "wsh" || out.type === "tr") && !equalBytes3(raw, OutScript.encode(out)))
|
|
6597
6607
|
throw new Error("OutScript: non-canonical witness program");
|
|
6598
6608
|
return out;
|
|
6599
6609
|
}
|
|
6600
6610
|
})))();
|
|
6601
6611
|
function checkWSH(s, witnessScript) {
|
|
6602
|
-
if (!
|
|
6612
|
+
if (!equalBytes3(s.hash, sha2562(witnessScript)))
|
|
6603
6613
|
throw new Error("checkScript: wsh wrong witnessScript hash");
|
|
6604
6614
|
const w = OutScript.decode(witnessScript);
|
|
6605
6615
|
if (w.type === "tr" || w.type === "tr_ns" || w.type === "tr_ms")
|
|
@@ -6617,7 +6627,7 @@ function checkScript(script, redeemScript, witnessScript) {
|
|
|
6617
6627
|
if (redeemScript) {
|
|
6618
6628
|
if (s.type !== "sh")
|
|
6619
6629
|
throw new Error("checkScript: redeemScript without P2SH");
|
|
6620
|
-
if (!
|
|
6630
|
+
if (!equalBytes3(s.hash, hash1602(redeemScript)))
|
|
6621
6631
|
throw new Error("checkScript: sh wrong redeemScript hash");
|
|
6622
6632
|
r = _WitnessOutScript.decode(redeemScript);
|
|
6623
6633
|
if (r?.type === "tr" || r?.type === "tr_ns" || r?.type === "tr_ms")
|
|
@@ -6659,7 +6669,7 @@ var checkCanonicalScript = (script, name, allowNonCanonicalScript) => {
|
|
|
6659
6669
|
return;
|
|
6660
6670
|
const decoded = Script.decode(script);
|
|
6661
6671
|
const nonMinimalNumber = decoded.some((op) => isBytes5(op) && op.length === 1 && (1 <= op[0] && op[0] <= 16 || op[0] === 129));
|
|
6662
|
-
if (nonMinimalNumber || !
|
|
6672
|
+
if (nonMinimalNumber || !equalBytes3(script, Script.encode(decoded))) {
|
|
6663
6673
|
const wrapper = name === "redeemScript" ? "P2SH" : "P2WSH";
|
|
6664
6674
|
throw new Error(`${wrapper}: non-canonical ${name}`);
|
|
6665
6675
|
}
|
|
@@ -6735,9 +6745,9 @@ function checkTaprootScript(script, internalPubKey, allowUnknownOutputs = false,
|
|
|
6735
6745
|
const outms = out;
|
|
6736
6746
|
if (!allowUnknownOutputs && outms.pubkeys) {
|
|
6737
6747
|
for (const p of outms.pubkeys) {
|
|
6738
|
-
if (
|
|
6748
|
+
if (equalBytes3(p, taprootNumsKey()))
|
|
6739
6749
|
throw new Error("Unspendable taproot key in leaf script");
|
|
6740
|
-
if (
|
|
6750
|
+
if (equalBytes3(p, internalPubKey)) {
|
|
6741
6751
|
throw new Error("Using P2TR with leaf script with same key as internal key is not supported");
|
|
6742
6752
|
}
|
|
6743
6753
|
}
|
|
@@ -6804,7 +6814,7 @@ function taprootHashTree(tree, internalPubKey, allowUnknownOutputs = false, cust
|
|
|
6804
6814
|
validateObject2(tree, {}, {}, "tree");
|
|
6805
6815
|
const version = tree.leafVersion;
|
|
6806
6816
|
const { script: leafScript } = tree;
|
|
6807
|
-
if (tree.tapLeafScript || tree.tapMerkleRoot && !
|
|
6817
|
+
if (tree.tapLeafScript || tree.tapMerkleRoot && !equalBytes3(tree.tapMerkleRoot, EMPTY))
|
|
6808
6818
|
throw new Error("P2TR: tapRoot leafScript cannot have tree");
|
|
6809
6819
|
const script = typeof leafScript === "string" ? hex.decode(leafScript) : abytes2(leafScript, undefined, "tree.script");
|
|
6810
6820
|
checkTaprootScript(script, internalPubKey, allowUnknownOutputs, customScripts);
|
|
@@ -6947,7 +6957,7 @@ function Address(network = NETWORK) {
|
|
|
6947
6957
|
return { type: "wpkh", hash: data };
|
|
6948
6958
|
else if (version === 1 && data.length === 32)
|
|
6949
6959
|
return { type: "tr", pubkey: data };
|
|
6950
|
-
else if (version === 1 &&
|
|
6960
|
+
else if (version === 1 && equalBytes3(data, P2A_PROGRAM))
|
|
6951
6961
|
return { type: "p2a", script: Script.encode([1, data]) };
|
|
6952
6962
|
else
|
|
6953
6963
|
throw new Error("Unknown witness program");
|
|
@@ -7047,7 +7057,7 @@ var SigHash = /* @__PURE__ */ (() => Object.freeze({
|
|
|
7047
7057
|
}))();
|
|
7048
7058
|
var SigHashNames = /* @__PURE__ */ (() => Object.freeze(reverseObject(SigHash)))();
|
|
7049
7059
|
function getTaprootKeys(privKey, pubKey, internalKey, merkleRoot = EMPTY) {
|
|
7050
|
-
if (
|
|
7060
|
+
if (equalBytes3(internalKey, pubKey)) {
|
|
7051
7061
|
privKey = taprootTweakPrivKey(privKey, merkleRoot);
|
|
7052
7062
|
pubKey = pubSchnorr(privKey);
|
|
7053
7063
|
}
|
|
@@ -7214,7 +7224,7 @@ function checkTaprootInputCommitments(input, prevScript) {
|
|
|
7214
7224
|
}
|
|
7215
7225
|
const checkOutputKey = (internalKey, merkleRoot, parity) => {
|
|
7216
7226
|
const [outputKey, outputParity] = taprootTweakPubkey(internalKey, merkleRoot);
|
|
7217
|
-
if (!
|
|
7227
|
+
if (!equalBytes3(outputKey, output.pubkey))
|
|
7218
7228
|
throw new Error("validateInput: Taproot commitment does not match previous output");
|
|
7219
7229
|
if (parity !== undefined && outputParity !== parity)
|
|
7220
7230
|
throw new Error("validateInput: Taproot control-block parity does not match previous output");
|
|
@@ -7228,9 +7238,9 @@ function checkTaprootInputCommitments(input, prevScript) {
|
|
|
7228
7238
|
merkleRoot = compareBytes(sibling, merkleRoot) === -1 ? tagSchnorr("TapBranch", sibling, merkleRoot) : tagSchnorr("TapBranch", merkleRoot, sibling);
|
|
7229
7239
|
}
|
|
7230
7240
|
checkOutputKey(controlBlock.internalKey, merkleRoot, controlBlock.version & 1);
|
|
7231
|
-
if (input.tapInternalKey && !
|
|
7241
|
+
if (input.tapInternalKey && !equalBytes3(input.tapInternalKey, controlBlock.internalKey))
|
|
7232
7242
|
throw new Error("validateInput: tapInternalKey does not match Taproot control block");
|
|
7233
|
-
if (input.tapMerkleRoot && !
|
|
7243
|
+
if (input.tapMerkleRoot && !equalBytes3(input.tapMerkleRoot, merkleRoot))
|
|
7234
7244
|
throw new Error("validateInput: tapMerkleRoot does not match Taproot control block");
|
|
7235
7245
|
}
|
|
7236
7246
|
}
|
|
@@ -7292,7 +7302,7 @@ function validateInput(i, disableScriptCheck = false) {
|
|
|
7292
7302
|
if (_i.index > last)
|
|
7293
7303
|
throw new Error(`validateInput: index(${_i.index}) not in nonWitnessUtxo`);
|
|
7294
7304
|
prevOut = _i.nonWitnessUtxo.outputs[_i.index];
|
|
7295
|
-
if (_i.witnessUtxo && (!
|
|
7305
|
+
if (_i.witnessUtxo && (!equalBytes3(_i.witnessUtxo.script, prevOut.script) || _i.witnessUtxo.amount !== prevOut.amount))
|
|
7296
7306
|
throw new Error("validateInput: witnessUtxo different from nonWitnessUtxo");
|
|
7297
7307
|
if (_i.txid) {
|
|
7298
7308
|
const outputs = _i.nonWitnessUtxo.outputs;
|
|
@@ -7843,7 +7853,7 @@ class Transaction {
|
|
|
7843
7853
|
if (signatures?.length && nextLockTime !== this.lockTime)
|
|
7844
7854
|
throw new Error("Tx has signed inputs, cannot change lockTime");
|
|
7845
7855
|
const current = this.inputs[idx];
|
|
7846
|
-
const transactionChanged = current.index !== normalized.index || def(current.sequence, DEFAULT_SEQUENCE) !== def(normalized.sequence, DEFAULT_SEQUENCE) || (current.txid === undefined ? normalized.txid !== undefined : normalized.txid === undefined || !
|
|
7856
|
+
const transactionChanged = current.index !== normalized.index || def(current.sequence, DEFAULT_SEQUENCE) !== def(normalized.sequence, DEFAULT_SEQUENCE) || (current.txid === undefined ? normalized.txid !== undefined : normalized.txid === undefined || !equalBytes3(current.txid, normalized.txid)) || nextLockTime !== this.lockTime;
|
|
7847
7857
|
if (transactionChanged)
|
|
7848
7858
|
this.requireTxModifiable(1, "inputs");
|
|
7849
7859
|
this.inputs[idx] = normalized;
|
|
@@ -7908,7 +7918,7 @@ class Transaction {
|
|
|
7908
7918
|
}
|
|
7909
7919
|
const current = this.outputs[idx];
|
|
7910
7920
|
const normalized = cloneDeep(this.normalizeOutput(output, current, allowedFields));
|
|
7911
|
-
const transactionChanged = current.amount !== normalized.amount || (current.script === undefined ? normalized.script !== undefined : normalized.script === undefined || !
|
|
7921
|
+
const transactionChanged = current.amount !== normalized.amount || (current.script === undefined ? normalized.script !== undefined : normalized.script === undefined || !equalBytes3(current.script, normalized.script));
|
|
7912
7922
|
if (transactionChanged)
|
|
7913
7923
|
this.requireTxModifiable(2, "outputs");
|
|
7914
7924
|
this.outputs[idx] = normalized;
|
|
@@ -8048,13 +8058,13 @@ class Transaction {
|
|
|
8048
8058
|
const canSign = (privateKey) => {
|
|
8049
8059
|
if (inputType.txType === "taproot") {
|
|
8050
8060
|
const pubKey = pubSchnorr(privateKey);
|
|
8051
|
-
if (input.tapInternalKey &&
|
|
8061
|
+
if (input.tapInternalKey && equalBytes3(pubKey, input.tapInternalKey))
|
|
8052
8062
|
return true;
|
|
8053
8063
|
if (!input.tapLeafScript)
|
|
8054
8064
|
return false;
|
|
8055
8065
|
for (const [_, leaf] of input.tapLeafScript) {
|
|
8056
8066
|
for (const op of Script.decode(leaf.subarray(0, -1))) {
|
|
8057
|
-
if (isBytes5(op) &&
|
|
8067
|
+
if (isBytes5(op) && equalBytes3(op, pubKey))
|
|
8058
8068
|
return true;
|
|
8059
8069
|
}
|
|
8060
8070
|
}
|
|
@@ -8063,7 +8073,7 @@ class Transaction {
|
|
|
8063
8073
|
const pubKey = pubECDSA(privateKey);
|
|
8064
8074
|
const pubKeyHash = hash1602(pubKey);
|
|
8065
8075
|
for (const op of Script.decode(inputType.lastScript)) {
|
|
8066
|
-
if (isBytes5(op) && (
|
|
8076
|
+
if (isBytes5(op) && (equalBytes3(op, pubKey) || equalBytes3(op, pubKeyHash)))
|
|
8067
8077
|
return true;
|
|
8068
8078
|
}
|
|
8069
8079
|
return false;
|
|
@@ -8077,7 +8087,7 @@ class Transaction {
|
|
|
8077
8087
|
let s = root;
|
|
8078
8088
|
for (const i of row.path)
|
|
8079
8089
|
s = s.deriveChild(i);
|
|
8080
|
-
if (!
|
|
8090
|
+
if (!equalBytes3(pubKey(s), row.pubKey))
|
|
8081
8091
|
throw new Error(`${label}: wrong pubKey`);
|
|
8082
8092
|
if (!s.privateKey)
|
|
8083
8093
|
throw new Error(`${label}: no privateKey`);
|
|
@@ -8132,7 +8142,7 @@ class Transaction {
|
|
|
8132
8142
|
if (input.tapInternalKey) {
|
|
8133
8143
|
const { pubKey, privKey } = getTaprootKeys(privateKey, schnorrPub, input.tapInternalKey, merkleRoot);
|
|
8134
8144
|
const [taprootPubKey, _] = taprootTweakPubkey(input.tapInternalKey, merkleRoot);
|
|
8135
|
-
if (
|
|
8145
|
+
if (equalBytes3(taprootPubKey, pubKey)) {
|
|
8136
8146
|
const hash = this.preimageWitnessV1(idx, prevOutScript, sighash, amount);
|
|
8137
8147
|
const sig = concatBytes4(signSchnorr(hash, privKey, _auxRand), sighash !== SignatureHash.DEFAULT ? new Uint8Array([sighash]) : EMPTY);
|
|
8138
8148
|
this.updateInput(idx, { tapKeySig: sig }, true);
|
|
@@ -8146,7 +8156,7 @@ class Transaction {
|
|
|
8146
8156
|
const scriptDecoded = Script.decode(script);
|
|
8147
8157
|
const ver = _script[_script.length - 1];
|
|
8148
8158
|
const hash = tapLeafHash(script, ver);
|
|
8149
|
-
const pos = scriptDecoded.findIndex((i) => isBytes5(i) &&
|
|
8159
|
+
const pos = scriptDecoded.findIndex((i) => isBytes5(i) && equalBytes3(i, schnorrPub));
|
|
8150
8160
|
if (pos === -1)
|
|
8151
8161
|
continue;
|
|
8152
8162
|
const msg = this.preimageWitnessV1(idx, prevOutScript, sighash, amount, undefined, script, ver);
|
|
@@ -8163,7 +8173,7 @@ class Transaction {
|
|
|
8163
8173
|
let hasPubkey = false;
|
|
8164
8174
|
const pubKeyHash = hash1602(pubKey);
|
|
8165
8175
|
for (const i of Script.decode(inputType.lastScript)) {
|
|
8166
|
-
if (isBytes5(i) && (
|
|
8176
|
+
if (isBytes5(i) && (equalBytes3(i, pubKey) || equalBytes3(i, pubKeyHash)))
|
|
8167
8177
|
hasPubkey = true;
|
|
8168
8178
|
}
|
|
8169
8179
|
if (!hasPubkey)
|
|
@@ -8219,7 +8229,7 @@ class Transaction {
|
|
|
8219
8229
|
const ver = _script[_script.length - 1];
|
|
8220
8230
|
const outScript = OutScript.decode(script);
|
|
8221
8231
|
const hash = tapLeafHash(script, ver);
|
|
8222
|
-
const scriptSig = input.tapScriptSig.filter((i) =>
|
|
8232
|
+
const scriptSig = input.tapScriptSig.filter((i) => equalBytes3(i[0].leafHash, hash));
|
|
8223
8233
|
let signatures = [];
|
|
8224
8234
|
let witness;
|
|
8225
8235
|
if (outScript.type === "tr_ms") {
|
|
@@ -8227,7 +8237,7 @@ class Transaction {
|
|
|
8227
8237
|
const pubkeys = outScript.pubkeys;
|
|
8228
8238
|
let added = 0;
|
|
8229
8239
|
for (const pub of pubkeys) {
|
|
8230
|
-
const sigIdx = scriptSig.findIndex((i) =>
|
|
8240
|
+
const sigIdx = scriptSig.findIndex((i) => equalBytes3(i[0].pubKey, pub));
|
|
8231
8241
|
if (added === m || sigIdx === -1) {
|
|
8232
8242
|
signatures.push(EMPTY);
|
|
8233
8243
|
continue;
|
|
@@ -8239,7 +8249,7 @@ class Transaction {
|
|
|
8239
8249
|
continue;
|
|
8240
8250
|
} else if (outScript.type === "tr_ns") {
|
|
8241
8251
|
for (const pub of outScript.pubkeys) {
|
|
8242
|
-
const sigIdx = scriptSig.findIndex((i) =>
|
|
8252
|
+
const sigIdx = scriptSig.findIndex((i) => equalBytes3(i[0].pubKey, pub));
|
|
8243
8253
|
if (sigIdx === -1)
|
|
8244
8254
|
continue;
|
|
8245
8255
|
signatures.push(scriptSig[sigIdx][1]);
|
|
@@ -8249,7 +8259,7 @@ class Transaction {
|
|
|
8249
8259
|
} else if (outScript.type === "unknown" && this.opts.allowUnknownInputs) {
|
|
8250
8260
|
const scriptDecoded = Script.decode(script);
|
|
8251
8261
|
signatures = scriptSig.map(([{ pubKey }, signature]) => {
|
|
8252
|
-
const pos = scriptDecoded.findIndex((i) => isBytes5(i) &&
|
|
8262
|
+
const pos = scriptDecoded.findIndex((i) => isBytes5(i) && equalBytes3(i, pubKey));
|
|
8253
8263
|
if (pos === -1)
|
|
8254
8264
|
throw new Error("finalize/taproot: cannot find position of pubkey in script");
|
|
8255
8265
|
return { signature, pos };
|
|
@@ -8307,7 +8317,7 @@ class Transaction {
|
|
|
8307
8317
|
const pubkeys = inputType.last.pubkeys;
|
|
8308
8318
|
let signatures = [];
|
|
8309
8319
|
for (const pub of pubkeys) {
|
|
8310
|
-
const sign = input.partialSig.find((s) =>
|
|
8320
|
+
const sign = input.partialSig.find((s) => equalBytes3(pub, s[0]));
|
|
8311
8321
|
if (!sign)
|
|
8312
8322
|
continue;
|
|
8313
8323
|
signatures.push(sign[1]);
|
|
@@ -8389,7 +8399,7 @@ class Transaction {
|
|
|
8389
8399
|
}
|
|
8390
8400
|
}
|
|
8391
8401
|
const unsignedTx = this.unsignedTx;
|
|
8392
|
-
if (!
|
|
8402
|
+
if (!equalBytes3(unsignedTx, other.unsignedTx))
|
|
8393
8403
|
throw new Error(`Transaction/combine: different unsigned tx`);
|
|
8394
8404
|
let txModifiable;
|
|
8395
8405
|
if (thisV2 && otherV2) {
|
|
@@ -8466,7 +8476,7 @@ class Transaction {
|
|
|
8466
8476
|
candidate.outputs = outputs;
|
|
8467
8477
|
if ((!thisV2 || !otherV2) && candidate.isPSBTv2())
|
|
8468
8478
|
candidate.global.txModifiable = candidate.txModifiable;
|
|
8469
|
-
if (!
|
|
8479
|
+
if (!equalBytes3(candidate.unsignedTx, unsignedTx))
|
|
8470
8480
|
throw new Error("Transaction/combine: combined unsigned tx differs");
|
|
8471
8481
|
this.global = candidate.global;
|
|
8472
8482
|
this.inputs = candidate.inputs;
|
|
@@ -8478,4 +8488,4 @@ class Transaction {
|
|
|
8478
8488
|
}
|
|
8479
8489
|
}
|
|
8480
8490
|
|
|
8481
|
-
export { anumber, abool, abytes, ahash, aexists, aoutput, u32, clean, createView, rotl, swap32IfBE, bytesToHex, hexToBytes, asyncLoop, utf8ToBytes, kdfInputToBytes, concatBytes, checkOpts, createHasher, randomBytes, split, sha256, sha512, abytes2, bytesToHex2, concatBytes2, hexToBytes2, isBytes, randomBytes2, abool2, asafenumber, bytesToNumberBE, bytesToNumberLE, numberToBytesLE, copyBytes, aInRange, validateObject, mod, pow2, isNegativeLE, FpLegendre, validatePointCons, normalizeZ, ScalarMultiplier, createCurveFields, createKeygen, hmac, secp256k1, schnorr, base64, base64urlnopad, bech32, ripemd160, HDKey, taprootTweakPrivKey, NETWORK, TEST_NETWORK, ScriptNum, Script, OutScript, p2pkh, p2sh, p2wpkh, taprootListToTree, p2tr, Address, SigHash, getInputType, Transaction };
|
|
8491
|
+
export { anumber, abool, abytes, ahash, aexists, aoutput, u32, clean, createView, rotl, swap32IfBE, bytesToHex, hexToBytes, asyncLoop, utf8ToBytes, kdfInputToBytes, concatBytes, checkOpts, createHasher, randomBytes, split, sha256, sha512, abytes2, bytesToHex2, concatBytes2, hexToBytes2, isBytes, randomBytes2, abool2, asafenumber, bytesToNumberBE, bytesToNumberLE, numberToBytesBE, numberToBytesLE, equalBytes, copyBytes, aInRange, validateObject, mod, pow2, isNegativeLE, FpLegendre, validatePointCons, normalizeZ, ScalarMultiplier, createCurveFields, createKeygen, hmac, secp256k1, schnorr, base64, base64urlnopad, base58, bech32, ripemd160, HDKey, taprootTweakPrivKey, NETWORK, TEST_NETWORK, ScriptNum, Script, OutScript, p2pkh, p2sh, p2wpkh, taprootListToTree, p2tr, Address, SigHash, getInputType, Transaction };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qntx/wallet-worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Web Worker and worker_threads hosts for @qntx/wallet",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nostr",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
"@qntx/spark": "0.5.2",
|
|
68
68
|
"@qntx/spark-wasm": "0.5.2",
|
|
69
69
|
"@qntx/tsconfig": "1.0.1",
|
|
70
|
-
"@qntx/wallet": "0.
|
|
71
|
-
"@qntx/wallet-kernel": "0.
|
|
70
|
+
"@qntx/wallet": "0.10.0",
|
|
71
|
+
"@qntx/wallet-kernel": "0.10.0",
|
|
72
72
|
"@scure/base": "2.4.0",
|
|
73
73
|
"@scure/btc-signer": "2.4.1",
|
|
74
|
-
"@types/node": "26.6.
|
|
74
|
+
"@types/node": "26.6.6",
|
|
75
75
|
"publint": "0.3.25",
|
|
76
76
|
"typescript": "7.0.2",
|
|
77
77
|
"vite-plus": "1.4.0"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@qntx/wallet": "0.
|
|
80
|
+
"@qntx/wallet": "0.10.0"
|
|
81
81
|
},
|
|
82
82
|
"devEngines": {
|
|
83
83
|
"packageManager": {
|