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.
99 lines
2.7 KiB
99 lines
2.7 KiB
10 years ago
|
# Bitcore v0.9
|
||
10 years ago
|
|
||
|
## Principles
|
||
|
|
||
10 years ago
|
Bitcoin is a powerful new peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Bitcoin network allows for highly resilient bitcoin infrastructure, and the developer community needs reliable, open-source tools to implement bitcoin apps and services. Bitcore provides a reliable API for javascript apps that need to interface with Bitcoin.
|
||
10 years ago
|
|
||
|
To get started, just `npm install bitcore` or `bower install bitcore`.
|
||
|
|
||
|
# Documentation Index
|
||
|
|
||
|
## Addresses and Key Management
|
||
|
|
||
|
* [Addresses](address.md)
|
||
10 years ago
|
* [Using Different Networks](networks.md)
|
||
10 years ago
|
* [Private Keys](privatekey.md) and [Public Keys](publickey.md)
|
||
|
* [Hierarchically-derived Private and Public Keys](hierarchical.md)
|
||
|
|
||
10 years ago
|
## Payment Handling
|
||
|
* [Using Different Units](unit.md)
|
||
|
* [Acknowledging and Requesting Payments: Bitcoin URIs](uri.md)
|
||
10 years ago
|
* [The Transaction Class](transaction.md)
|
||
|
|
||
10 years ago
|
## Bitcoin Internals
|
||
10 years ago
|
* [Scripts](script.md)
|
||
|
* [Block](block.md)
|
||
|
|
||
|
## Extra
|
||
|
* [Crypto](crypto.md)
|
||
|
* [Encoding](encoding.md)
|
||
|
|
||
10 years ago
|
## Module Development
|
||
|
* [Browser Builds](browser.md)
|
||
|
|
||
10 years ago
|
## Modules
|
||
|
|
||
|
Some functionality is implemented as a module that can be installed seperately:
|
||
|
|
||
|
* [Payment Protocol Support](https://github.com/bitpay/bitcore-payment-protocol)
|
||
|
* [Peer to Peer Networking](https://github.com/bitpay/bitcore-payment-protocol)
|
||
|
* [Bitcoin Core JSON-RPC](https://github.com/bitpay/bitcoind-rpc)
|
||
|
* [Payment Channels](https://github.com/bitpay/bitcore-channel)
|
||
|
* [Mnemonics](https://github.com/bitpay/bitcore-mnemonic)
|
||
|
* [Elliptical Curve Integrated Encryption Scheme](https://github.com/bitpay/bitcore-ecies)
|
||
|
* [Blockchain Explorers](https://github.com/bitpay/bitcore-explorers)
|
||
|
|
||
10 years ago
|
# Examples
|
||
|
|
||
|
## Create a Private Key
|
||
|
|
||
10 years ago
|
```javascript
|
||
10 years ago
|
var privKey = new bitcore.PrivateKey();
|
||
|
```
|
||
|
|
||
|
## Create an Address
|
||
10 years ago
|
|
||
|
```javascript
|
||
10 years ago
|
var privKey = new bitcore.PrivateKey();
|
||
|
var address = privKey.toAddress();
|
||
|
```
|
||
|
|
||
|
## Create a Multisig Address
|
||
10 years ago
|
|
||
|
```javascript
|
||
10 years ago
|
// Build a 2-of-3 address from public keys
|
||
|
var P2SHAddress = new bitcore.Address([publicKey1, publicKey2, publicKey3], 2);
|
||
|
```
|
||
|
|
||
|
## Request a Payment
|
||
10 years ago
|
|
||
|
```javascript
|
||
10 years ago
|
var paymentInfo = {
|
||
|
address: '1DNtTk4PUCGAdiNETAzQFWZiy2fCHtGnPx',
|
||
|
amount: 120000 //satoshis
|
||
|
};
|
||
|
var uri = new bitcore.URI(paymentInfo).toString();
|
||
|
```
|
||
|
|
||
|
## Create a Transaction
|
||
10 years ago
|
|
||
|
```javascript
|
||
10 years ago
|
var transaction = new Transaction()
|
||
10 years ago
|
.from(utxos) // Feed information about what unspent outputs one can use
|
||
10 years ago
|
.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
|
||
|
```
|
||
|
|
||
|
## Connect to the Network
|
||
10 years ago
|
|
||
|
```javascript
|
||
10 years ago
|
var peer = new Peer('5.9.85.34');
|
||
|
|
||
|
peer.on('inv', function(message) {
|
||
10 years ago
|
// new inventory
|
||
10 years ago
|
});
|
||
|
|
||
|
peer.connect();
|
||
|
```
|