-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path001.js
28 lines (22 loc) · 840 Bytes
/
001.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Filename:
// 001.js
// Description:
// Generate a Private and Public Key Pair
// Then use send some BSV to the Public Key
// from an existing service
var bsv = require('bsv');
var buffer = require('buffer');
// Generate a Key (object)
let privateKey = bsv.PrivateKey.fromRandom()
// or...
// Generate a Key (object) for the TestNet
// let privateKey = bsv.PrivateKey.fromRandom('testnet')
// Get the Private Key as a String
let privateKeyString = privateKey.toString();
console.log("privateKeyString", privateKeyString);
// Get the Public Address as a String
let publicAddress = privateKey.toAddress().toString()
console.log("publicAddress", publicAddress);
// Now, send money from Money Button to the Public Address
// Money Button will create a bitcoin transaction (Tx) and transfer the
// specified amount to the public address