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.
43 lines
1.9 KiB
43 lines
1.9 KiB
10 years ago
|
# > `bitcore.Networks`
|
||
|
|
||
|
## Description
|
||
10 years ago
|
|
||
10 years ago
|
Bitcore provides support for both the main bitcoin network as well as for `testnet3`, the current test blockchain. We encourage the use of `Networks.livenet` and `Networks.testnet` as constants. Note that the library sometimes may check for equality against this object. Avoid creating a deep copy of this object and using that.
|
||
|
|
||
|
The `Network` namespace has a function, `get(...)` that returns an instance of a `Network` or `undefined`. The only argument to this function is some kind of identifier of the network: either its name, a reference to a Network object, or a number used as a magic constant to identify the network (for example, the value `0` that gives bitcoin addresses the distinctive `'1'` at its beginning on livenet, is a `0x6F` for testnet).
|
||
10 years ago
|
|
||
|
## Setting the default network
|
||
|
|
||
10 years ago
|
Most project will only need to work in one of either networks. The value of `Networks.defaultNetwork` can be set to `Networks.testnet` if the project will needs only to work on testnet (the default is `Networks.livenet`).
|
||
10 years ago
|
|
||
|
## Network constants
|
||
|
|
||
10 years ago
|
The functionality of testnet and livenet is mostly similar (except for some relaxed block validation rules on testnet). They differ in the constants being used for human representation of base58 encoded strings. These are sometimes referred to as "version" constants.
|
||
|
|
||
10 years ago
|
Take a look at this modified snippet from [networks.js](https://github.com/bitpay/bitcore/blob/master/lib/networks.js)
|
||
10 years ago
|
```javascript
|
||
|
var livenet = new Network();
|
||
|
_.extend(livenet, {
|
||
|
name: 'livenet',
|
||
|
alias: 'mainnet',
|
||
|
pubkeyhash: 0x00,
|
||
|
privatekey: 0x80,
|
||
|
scripthash: 0x05,
|
||
|
xpubkey: 0x0488b21e,
|
||
|
xprivkey: 0x0488ade4,
|
||
|
port: 8333
|
||
|
});
|
||
10 years ago
|
|
||
10 years ago
|
var testnet = new Network();
|
||
|
_.extend(testnet, {
|
||
|
name: 'testnet',
|
||
|
alias: 'testnet',
|
||
|
pubkeyhash: 0x6f,
|
||
|
privatekey: 0xef,
|
||
|
scripthash: 0xc4,
|
||
|
xpubkey: 0x043587cf,
|
||
|
xprivkey: 0x04358394,
|
||
|
port: 18333
|
||
|
});
|
||
|
```
|