|
|
@ -42,24 +42,27 @@ To get started, just `npm install bitcore` or `bower install bitcore`. |
|
|
|
|
|
|
|
## Create a Private Key |
|
|
|
|
|
|
|
``` |
|
|
|
```javascript |
|
|
|
var privKey = new bitcore.PrivateKey(); |
|
|
|
``` |
|
|
|
|
|
|
|
## Create an Address |
|
|
|
``` |
|
|
|
|
|
|
|
```javascript |
|
|
|
var privKey = new bitcore.PrivateKey(); |
|
|
|
var address = privKey.toAddress(); |
|
|
|
``` |
|
|
|
|
|
|
|
## Create a Multisig Address |
|
|
|
``` |
|
|
|
|
|
|
|
```javascript |
|
|
|
// Build a 2-of-3 address from public keys |
|
|
|
var P2SHAddress = new bitcore.Address([publicKey1, publicKey2, publicKey3], 2); |
|
|
|
``` |
|
|
|
|
|
|
|
## Request a Payment |
|
|
|
``` |
|
|
|
|
|
|
|
```javascript |
|
|
|
var paymentInfo = { |
|
|
|
address: '1DNtTk4PUCGAdiNETAzQFWZiy2fCHtGnPx', |
|
|
|
amount: 120000 //satoshis |
|
|
@ -68,7 +71,8 @@ var uri = new bitcore.URI(paymentInfo).toString(); |
|
|
|
``` |
|
|
|
|
|
|
|
## Create a Transaction |
|
|
|
``` |
|
|
|
|
|
|
|
```javascript |
|
|
|
var transaction = new Transaction() |
|
|
|
.from(utxos) // Feed information about what unspent outputs one can use |
|
|
|
.to(address, amount) // Add an output with the given amount of satoshis |
|
|
@ -77,7 +81,8 @@ var transaction = new Transaction() |
|
|
|
``` |
|
|
|
|
|
|
|
## Connect to the Network |
|
|
|
``` |
|
|
|
|
|
|
|
```javascript |
|
|
|
var peer = new Peer('5.9.85.34'); |
|
|
|
|
|
|
|
peer.on('inv', function(message) { |
|
|
|