@btc-vision/bitcoin 7.0.0-alpha.8 → 7.0.0-alpha.9
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/browser/chunks/{psbt-parallel-PtTJ19DC.js → psbt-parallel-BBFlkmiv.js} +4 -2
- package/browser/index.d.ts +1 -1
- package/browser/index.d.ts.map +1 -1
- package/browser/index.js +2 -2
- package/browser/io/hex.d.ts.map +1 -1
- package/browser/workers/index.js +2 -2
- package/build/bech32utils.js.map +1 -1
- package/build/block.js.map +1 -1
- package/build/env.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/io/hex.d.ts.map +1 -1
- package/build/io/hex.js +2 -1
- package/build/io/hex.js.map +1 -1
- package/build/payments/bip341.js.map +1 -1
- package/build/payments/embed.js.map +1 -1
- package/build/payments/p2ms.js.map +1 -1
- package/build/payments/p2pk.js.map +1 -1
- package/build/payments/p2pkh.js.map +1 -1
- package/build/payments/p2sh.js.map +1 -1
- package/build/payments/p2tr.js.map +1 -1
- package/build/payments/p2wpkh.js.map +1 -1
- package/build/payments/p2wsh.js.map +1 -1
- package/build/psbt/PsbtFinalizer.js.map +1 -1
- package/build/psbt/PsbtSigner.js.map +1 -1
- package/build/psbt.js.map +1 -1
- package/build/transaction.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/workers/index.js.map +1 -1
- package/build/workers/psbt-parallel.js.map +1 -1
- package/package.json +1 -1
- package/src/bech32utils.ts +3 -3
- package/src/block.ts +2 -2
- package/src/env.ts +4 -2
- package/src/index.ts +1 -0
- package/src/io/hex.ts +2 -1
- package/src/payments/bip341.ts +3 -3
- package/src/payments/embed.ts +1 -1
- package/src/payments/p2ms.ts +2 -2
- package/src/payments/p2pk.ts +2 -2
- package/src/payments/p2pkh.ts +3 -3
- package/src/payments/p2sh.ts +4 -4
- package/src/payments/p2tr.ts +7 -7
- package/src/payments/p2wpkh.ts +5 -5
- package/src/payments/p2wsh.ts +2 -2
- package/src/psbt/PsbtFinalizer.ts +3 -3
- package/src/psbt/PsbtSigner.ts +3 -3
- package/src/psbt.ts +1 -1
- package/src/transaction.ts +1 -1
- package/src/workers/index.ts +1 -1
- package/src/workers/psbt-parallel.ts +1 -1
package/src/payments/p2sh.ts
CHANGED
|
@@ -336,7 +336,7 @@ export class P2SH {
|
|
|
336
336
|
output: (lastChunk === OPS.OP_FALSE
|
|
337
337
|
? new Uint8Array(0)
|
|
338
338
|
: (lastChunk as Uint8Array)) as Script,
|
|
339
|
-
input: bscript.compile(chunks.slice(0, -1))
|
|
339
|
+
input: bscript.compile(chunks.slice(0, -1)),
|
|
340
340
|
witness: this.#inputWitness || [],
|
|
341
341
|
};
|
|
342
342
|
}
|
|
@@ -370,7 +370,7 @@ export class P2SH {
|
|
|
370
370
|
}
|
|
371
371
|
const r = this.redeem;
|
|
372
372
|
if (r && r.output) {
|
|
373
|
-
return bcrypto.hash160(r.output)
|
|
373
|
+
return bcrypto.hash160(r.output);
|
|
374
374
|
}
|
|
375
375
|
return undefined;
|
|
376
376
|
}
|
|
@@ -382,7 +382,7 @@ export class P2SH {
|
|
|
382
382
|
const h = this.hash;
|
|
383
383
|
if (!h) return undefined;
|
|
384
384
|
|
|
385
|
-
return bscript.compile([OPS.OP_HASH160, h, OPS.OP_EQUAL])
|
|
385
|
+
return bscript.compile([OPS.OP_HASH160, h, OPS.OP_EQUAL]);
|
|
386
386
|
}
|
|
387
387
|
|
|
388
388
|
#computeInput(): Script | undefined {
|
|
@@ -395,7 +395,7 @@ export class P2SH {
|
|
|
395
395
|
}
|
|
396
396
|
return bscript.compile(
|
|
397
397
|
([] as Stack).concat(bscript.decompile(r.input) as Stack, r.output),
|
|
398
|
-
)
|
|
398
|
+
);
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
#computeRedeem(): ScriptRedeem | undefined {
|
package/src/payments/p2tr.ts
CHANGED
|
@@ -459,7 +459,7 @@ export class P2TR {
|
|
|
459
459
|
if (internalPk) {
|
|
460
460
|
const tweakedKey = tweakKey(internalPk, this.hash);
|
|
461
461
|
if (tweakedKey) {
|
|
462
|
-
return tweakedKey.x
|
|
462
|
+
return tweakedKey.x;
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
465
|
return undefined;
|
|
@@ -479,7 +479,7 @@ export class P2TR {
|
|
|
479
479
|
#computeHash(): Bytes32 | undefined {
|
|
480
480
|
const hashTree = this.#getHashTree();
|
|
481
481
|
if (hashTree) {
|
|
482
|
-
return hashTree.hash
|
|
482
|
+
return hashTree.hash;
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
const w = this.#getWitnessWithoutAnnex();
|
|
@@ -491,7 +491,7 @@ export class P2TR {
|
|
|
491
491
|
output: script,
|
|
492
492
|
version: leafVersion,
|
|
493
493
|
});
|
|
494
|
-
return rootHashFromPath(controlBlock, leafHash)
|
|
494
|
+
return rootHashFromPath(controlBlock, leafHash);
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
return undefined;
|
|
@@ -515,7 +515,7 @@ export class P2TR {
|
|
|
515
515
|
const pk = this.pubkey;
|
|
516
516
|
if (!pk) return undefined;
|
|
517
517
|
|
|
518
|
-
return bscript.compile([OPS.OP_1, pk])
|
|
518
|
+
return bscript.compile([OPS.OP_1, pk]);
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
#computeRedeem(): ScriptRedeem | undefined {
|
|
@@ -688,7 +688,7 @@ export class P2TR {
|
|
|
688
688
|
if (witness && witness.length > 0) {
|
|
689
689
|
if (witness.length === 1) {
|
|
690
690
|
// Key-path spending
|
|
691
|
-
if (this.#inputSignature && !equals(this.#inputSignature
|
|
691
|
+
if (this.#inputSignature && !equals(this.#inputSignature, witness[0]!)) {
|
|
692
692
|
throw new TypeError('Signature mismatch');
|
|
693
693
|
}
|
|
694
694
|
} else {
|
|
@@ -712,7 +712,7 @@ export class P2TR {
|
|
|
712
712
|
}
|
|
713
713
|
|
|
714
714
|
const internalPk = controlBlock.subarray(1, 33);
|
|
715
|
-
if (this.#inputInternalPubkey && !equals(this.#inputInternalPubkey
|
|
715
|
+
if (this.#inputInternalPubkey && !equals(this.#inputInternalPubkey, internalPk)) {
|
|
716
716
|
throw new TypeError('Internal pubkey mismatch');
|
|
717
717
|
}
|
|
718
718
|
|
|
@@ -729,7 +729,7 @@ export class P2TR {
|
|
|
729
729
|
});
|
|
730
730
|
const computedHash = rootHashFromPath(controlBlock, leafHash);
|
|
731
731
|
|
|
732
|
-
const outputKey = tweakKey(internalPk
|
|
732
|
+
const outputKey = tweakKey(internalPk, computedHash);
|
|
733
733
|
if (!outputKey) {
|
|
734
734
|
throw new TypeError('Invalid outputKey for p2tr witness');
|
|
735
735
|
}
|
package/src/payments/p2wpkh.ts
CHANGED
|
@@ -341,7 +341,7 @@ export class P2WPKH {
|
|
|
341
341
|
}
|
|
342
342
|
const pk = this.#inputPubkey ?? this.pubkey;
|
|
343
343
|
if (pk) {
|
|
344
|
-
return bcrypto.hash160(pk)
|
|
344
|
+
return bcrypto.hash160(pk);
|
|
345
345
|
}
|
|
346
346
|
return undefined;
|
|
347
347
|
}
|
|
@@ -373,7 +373,7 @@ export class P2WPKH {
|
|
|
373
373
|
const h = this.hash;
|
|
374
374
|
if (!h) return undefined;
|
|
375
375
|
|
|
376
|
-
return bscript.compile([OPS.OP_0, h])
|
|
376
|
+
return bscript.compile([OPS.OP_0, h]);
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
#computeInput(): Uint8Array | undefined {
|
|
@@ -457,14 +457,14 @@ export class P2WPKH {
|
|
|
457
457
|
if (!bscript.isCanonicalScriptSignature(this.#inputWitness[0]!)) {
|
|
458
458
|
throw new TypeError('Witness has invalid signature');
|
|
459
459
|
}
|
|
460
|
-
if (!isPoint(this.#inputWitness[1]!) || this.#inputWitness[1]
|
|
460
|
+
if (!isPoint(this.#inputWitness[1]!) || this.#inputWitness[1].length !== 33) {
|
|
461
461
|
throw new TypeError('Witness has invalid pubkey');
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
-
if (this.#inputSignature && !equals(this.#inputSignature
|
|
464
|
+
if (this.#inputSignature && !equals(this.#inputSignature, this.#inputWitness[0]!)) {
|
|
465
465
|
throw new TypeError('Signature mismatch');
|
|
466
466
|
}
|
|
467
|
-
if (this.#inputPubkey && !equals(this.#inputPubkey
|
|
467
|
+
if (this.#inputPubkey && !equals(this.#inputPubkey, this.#inputWitness[1])) {
|
|
468
468
|
throw new TypeError('Pubkey mismatch');
|
|
469
469
|
}
|
|
470
470
|
|
package/src/payments/p2wsh.ts
CHANGED
|
@@ -352,7 +352,7 @@ export class P2WSH {
|
|
|
352
352
|
}
|
|
353
353
|
const r = this.redeem;
|
|
354
354
|
if (r && r.output) {
|
|
355
|
-
return bcrypto.sha256(r.output)
|
|
355
|
+
return bcrypto.sha256(r.output);
|
|
356
356
|
}
|
|
357
357
|
return undefined;
|
|
358
358
|
}
|
|
@@ -364,7 +364,7 @@ export class P2WSH {
|
|
|
364
364
|
const h = this.hash;
|
|
365
365
|
if (!h) return undefined;
|
|
366
366
|
|
|
367
|
-
return bscript.compile([OPS.OP_0, h])
|
|
367
|
+
return bscript.compile([OPS.OP_0, h]);
|
|
368
368
|
}
|
|
369
369
|
|
|
370
370
|
#computeInput(): Uint8Array | undefined {
|
|
@@ -110,18 +110,18 @@ export function prepareFinalScripts(
|
|
|
110
110
|
finalScriptWitness = witnessStackToScriptWitness(solution ?? [new Uint8Array([0x00])]);
|
|
111
111
|
}
|
|
112
112
|
if (p2sh) {
|
|
113
|
-
finalScriptSig = p2sh?.input
|
|
113
|
+
finalScriptSig = p2sh?.input;
|
|
114
114
|
}
|
|
115
115
|
} else {
|
|
116
116
|
if (p2sh) {
|
|
117
|
-
finalScriptSig = p2sh?.input
|
|
117
|
+
finalScriptSig = p2sh?.input;
|
|
118
118
|
} else {
|
|
119
119
|
if (!payment) {
|
|
120
120
|
finalScriptSig = (
|
|
121
121
|
Array.isArray(solution) && solution[0] ? solution[0] : new Uint8Array([0x01])
|
|
122
122
|
) as Script;
|
|
123
123
|
} else {
|
|
124
|
-
finalScriptSig = payment.input
|
|
124
|
+
finalScriptSig = payment.input;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
}
|
package/src/psbt/PsbtSigner.ts
CHANGED
|
@@ -108,7 +108,7 @@ export class PsbtSigner {
|
|
|
108
108
|
if (!p2pkhPayment.output) throw new Error('Unable to create signing script');
|
|
109
109
|
hash = unsignedTx.hashForWitnessV0(
|
|
110
110
|
inputIndex,
|
|
111
|
-
p2pkhPayment.output
|
|
111
|
+
p2pkhPayment.output,
|
|
112
112
|
prevout.value,
|
|
113
113
|
sighashType,
|
|
114
114
|
);
|
|
@@ -198,7 +198,7 @@ export class PsbtSigner {
|
|
|
198
198
|
signingScripts,
|
|
199
199
|
values,
|
|
200
200
|
sighashType,
|
|
201
|
-
tapLeaf.hash
|
|
201
|
+
tapLeaf.hash,
|
|
202
202
|
undefined,
|
|
203
203
|
taprootCache,
|
|
204
204
|
);
|
|
@@ -206,7 +206,7 @@ export class PsbtSigner {
|
|
|
206
206
|
return {
|
|
207
207
|
pubkey: pubkey as PublicKey,
|
|
208
208
|
hash: tapScriptHash,
|
|
209
|
-
leafHash: tapLeaf.hash
|
|
209
|
+
leafHash: tapLeaf.hash,
|
|
210
210
|
};
|
|
211
211
|
});
|
|
212
212
|
|
package/src/psbt.ts
CHANGED
package/src/transaction.ts
CHANGED
|
@@ -770,7 +770,7 @@ export class Transaction {
|
|
|
770
770
|
getHash(forWitness?: boolean): Bytes32 {
|
|
771
771
|
// wtxid for coinbase is always 32 bytes of 0x00
|
|
772
772
|
if (forWitness && this.isCoinbase()) return new Uint8Array(32) as Bytes32;
|
|
773
|
-
return bcrypto.hash256(this.#toBuffer(undefined, undefined, forWitness))
|
|
773
|
+
return bcrypto.hash256(this.#toBuffer(undefined, undefined, forWitness));
|
|
774
774
|
}
|
|
775
775
|
|
|
776
776
|
/**
|
package/src/workers/index.ts
CHANGED
|
@@ -57,7 +57,7 @@ export * from './index.shared.js';
|
|
|
57
57
|
* @returns 'node' for Node.js, 'browser' for browsers, 'unknown' otherwise
|
|
58
58
|
*/
|
|
59
59
|
export function detectRuntime(): 'node' | 'browser' | 'react-native' | 'unknown' {
|
|
60
|
-
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
60
|
+
if (typeof navigator !== 'undefined' && (navigator as {product?: string}).product === 'ReactNative') {
|
|
61
61
|
return 'react-native';
|
|
62
62
|
}
|
|
63
63
|
if (typeof process !== 'undefined' && process.versions?.node) {
|
|
@@ -118,7 +118,7 @@ export async function signPsbtParallel(
|
|
|
118
118
|
pool = poolOrConfig;
|
|
119
119
|
} else {
|
|
120
120
|
const { WorkerSigningPool } = await import('./WorkerSigningPool.js');
|
|
121
|
-
pool = WorkerSigningPool.getInstance(poolOrConfig
|
|
121
|
+
pool = WorkerSigningPool.getInstance(poolOrConfig);
|
|
122
122
|
if (!pool.isPreservingWorkers) {
|
|
123
123
|
shouldShutdown = true;
|
|
124
124
|
}
|