You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
10 years ago
|
# Examples
|
||
|
|
||
10 years ago
|
## Create a Private Key
|
||
10 years ago
|
|
||
|
```
|
||
|
var privKey = new bitcore.PrivateKey();
|
||
|
```
|
||
|
|
||
|
## Create an Address
|
||
|
```
|
||
|
var privKey = new bitcore.PrivateKey();
|
||
|
var address = privKey.toAddress();
|
||
|
```
|
||
|
|
||
|
## Create a Multisig Address
|
||
|
```
|
||
10 years ago
|
// Build a 2-of-3 address from public keys
|
||
|
var P2SHAddress = new bitcore.Address([publicKey1, publicKey2, publicKey3], 2);
|
||
10 years ago
|
```
|
||
|
|
||
|
## Request a Payment
|
||
|
```
|
||
|
var paymentInfo = {
|
||
|
address: '1DNtTk4PUCGAdiNETAzQFWZiy2fCHtGnPx',
|
||
|
amount: 120000 //satoshis
|
||
|
};
|
||
|
var uri = new bitcore.URI(paymentInfo).toString();
|
||
|
```
|
||
|
|
||
10 years ago
|
## Create a Transaction
|
||
10 years ago
|
```
|
||
10 years ago
|
var transaction = new Transaction()
|
||
|
.from(utxos) // Feed information about what unspend outputs one can use
|
||
|
.to(address, amount) // Add an output with the given amount of satoshis
|
||
|
.change(address) // Sets up a change address where the rest of the funds will go
|
||
|
.sign(privkeySet) // Signs all the inputs it can
|
||
10 years ago
|
```
|
||
|
|
||
10 years ago
|
## Connect to the Network
|
||
10 years ago
|
```
|
||
|
var peer = new Peer('5.9.85.34');
|
||
|
|
||
|
peer.on('inv', function(message) {
|
||
|
// new invetory
|
||
|
});
|
||
|
|
||
|
peer.connect();
|
||
|
```
|