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 7795853Copy full SHA for 7795853
src/example-generate-address.js
@@ -0,0 +1,17 @@
1
+/**
2
+ * Example: Generate a new Bitcoin address using bitcoinjs-lib.
3
+ * This simple script creates a random key pair and logs
4
+ * the corresponding P2WPKH (SegWit) address.
5
+ */
6
+
7
+import * as bitcoin from 'bitcoinjs-lib';
8
9
+export function generateSegWitAddress() {
10
+ const keyPair = bitcoin.ECPair.makeRandom();
11
+ const { address } = bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey });
12
+ console.log('Your new Bitcoin address:', address);
13
+ return address;
14
+}
15
16
+// Uncomment below line for direct execution
17
+// generateSegWitAddress();
0 commit comments