We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 13aea8c commit e638df0Copy full SHA for e638df0
src/example-taproot-verify.js
@@ -0,0 +1,17 @@
1
+/**
2
+ * Example: Simple Taproot signature verification using bitcoinjs-lib
3
+ * Demonstrates how to import a transaction and verify a signature.
4
+ */
5
+
6
+import * as bitcoin from 'bitcoinjs-lib';
7
8
+export function verifyTaprootSignature(txHex, signature, pubkey) {
9
+ try {
10
+ const tx = bitcoin.Transaction.fromHex(txHex);
11
+ const hash = tx.hashForWitnessV1(0, [pubkey], [bitcoin.Transaction.SIGHASH_ALL]);
12
+ return bitcoin.script.signature.decode(signature).toString('hex') === hash.toString('hex');
13
+ } catch (err) {
14
+ console.error('Verification failed:', err);
15
+ return false;
16
+ }
17
+}
0 commit comments