Added JavaScript syntax highlighting
This commit is contained in:
parent
c494938cb7
commit
ae80f28252
|
@ -5,24 +5,27 @@ description: Sample code for the most common task in any bitcoin application.
|
||||||
|
|
||||||
## Create a Private Key
|
## Create a Private Key
|
||||||
|
|
||||||
```
|
```javascript
|
||||||
var privKey = new bitcore.PrivateKey();
|
var privKey = new bitcore.PrivateKey();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create an Address
|
## Create an Address
|
||||||
```
|
|
||||||
|
```javascript
|
||||||
var privKey = new bitcore.PrivateKey();
|
var privKey = new bitcore.PrivateKey();
|
||||||
var address = privKey.toAddress();
|
var address = privKey.toAddress();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create a Multisig Address
|
## Create a Multisig Address
|
||||||
```
|
|
||||||
|
```javascript
|
||||||
// Build a 2-of-3 address from public keys
|
// Build a 2-of-3 address from public keys
|
||||||
var P2SHAddress = new bitcore.Address([publicKey1, publicKey2, publicKey3], 2);
|
var P2SHAddress = new bitcore.Address([publicKey1, publicKey2, publicKey3], 2);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Request a Payment
|
## Request a Payment
|
||||||
```
|
|
||||||
|
```javascript
|
||||||
var paymentInfo = {
|
var paymentInfo = {
|
||||||
address: '1DNtTk4PUCGAdiNETAzQFWZiy2fCHtGnPx',
|
address: '1DNtTk4PUCGAdiNETAzQFWZiy2fCHtGnPx',
|
||||||
amount: 120000 //satoshis
|
amount: 120000 //satoshis
|
||||||
|
@ -31,7 +34,8 @@ var uri = new bitcore.URI(paymentInfo).toString();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create a Transaction
|
## Create a Transaction
|
||||||
```
|
|
||||||
|
```javascript
|
||||||
var transaction = new Transaction()
|
var transaction = new Transaction()
|
||||||
.from(utxos) // Feed information about what unspend outputs one can use
|
.from(utxos) // Feed information about what unspend outputs one can use
|
||||||
.to(address, amount) // Add an output with the given amount of satoshis
|
.to(address, amount) // Add an output with the given amount of satoshis
|
||||||
|
@ -40,7 +44,8 @@ var transaction = new Transaction()
|
||||||
```
|
```
|
||||||
|
|
||||||
## Connect to the Network
|
## Connect to the Network
|
||||||
```
|
|
||||||
|
```javascript
|
||||||
var peer = new Peer('5.9.85.34');
|
var peer = new Peer('5.9.85.34');
|
||||||
|
|
||||||
peer.on('inv', function(message) {
|
peer.on('inv', function(message) {
|
||||||
|
|
Loading…
Reference in New Issue