Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dashevo/dashcore-lib

Package Overview
Dependencies
Maintainers
11
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dashevo/dashcore-lib - npm Package Compare versions

Comparing version 0.15.3 to 0.15.4

.jshintignore

12

docs/address.md

@@ -1,6 +0,6 @@

# Bitcoin Address
Represents a bitcoin address. Addresses are the most popular way to make bitcoin transactions. See [the official Bitcoin Wiki](https://en.bitcoin.it/wiki/Address) for technical background information.
# Dash Address
Represents a Dash address. Addresses are the most popular way to make Dash transactions. See [the Dash documentation](https://dash-docs.github.io/en/glossary/address) for technical background information.
## Instantiate an Address
To be able to receive bitcoins an address is needed, but in order to spend them a private key is necessary. Please take a look at the [`PrivateKey`](privatekey.md) docs for more information about exporting and saving a key.
To be able to receive some funds an address is needed, but in order to spend them a private key is necessary. Please take a look at the [`PrivateKey`](privatekey.md) docs for more information about exporting and saving a key.

@@ -16,3 +16,3 @@ ```javascript

// from a string
var address = Address.fromString('mwkXG8NnB2snbqWTcpNiK6qqGHm1LebHDc');
var address = Address.fromString('XuUGDZHrKLo841CyamDbG5W7n59epA71h2');

@@ -38,3 +38,3 @@ // a default network address from a public key

## Validating an Address
The main use that we expect you'll have for the `Address` class in Bitcore is validating that an address is a valid one, what type of address it is (you may be interested on knowing if the address is a simple "pay to public key hash" address or a "pay to script hash" address) and what network does the address belong to.
The main use that we expect you'll have for the `Address` class in Dashcore is validating that an address is a valid one, what type of address it is (you may be interested on knowing if the address is a simple "pay to public key hash" address or a "pay to script hash" address) and what network does the address belong to.

@@ -67,2 +67,2 @@ The code to do these validations looks like this:

The errors are listed in the generated file in the [errors folder](https://github.com/bitpay/bitcore/tree/master/lib/errors). There's a structure to errors defined in the [spec.js file](https://github.com/bitpay/bitcore/tree/master/lib/errors/spec.js).
The errors are listed in the generated file in the [errors folder](https://github.com/dashevo/bitcore-dash/tree/master/lib/errors). There's a structure to errors defined in the [spec.js file](https://github.com/dashevo/bitcore-dash/tree/master/lib/errors/spec.js).

@@ -1,3 +0,3 @@

# Bitcoin Block
A Block instance represents the information of a block in the bitcoin network. Given a hexadecimal string representation of the serialization of a block with its transactions, you can instantiate a Block instance. Methods are provided to calculate and check the merkle root hash (if enough data is provided), but transactions won't necessarily be valid spends, and this class won't validate them. A binary representation as a `Buffer` instance is also valid input for a Block's constructor.
# Dash Block
A Block instance represents the information of a block in the Dash network. Given a hexadecimal string representation of the serialization of a block with its transactions, you can instantiate a Block instance. Methods are provided to calculate and check the merkle root hash (if enough data is provided), but transactions won't necessarily be valid spends, and this class won't validate them. A binary representation as a `Buffer` instance is also valid input for a Block's constructor.

@@ -16,3 +16,3 @@ ```javascript

For detailed technical information about a block please visit [Blocks](https://en.bitcoin.it/wiki/Blocks#Block_structure) on the Bitcoin Wiki.
For detailed technical information about a block please visit [Blocks](https://dash-docs.github.io/en/glossary/block) on the Dash Wiki.

@@ -38,3 +38,3 @@ ## Block Header

For more information about the specific properties of a block header please visit the [Block hashing algorithm](https://en.bitcoin.it/wiki/Block_hashing_algorithm) page on the Bitcoin Wiki.
For more information about the specific properties of a block header please visit the [Block headers](https://dash-docs.github.io/en/developer-reference#block-headers) page on the Dash Developer Reference Wiki.

@@ -41,0 +41,0 @@ ## Transactions

@@ -1,17 +0,17 @@

# Bitcoin Crypto
The cryptographic primitives (ECDSA and HMAC) implementations in this package have been reviewed by the BitPay engineering team. More audits and reviews are welcomed.
# Dash Crypto
The cryptographic primitives (ECDSA and HMAC) implementations in this package have been reviewed on the upstream repository, no changes have been done since then, however, more audits and reviews are welcomed.
## Random
The `bitcore.crypto.Random` namespace contains a single function, named `getRandomBuffer(size)` that returns a `Buffer` instance with random bytes. It may not work depending on the engine that bitcore is running on (doesn't work with IE versions lesser than 11).
The `dashcore.crypto.Random` namespace contains a single function, named `getRandomBuffer(size)` that returns a `Buffer` instance with random bytes. It may not work depending on the engine that dashcore is running on (doesn't work with IE versions lesser than 11).
## BN
The `bitcore.crypto.BN` class contains a wrapper around [bn.js](https://github.com/indutny/bn.js), the bignum library used internally in bitcore.
The `dashcore.crypto.BN` class contains a wrapper around [bn.js](https://github.com/indutny/bn.js), the bignum library used internally in dashcore.
## Point
The `bitcore.crypto.Point` class contains a wrapper around the class Point of [elliptic.js](https://github.com/indutny/elliptic), the elliptic curve library used internally in bitcore.
The `dashcore.crypto.Point` class contains a wrapper around the class Point of [elliptic.js](https://github.com/indutny/elliptic), the elliptic curve library used internally in dashcore.
## Hash
The `bitcore.crypto.Hash` namespace contains a set of hashes and utilities. These are either the native `crypto` hash functions from `node.js` or their respective browser shims as provided by the `browserify` library.
The `dashcore.crypto.Hash` namespace contains a set of hashes and utilities. These are either the native `crypto` hash functions from `node.js` or their respective browser shims as provided by the `browserify` library.
## ECDSA
`bitcore.crypto.ECDSA` contains a pure JavaScript implementation of the elliptic curve DSA signature scheme based on [elliptic.js](https://github.com/indutny/elliptic).
`dashcore.crypto.ECDSA` contains a pure JavaScript implementation of the elliptic curve DSA signature scheme based on [elliptic.js](https://github.com/indutny/elliptic).
# Encoding
The `bitcore.Encoding` namespace contains utilities for encoding information in common formats in the bitcoin ecosystem.
The `dashcore.Encoding` namespace contains utilities for encoding information in common formats in the Dash ecosystem.

@@ -4,0 +4,0 @@ ## Base58 & Base58Check

@@ -1,3 +0,61 @@

# Bitcore examples
# Dashcore examples
## Create and Save a Private Key
```javascript
var privateKey = new bitcore.PrivateKey();
var exported = privateKey.toWIF();
// e.g. L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m
var imported = bitcore.PrivateKey.fromWIF(exported);
var hexa = privateKey.toString();
// e.g. 'b9de6e778fe92aa7edb69395556f843f1dce0448350112e14906efc2a80fa61a'
```
## Create an Address
```javascript
var address = privateKey.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
};
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
.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
```javascript
var peer = new Peer('5.9.85.34');
peer.on('inv', function(message) {
// new inventory
});
peer.connect();
```
## Generate a random address

@@ -4,0 +62,0 @@ ```javascript

@@ -5,3 +5,3 @@ # HDKeys

## Hierarchically Derived Keys
Bitcore provides full support for [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), allowing for many key management schemas that benefit from this property. Please be sure to read and understand the basic concepts and the warnings on that BIP before using these classes.
Dashcore provides full support for [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), allowing for many key management schemas that benefit from this property. Please be sure to read and understand the basic concepts and the warnings on that BIP before using these classes.

@@ -14,4 +14,3 @@ ## HDPrivateKey

```javascript
var bitcore = require('bitcore');
var HDPrivateKey = bitcore.HDPrivateKey;
var HDPrivateKey = dashcore.HDPrivateKey;

@@ -18,0 +17,0 @@ var hdPrivateKey = new HDPrivateKey();

# Networks
Bitcore provides support for 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. Please avoid creating a deep copy of this object.
Dashcore provides support for the main Dash 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. Please avoid creating a deep copy of this object.
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).
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 `0x4c` that gives Dash addresses the distinctive `'X'` at its beginning on livenet, is a `0x8c` for testnet).
## Regtest
The regtest network is useful for development as it's possible to programmatically and instantly generate blocks for testing. It's currently supported as a variation of testnet. Here is an example of how to use regtest with the Bitcore Library:
The regtest network is useful for development as it's possible to programmatically and instantly generate blocks for testing. It's currently supported as a variation of testnet. Here is an example of how to use regtest with the Dashcore Library:
```js
// Standard testnet
> bitcore.Networks.testnet.networkMagic;
<Buffer 0b 11 09 07>
> dashcore.Networks.testnet.networkMagic;
<Buffer ce e2 ca ff>
```

@@ -18,5 +18,5 @@

// Enabling testnet to use the regtest port and magicNumber
> bitcore.Networks.enableRegtest();
> bitcore.Networks.testnet.networkMagic;
<Buffer fa bf b5 da>
> dashcore.Networks.enableRegtest();
> dashcore.Networks.testnet.networkMagic;
<Buffer fc c1 b7 dc>
```

@@ -30,4 +30,2 @@

Take a look at this modified snippet from [networks.js](https://github.com/bitpay/bitcore/blob/master/lib/networks.js)
```javascript

@@ -38,8 +36,9 @@ var livenet = new Network();

alias: 'mainnet',
pubkeyhash: 0x00,
privatekey: 0x80,
scripthash: 0x05,
xpubkey: 0x0488b21e,
xprivkey: 0x0488ade4,
port: 8333
pubkeyhash: 0x4c,
privatekey: 0xcc,
scripthash: 0x10,
xpubkey: 0x488b21e,
xprivkey: 0x488ade4,
networkMagic: 0xbf0c6bbd,
port: 9999,
});

@@ -51,9 +50,9 @@

alias: 'testnet',
pubkeyhash: 0x6f,
pubkeyhash: 0x8c,
privatekey: 0xef,
scripthash: 0xc4,
xpubkey: 0x043587cf,
scripthash: 0x13,
xpubkey: 0x43587cf,
xprivkey: 0x04358394,
port: 18333
port:19999
});
```
# Private Key
Represents a bitcoin private key and is needed to be able to spend bitcoin and sign transactions. See the official [Bitcoin Wiki](https://en.bitcoin.it/wiki/Private_key) for more information about private keys. A PrivateKey in Bitcore is an immutable object that has methods to import and export into a variety of formats including [Wallet Import Format](https://en.bitcoin.it/wiki/Wallet_import_format).
Represents a Dash private key and is needed to be able to spend funds and sign transactions. See the official [Bitcoin Wiki](https://en.bitcoin.it/wiki/Private_key) for more information about private keys. A PrivateKey in Dashcore is an immutable object that has methods to import and export into a variety of formats including [Wallet Import Format](https://en.bitcoin.it/wiki/Wallet_import_format).

@@ -18,9 +18,9 @@ ## Instantiate a Private Key

// encode into wallet export format
var exported = privateKey.toWIF();
var exported = privateKey.toWIF(); //XHFu419963FyHRikGLeRxxgNNJRdujRnxz9u8YRFfG5FNeGpfueL
// instantiate from the exported (and saved) private key
var imported = PrivateKey.fromWIF('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m');
var imported = PrivateKey.fromWIF(exported);
```
Note: The WIF (Wallet Import Format) includes information about the network and if the associated public key is compressed or uncompressed (thus the same bitcoin address will be generated by using this format).
Note: The WIF (Wallet Import Format) includes information about the network and if the associated public key is compressed or uncompressed (thus the same Dash address will be generated by using this format).

@@ -27,0 +27,0 @@ To generate an Address or PublicKey from a PrivateKey:

# Public Key
Represents a bitcoin public key and is needed to be able to receive bitcoin, as is usually represented as a bitcoin [Address](address.md). See the official [Bitcoin Wiki](https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses).
Represents a Fash public key and is needed to be able to receive funds, as is usually represented as a Dash [Address](address.md). See the official [Bitcoin Wiki](https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses).
A PublicKey in Bitcore is an immutable object and can be instantiated from a [Point](crypto.md), string, [PrivateKey](privatekey.md), Buffer or a [BN](crypto.md).
A PublicKey in Dashcore is an immutable object and can be instantiated from a [Point](crypto.md), string, [PrivateKey](privatekey.md), Buffer or a [BN](crypto.md).

@@ -30,3 +30,3 @@ ## Instantiate a Public Key

## Compressed vs Uncompressed
It's important to note that there are two possible ways to represent a public key. The standard is _compressed_ and includes the X value and parity (as represented above in the documentation). There is also a longer version that is _uncompressed_ which includes both X and Y values. Using this encoding will generate a different bitcoin address, so be careful when selecting the encoding. Uncompressed public keys start with 0x04; compressed public keys begin with 0x03 or 0x02 depending on whether they're greater or less than the midpoint of the curve. These prefix bytes are all used in official secp256k1 documentation.
It's important to note that there are two possible ways to represent a public key. The standard is _compressed_ and includes the X value and parity (as represented above in the documentation). There is also a longer version that is _uncompressed_ which includes both X and Y values. Using this encoding will generate a different Dash address, so be careful when selecting the encoding. Uncompressed public keys start with 0x04; compressed public keys begin with 0x03 or 0x02 depending on whether they're greater or less than the midpoint of the curve. These prefix bytes are all used in official secp256k1 documentation.

@@ -36,6 +36,4 @@ Example:

```javascript
> var bitcore = require('bitcore');
// compressed public key starting with 0x03 (greater than midpoint of curve)
> var compressedPK = bitcore.PublicKey('030589ee559348bd6a7325994f9c8eff12bd'+
> var compressedPK = dashcore.PublicKey('030589ee559348bd6a7325994f9c8eff12bd'+
'5d73cc683142bd0dd1a17abc99b0dc');

@@ -45,12 +43,12 @@ > compressedPK.compressed;

> compressedPK.toAddress().toString();
'1KbUJ4x8epz6QqxkmZbTc4f79JbWWz6g37'
'XuHK8Kc2cYCgZnZLdSugTbLtyeBCaAFy6z'
// compressed public key starting with 0x02 (smaller than midpoint of curve)
> var compressedPK2 = new bitcore.PublicKey('02a1633cafcc01ebfb6d78e39f687a1f'+
> var compressedPK2 = new dashcore.PublicKey('02a1633cafcc01ebfb6d78e39f687a1f'+
'0995c62fc95f51ead10a02ee0be551b5dc');
> compressedPK2.compressed;
true
> compressedPK.toAddress().toString();
'1KbUJ4x8epz6QqxkmZbTc4f79JbWWz6g37'
> compressedPK2.toAddress().toString();
'XgzRgaSyy6yR4Vrd8s7tqoT3GYTSKGMqib'
// uncompressed public key, starting with 0x04. Contains both X and Y encoded
> var uncompressed = bitcore.PublicKey('0479BE667EF9DCBBAC55A06295CE870B07029'+
> var uncompressed = dashcore.PublicKey('0479BE667EF9DCBBAC55A06295CE870B07029'+
'BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68'+

@@ -61,3 +59,3 @@ '554199C47D08FFB10D4B8');

> uncompressed.toAddress().toString()
'1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm'
'XoyDQM3xGhFW5JqYBwTLckjqZ67Q3jZfAL'
```
# Script
All bitcoin transactions have scripts embedded into its inputs and outputs. The scripts use a very simple programming language, which is evaluated from left to right using a stack. The language is designed such that it guarantees all scripts will execute in a limited amount of time (it is not Turing-Complete).
All Dash transactions have scripts embedded into its inputs and outputs. The scripts use a very simple programming language, which is evaluated from left to right using a stack. The language is designed such that it guarantees all scripts will execute in a limited amount of time (it is not Turing-Complete).
When a transaction is validated, the input scripts are concatenated with the output scripts and evaluated. To be valid, all transaction scripts must evaluate to true. A good analogy for how this works is that the output scripts are puzzles that specify in which conditions can those bitcoins be spent. The input scripts provide the correct data to make those output scripts evaluate to true.
When a transaction is validated, the input scripts are concatenated with the output scripts and evaluated. To be valid, all transaction scripts must evaluate to true. A good analogy for how this works is that the output scripts are puzzles that specify in which conditions can those funds be spent. The input scripts provide the correct data to make those output scripts evaluate to true.
For more detailed information about the bitcoin scripting language, check the online reference [on bitcoin's wiki](https://en.bitcoin.it/wiki/Script).
For more detailed information about the Dash scripting language, check the online reference [on bitcoin's wiki](https://en.bitcoin.it/wiki/Script).
The `Script` object provides an interface to construct, parse, and identify bitcoin scripts. It also gives simple interfaces to create most common script types. This class is useful if you want to create custom input or output scripts. In other case, you should probably use `Transaction`.
The `Script` object provides an interface to construct, parse, and identify Dash scripts. It also gives simple interfaces to create most common script types. This class is useful if you want to create custom input or output scripts. In other case, you should probably use `Transaction`.

@@ -14,9 +14,9 @@ ## Script creation

### Pay to Public Key Hash (p2pkh)
This is the most commonly used transaction output script. It's used to pay to a bitcoin address (a bitcoin address is a public key hash encoded in base58check)
This is the most commonly used transaction output script. It's used to pay to a Dash address (a Dash address is a public key hash encoded in base58check)
```javascript
// create a new p2pkh paying to a specific address
var address = Address.fromString('1NaTVwXDDUJaXDQajoa9MqHhz4uTxtgK14');
var address = Address.fromString('XuUGDZHrKLo841CyamDbG5W7n59epA71h2');
var script = Script.buildPublicKeyHashOut(address);
assert(script.toString() === 'OP_DUP OP_HASH160 20 0xecae7d092947b7ee4998e254aa48900d26d2ce1d OP_EQUALVERIFY OP_CHECKSIG');
assert(script.toString() === 'OP_DUP OP_HASH160 089acaba6af8b2b4fb4bed3b747ab1e4e60b4965 OP_EQUALVERIFY OP_CHECKSIG');
```

@@ -35,3 +35,3 @@

### Pay to Multisig (p2ms)
Multisig outputs allow to share control of bitcoins between several keys. When creating the script, one specifies the public keys that control the funds, and how many of those keys are required to sign off spending transactions to be valid. An output with N public keys of which M are required is called an m-of-n output (For example, 2-of-3, 3-of-5, 4-of-4, etc.)
Multisig outputs allow to share control of some funds between several keys. When creating the script, one specifies the public keys that control the funds, and how many of those keys are required to sign off spending transactions to be valid. An output with N public keys of which M are required is called an m-of-n output (For example, 2-of-3, 3-of-5, 4-of-4, etc.)

@@ -55,3 +55,3 @@ Note that regular multisig outputs are rarely used nowadays. The best practice is to use a p2sh multisig output (See Script#toScriptHashOut()).

### Pay to Script Hash (p2sh)
Pay to script hash outputs are scripts that contain the hash of another script, called `redeemScript`. To spend bitcoins sent in a p2sh output, the spending transaction must provide a script matching the script hash and data which makes the script evaluate to true. This allows to defer revealing the spending conditions to the moment of spending. It also makes it possible for the receiver to set the conditions to spend those bitcoins.
Pay to script hash outputs are scripts that contain the hash of another script, called `redeemScript`. To spend funds sent in a p2sh output, the spending transaction must provide a script matching the script hash and data which makes the script evaluate to true. This allows to defer revealing the spending conditions to the moment of spending. It also makes it possible for the receiver to set the conditions to spend those funds.

@@ -95,3 +95,3 @@ Most multisig transactions today use p2sh outputs where the `redeemScript` is a multisig output.

## Script Parsing and Identification
`Script` has an easy interface to parse raw scripts from the network or bitcoind, and to extract useful information. An illustrative example (for more options check the API reference)
`Script` has an easy interface to parse raw scripts from the network or dashd, and to extract useful information. An illustrative example (for more options check the API reference)

@@ -110,3 +110,3 @@ ```javascript

## Script Interpreting and Validation
To validate a transaction, the bitcoin network validates all of its inputs and outputs. To validate an input, the input's script is concatenated with the referenced output script, and the result is executed. If at the end of execution the stack contains a 'true' value, then the transaction is valid. You can do this in `bitcore` by using the `Interpreter` class. The entry point (and probably the only interface you'll need for most applications) is the method `Interpreter#verify()`.
To validate a transaction, the Dash network validates all of its inputs and outputs. To validate an input, the input's script is concatenated with the referenced output script, and the result is executed. If at the end of execution the stack contains a 'true' value, then the transaction is valid. You can do this in `dashcore` by using the `Interpreter` class. The entry point (and probably the only interface you'll need for most applications) is the method `Interpreter#verify()`.

@@ -113,0 +113,0 @@ You can use it like this:

# Transaction
Bitcore provides a very simple API for creating transactions. We expect this API to be accessible for developers without knowing the working internals of bitcoin in deep detail. What follows is a small introduction to transactions with some basic knowledge required to use this API.
Dashcore provides a very simple API for creating transactions. We expect this API to be accessible for developers without knowing the working internals of Dash in deep detail. What follows is a small introduction to transactions with some basic knowledge required to use this API.
A Transaction contains a set of inputs and a set of outputs. Each input contains a reference to another transaction's output, and a signature that allows the value referenced in that output to be used in this transaction.
Note also that an output can be used only once. That's why there's a concept of "change address" in the bitcoin ecosystem: if an output of 10 BTC is available for me to spend, but I only need to transmit 1 BTC, I'll create a transaction with two outputs, one with 1 BTC that I want to spend, and the other with 9 BTC to a change address, so I can spend this 9 BTC with another private key that I own.
Note also that an output can be used only once. That's why there's a concept of "change address" in the Dash ecosystem: if an output of 10 DASH is available for me to spend, but I only need to transmit 1 DASH, I'll create a transaction with two outputs, one with 1 DASH that I want to spend, and the other with 9 DASH to a change address, so I can spend this 9 DASH with another private key that I own.

@@ -15,3 +15,3 @@ So, in order to transmit a valid transaction, you must know what other transactions on the network store outputs that have not been spent and that are available for you to spend (meaning that you have the set of keys that can validate you own those funds). The unspent outputs are usually referred to as "utxo"s.

.from(utxos) // Feed information about what unspent 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 satoshi
.change(address) // Sets up a change address where the rest of the funds will go

@@ -23,6 +23,6 @@ .sign(privkeySet) // Signs all the inputs it can

Now, this could just be serialized to hexadecimal ASCII values (`transaction.serialize()`) and sent over to the bitcoind reference client.
Now, this could just be serialized to hexadecimal ASCII values (`transaction.serialize()`) and sent over to the dashd reference client.
```bash
bitcoin-cli sendrawtransaction <serialized transaction>
dash-cli sendrawtransaction <serialized transaction>
```

@@ -34,3 +34,3 @@

var transaction = new Transaction().fee(5430); // Minimum non-dust amount
var transaction = new Transaction().fee(1e8); // Generous fee of 1 BTC
var transaction = new Transaction().fee(1e8); // Generous fee of 1 DASH
```

@@ -81,5 +81,5 @@

## Adding inputs
Transaction inputs are instances of either [Input](https://github.com/bitpay/bitcore/tree/master/lib/transaction/input) or its subclasses. `Input` has some abstract methods, as there is no actual concept of a "signed input" in the bitcoin scripting system (just valid signatures for <tt>OP_CHECKSIG</tt> and similar opcodes). They are stored in the `input` property of `Transaction` instances.
Transaction inputs are instances of either [Input](lib/transaction/input) or its subclasses. `Input` has some abstract methods, as there is no actual concept of a "signed input" in the Dash scripting system (just valid signatures for <tt>OP_CHECKSIG</tt> and similar opcodes). They are stored in the `input` property of `Transaction` instances.
Bitcore contains two implementations of `Input`, one for spending _Pay to Public Key Hash_ outputs (called `PublicKeyHashInput`) and another to spend _Pay to Script Hash_ outputs for which the redeem script is a Multisig script (called `MultisigScriptHashInput`).
Dashcore contains two implementations of `Input`, one for spending _Pay to Public Key Hash_ outputs (called `PublicKeyHashInput`) and another to spend _Pay to Script Hash_ outputs for which the redeem script is a Multisig script (called `MultisigScriptHashInput`).

@@ -90,3 +90,3 @@ All inputs have the following five properties:

- `sequenceNumber`: a `number`, the sequence number, see [bitcoin's developer guide on nLockTime and the sequence number](https://bitcoin.org/en/developer-guide#locktime-and-sequence-number).
- `script`: the `Script` instance for this input. Usually called `scriptSig` in the bitcoin community.
- `script`: the `Script` instance for this input. Usually called `scriptSig` in the Dash community.
- `output`: if available, a `Output` instance of the output associated with this input.

@@ -102,3 +102,3 @@

- `addInput`: Performs a series of checks on an input and appends it to the end of the `input` vector and updates the amount of incoming bitcoins of the transaction.
- `addInput`: Performs a series of checks on an input and appends it to the end of the `input` vector and updates the amount of incoming funds of the transaction.
- `uncheckedAddInput`: adds an input to the end of the `input` vector and updates the `inputAmount` without performing any checks.

@@ -141,7 +141,7 @@

- `inspect`: Returns a string with some information about the transaction (currently a string formatted as `<Transaction 000...000>`, that only shows the serialized value of the transaction.
- `toBuffer`: Serializes the transaction for sending over the wire in the bitcoin network
- `toBuffer`: Serializes the transaction for sending over the wire in the Dash network
- `toBufferWriter`: Uses an already existing BufferWriter to copy over the serialized transaction
## Serialization Checks
When serializing, the bitcore library performs a series of checks. These can be disabled by providing an object to the `serialize` method with the checks that you'll like to skip.
When serializing, the dashcore library performs a series of checks. These can be disabled by providing an object to the `serialize` method with the checks that you'll like to skip.
- `disableLargeFees` avoids checking that the fee is no more than `Transaction.FEE_PER_KB * Transaction.FEE_SECURITY_MARGIN * size_in_kb`.

@@ -153,3 +153,3 @@ - `disableSmallFees` avoids checking that the fee is less than `Transaction.FEE_PER_KB * size_in_kb / Transaction.FEE_SECURITY_MARGIN`.

These are the current default values in the bitcore library involved on these checks:
These are the current default values in the dashcore library involved on these checks:
- `Transaction.FEE_PER_KB`: `10000` (satoshis per kilobyte)

@@ -160,4 +160,6 @@ - `Transaction.FEE_SECURITY_MARGIN`: `15`

## Fee calculation
When outputs' value don't sum up to the same amount that inputs, the difference in bitcoins goes to the miner of the block that includes this transaction. The concept of a "change address" usually is associated with this: an output with an address that can be spent by the creator of the transaction.
When the sum of the outputs' value doesn't add up to the sum of the inputs' value, the difference is given to the miner of the block that includes this transaction as a "mining fee".
When outputs' value don't sum up to the same amount that inputs, the difference in funds goes to the miner of the block that includes this transaction. The concept of a "change address" usually is associated with this: an output with an address that can be spent by the creator of the transaction.
For this reason, some methods in the Transaction class are provided:

@@ -171,5 +173,5 @@ - `change(address)`: Set up the change address. This will set an internal `_changeScript` property that will store the change script associated with that address.

## Time-Locking transaction
All bitcoin transactions contain a locktime field. The locktime indicates the earliest time a transaction can be added to the blockchain. Locktime allows signers to create time-locked transactions which will only become valid in the future, giving the signers a chance to change their minds. Locktime can be set in the form of a bitcoin block height (the transaction can only be included in a block with a higher height than specified) or a linux timestamp (transaction can only be confirmed after that time). For more information see [bitcoin's development guide section on locktime](https://bitcoin.org/en/developer-guide#locktime-and-sequence-number).
All Dash transactions contain a locktime field. The locktime indicates the earliest time a transaction can be added to the blockchain. Locktime allows signers to create time-locked transactions which will only become valid in the future, giving the signers a chance to change their minds. Locktime can be set in the form of a Dash block height (the transaction can only be included in a block with a higher height than specified) or a linux timestamp (transaction can only be confirmed after that time). For more information see [bitcoin's development guide section on locktime](https://bitcoin.org/en/developer-guide#locktime-and-sequence-number).
In bitcore, you can set a `Transaction`'s locktime by using the methods `Transaction#lockUntilDate` and `Transaction#lockUntilBlockHeight`. You can also get a friendly version of the locktime field via `Transaction#getLockTime`;
In dashcore, you can set a `Transaction`'s locktime by using the methods `Transaction#lockUntilDate` and `Transaction#lockUntilBlockHeight`. You can also get a friendly version of the locktime field via `Transaction#getLockTime`;

@@ -187,2 +189,2 @@ For example:

## Upcoming changes
We're debating an API for Merge Avoidance, CoinJoin, Smart contracts, CoinSwap, and Stealth Addresses. We're expecting to have all of them by some time in 2015. Payment channel creation is available in the [bitcore-channel](https://github.com/bitpay/bitcore-channel) module.
We're debating an API for Merge Avoidance, CoinJoin, Smart contracts, CoinSwap, and Stealth Addresses. We're expecting to have all of them by some time in 2015. Payment channel creation is available in the [dashcore-channel](https://github.com/dashevo/dashcore-channel) module.
# Unit
Unit is a utility for handling and converting bitcoin units. We strongly recommend to always use satoshis to represent amount inside your application and only convert them to other units in the front-end.
Unit is a utility for handling and converting Dash units. We strongly recommend to always use satoshis to represent amount inside your application and only convert them to other units in the front-end.

@@ -9,4 +9,3 @@ To understand the need of using the `Unit` class when dealing with unit conversions, see this example:

8198999.999999999
> var bitcore = require('bitcore');
> var Unit = bitcore.Unit;
> var Unit = dashcore.Unit;
> Unit.fromMilis(81.99).toSatoshis() // correct

@@ -13,0 +12,0 @@ 8199000

# UnspentOutput
`bitcore.Transaction.UnspentOutput` is a class with stateless instances that provides information about an unspent output:
`dashcore.Transaction.UnspentOutput` is a class with stateless instances that provides information about an unspent output:
- Transaction ID and output index

@@ -19,15 +19,15 @@ - The "scriptPubKey", the script included in the output

var utxo = new UnspentOutput({
"txid" : "a0a08e397203df68392ee95b3f08b0b3b3e2401410a38d46ae0874f74846f2e9",
"txid" : "3912bd2b0c78706db809fff3ab51ac81ef20e0a53f61e4a2369cff0c4084c55c",
"vout" : 0,
"address" : "mgJT8iegL4f9NCgQFeFyfvnSw1Yj4M5Woi",
"scriptPubKey" : "76a914089acaba6af8b2b4fb4bed3b747ab1e4e60b496588ac",
"amount" : 0.00070000
"address" : "XuUGDZHrKLo841CyamDbG5W7n59epA71h2",
"scriptPubKey" : "76a914fd1a0216dc01bc90b68b39bbe755de834be5dddd88ac",
"amount" : 4.22900307
});
var utxo = new UnspentOutput({
"txId" : "a0a08e397203df68392ee95b3f08b0b3b3e2401410a38d46ae0874f74846f2e9",
"txId" : "3912bd2b0c78706db809fff3ab51ac81ef20e0a53f61e4a2369cff0c4084c55c",
"outputIndex" : 0,
"address" : "mgJT8iegL4f9NCgQFeFyfvnSw1Yj4M5Woi",
"script" : "76a914089acaba6af8b2b4fb4bed3b747ab1e4e60b496588ac",
"satoshis" : 70000
"address" : "XuUGDZHrKLo841CyamDbG5W7n59epA71h2",
"script" : "76a914fd1a0216dc01bc90b68b39bbe755de834be5dddd88ac",
"satoshis" : 422900307
});
```

@@ -1,3 +0,3 @@

# Bitcoin URIs
Represents a bitcoin payment URI. Bitcoin URI strings became the most popular way to share payment request, sometimes as a bitcoin link and others using a QR code.
# Dash URIs
Represents a Dash payment URI. Dash URI strings is a good standard to share payment request, sometimes as a Dash link or using a QR code.

@@ -7,9 +7,9 @@ URI Examples:

```
bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu
bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2
bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2&message=Payment&label=Satoshi&extra=other-param
dash:XuUGDZHrKLo841CyamDbG5W7n59epA71h2
dash:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=1.2
dash:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=1.2&message=Payment&label=Satoshi&extra=other-param
```
## URI Validation
The main use that we expect you'll have for the `URI` class in bitcore is validating and parsing bitcoin URIs. A `URI` instance exposes the address as a bitcore `Address` object and the amount in Satoshis, if present.
The main use that we expect you'll have for the `URI` class in dashcore is validating and parsing Dash URIs. A `URI` instance exposes the address as a dashcore `Address` object and the amount in satoshis, if present.

@@ -19,3 +19,3 @@ The code for validating URIs looks like this:

```javascript
var uriString = 'bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2';
var uriString = 'dash:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=1.2';
var valid = URI.isValid(uriString);

@@ -37,8 +37,26 @@ var uri = new URI(uriString);

```javascript
var uriString = new URI({
address: '12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu',
var uri = new URI({
address: 'XuUGDZHrKLo841CyamDbG5W7n59epA71h2',
amount : 10000, // in satoshis
message: 'My payment request'
});
var uriString = uri.toString();
console.log(uri.toString()) //dash:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=0.0001&message=My%20payment%20request
```
Methods `toObject`, `toJSON` and `inspect` remain available.
## fromString
```
var uri = new URI("dash:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=0.0001&message=My%20payment%20request>")
```
## fromObject
```
var uri = new URI({
address:"XuUGDZHrKLo841CyamDbG5W7n59epA71h2",
amount:"10000",
message:"My payment request"
})
```

@@ -9,4 +9,4 @@ 'use strict';

if (version !== undefined) {
var message = 'More than one instance of bitcore-lib found. ' +
'Please make sure that you are not mixing instances of classes of the different versions of bitcore.';
var message = 'More than one instance of dashcore-lib found. ' +
'Please make sure that you are not mixing instances of classes of the different versions of dashcore.';
console.warn(message);

@@ -13,0 +13,0 @@ }

'use strict';
var path = require('path')
// karma.conf.js
module.exports = function(config) {
var src = './index.js',
tests = './test.spec.js';
config.set({
browsers: ['Firefox'],
frameworks: ['mocha', 'detectBrowsers'],
detectBrowsers: {
enabled: true,
usePhantomJS: false,
postDetection: function(availableBrowser) {
// modify to enable additional browsers if available
var runBrowsers = ['Firefox', 'Chrome'];
var browsers = [];
for(var i = 0; i < runBrowsers.length; i++) {
if(~availableBrowser.indexOf(runBrowsers[i])) {
browsers.push(runBrowsers[i]);
}
}
return browsers;
}
var karmaConfig = {
frameworks: ['mocha', 'chai'],
files: [
src,
tests
],
preprocessors: {},
webpack: {
node: {
fs: 'empty',
},
singleRun: true,
files: [
'tests.js'
],
plugins: [
'karma-mocha',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-detect-browsers'
]
});
module: {
rules: [
{ test: /\.json$/, use: "json-loader" },
{ test: /\.dat$/, use: "raw-loader" },
{ enforce:'post', loader: "transform-loader?brfs" },
],
},
},
reporters: ['mocha'],
port: 9876,
colors: true,
autoWatch: false,
browsers: ['Chrome', 'Firefox'],
singleRun: false,
concurrency: Infinity,
plugins: [
'karma-mocha',
'karma-mocha-reporter',
'karma-chai',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-webpack'
]
};
karmaConfig.preprocessors[src] = ['webpack'];
karmaConfig.preprocessors[tests] = ['webpack'];
// karma.conf.js
module.exports = function(config) {
config.set(karmaConfig);
};

@@ -66,3 +66,4 @@ 'use strict';

Point.prototype._getX = Point.prototype.getX;
if (!Point.prototype._getX)
Point.prototype._getX = Point.prototype.getX;

@@ -79,3 +80,4 @@ /**

Point.prototype._getY = Point.prototype.getY;
if (!Point.prototype._getY)
Point.prototype._getY = Point.prototype.getY;

@@ -82,0 +84,0 @@ /**

@@ -98,9 +98,9 @@ 'use strict';

Proposal.prototype.fromBufferReader = function(reader) {
$.checkArgument(!reader.finished(), 'No data received');
$.checkArgument(!reader.finished(), 'No data received');
var dataHex = reader.read(reader.buf.length);
var object = JSON.parse(dataHex.toString('utf8'));
var dataHex = reader.read(reader.buf.length);
var object = JSON.parse(dataHex.toString('utf8'));
if(object.constructor.name === 'Array'){
this.type = object[0][0];
this.end_epoch = object[0][1].end_epoch;

@@ -113,4 +113,7 @@ this.name = object[0][1].name;

this.url = object[0][1].url;
}
else if(object.constructor.name==='Object') _.merge(this, object)
else throw new Error('Invalid proposal')
return this;
return this;

@@ -117,0 +120,0 @@ };

{
"name": "@dashevo/dashcore-lib",
"version": "0.15.3",
"version": "0.15.4",
"description": "A pure and powerful JavaScript Dash library.",

@@ -8,6 +8,8 @@ "author": "BitPay <dev@bitpay.com>",

"scripts": {
"lint": "gulp lint",
"test": "gulp test",
"coverage": "gulp coverage",
"build": "gulp"
"lint": "jshint . || true",
"test": "npm run build && npm run test:node && npm run test:browser && npm run lint",
"test:node": "mocha --no-timeouts --recursive",
"test:browser": "karma start ./karma.conf.js --single-run",
"coverage": "nyc mocha --recursive",
"build": "webpack --display-error-details"
},

@@ -111,10 +113,23 @@ "contributors": [

"devDependencies": {
"bitcore-build-dash": "dashevo/bitcore-build-dash",
"browserify": "latest",
"brfs": "^1.2.0",
"chai": "^1.10.0",
"gulp": "^3.8.10",
"sinon": "^1.13.0"
"jshint": "^2.9.5",
"karma": "^2.0.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-detect-browsers": "^2.2.6",
"karma-firefox-launcher": "^1.1.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-webpack": "^3.0.0",
"mocha": "^5.0.4",
"nyc": "^11.6.0",
"raw-loader": "^0.5.1",
"sinon": "^4.2.2",
"transform-loader": "^0.2.4",
"uglifyjs-webpack-plugin": "^1.2.4",
"webpack": "^3.10.0"
},
"license": "MIT"
}

@@ -1,7 +0,7 @@

Bitcore-Dash Library
=======
Dashcore Library
================
[![NPM Package](https://img.shields.io/npm/v/bitcore-lib-dash.svg?style=flat-square)](https://www.npmjs.org/package/bitcore-lib-dash)
[![Build Status](https://img.shields.io/travis/dashpay/bitcore-lib-dash.svg?branch=master&style=flat-square)](https://travis-ci.org/dashpay/bitcore-lib-dash)
[![Coverage Status](https://img.shields.io/coveralls/dashpay/bitcore-lib-dash.svg?style=flat-square)](https://coveralls.io/github/dashpay/bitcore-lib-dash?branch=master)
[![NPM Package](https://img.shields.io/npm/v/@dashevo/dashcore-lib.svg?style=flat-square)](https://www.npmjs.org/package/@dashevo/dashcore-lib)
[![Build Status](https://img.shields.io/travis/dashevo/dashcore-lib.svg?branch=master&style=flat-square)](https://travis-ci.org/dashevo/dashcore-lib)
[![Coverage Status](https://img.shields.io/coveralls/dashevo/dashcore-lib.svg?style=flat-square)](https://coveralls.io/github/dashevo/dashcore-lib?branch=master)

@@ -15,67 +15,86 @@ A pure and powerful JavaScript Dash library.

## Get Started
### NodeJS
```
npm install bitcore-lib-dash
npm install dashcore-lib
```
```
bower install bitcore-lib-dash
```
### Browser
## Documentation
See the section below to generate your own bundle, or download the pre-generated [minified file](dist/dashcore-lib.min.js)
The complete docs are hosted here: [bitcore documentation](http://bitcore.io/guide/). There's also a [bitcore API reference](http://bitcore.io/api/) available generated from the JSDocs of the project, where you'll find low-level details on each bitcore utility.
- [Read the Developer Guide](http://bitcore.io/guide/)
- [Read the API Reference](http://bitcore.io/api/)
## Docs
To get community assistance and ask for help with implementation questions, please use our [community forums](https://forum.bitcore.io/).
* [Addresses](address.md)
* [Block](block.md)
* [Crypto](crypto.md)
* [Encoding](encoding.md)
* [Hierarchically-derived Private and Public Keys](hierarchical.md)
* [Networks](docs/networks.md)
* [PrivateKey](docs/privatekey.md)
* [PublicKey](docs/publickey.md)
* [Script](docs/script.md)
* [Transaction](docs/transaction.md)
* [Using Different Units](unit.md)
* [Unspent Output](docs/upspentoutput.md)
* [URI](docs/uri.md)
* [Governance Object / Proposal](govobject/govobject.md)
## Examples
* [Generate a random address](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#generate-a-random-address)
* [Generate a address from a SHA256 hash](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#generate-a-address-from-a-sha256-hash)
* [Import an address via WIF](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#import-an-address-via-wif)
* [Create a Transaction](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#create-a-transaction)
* [Sign a Dash message](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#sign-a-bitcoin-message)
* [Verify a Dash message](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#verify-a-bitcoin-message)
* [Create an OP RETURN transaction](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#create-an-op-return-transaction)
* [Create a 2-of-3 multisig P2SH address](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#create-a-2-of-3-multisig-p2sh-address)
* [Spend from a 2-of-2 multisig P2SH address](https://github.com/dashpay/bitcore-lib-dash/blob/master/docs/examples.md#spend-from-a-2-of-2-multisig-p2sh-address)
Some examples can be find [here](docs/examples.md), below is a list of direct link for some of them.
## Security
* [Generate a random address](docs/examples.md#generate-a-random-address)
* [Generate a address from a SHA256 hash](docs/examples.md#generate-a-address-from-a-sha256-hash)
* [Import an address via WIF](docs/examples.md#import-an-address-via-wif)
* [Create a Transaction](docs/examples.md#create-a-transaction)
* [Sign a Dash message](docs/examples.md#sign-a-bitcoin-message)
* [Verify a Dash message](docs/examples.md#verify-a-bitcoin-message)
* [Create an OP RETURN transaction](docs/examples.md#create-an-op-return-transaction)
* [Create a 2-of-3 multisig P2SH address](docs/examples.md#create-a-2-of-3-multisig-p2sh-address)
* [Spend from a 2-of-2 multisig P2SH address](docs/examples.md#spend-from-a-2-of-2-multisig-p2sh-address)
We're using Bitcore in production, as are [many others](http://bitcore.io#projects), but please use common sense when doing anything related to finances! We take no responsibility for your implementation decisions.
## Modules
If you find a security issue, please email security@bitpay.com.
Some functionality is implemented as a module that can be installed separately:
* [Payment Protocol Support](https://github.com/dashevo/dashcore-payment-protocol)
* [Peer to Peer Networking](https://github.com/dashevo/dashcore-p2p)
* [Bitcoin Core JSON-RPC](https://github.com/dashevo/dashd-rpc)
* [Payment Channels](https://github.com/dashevo/dashcore-channel)
* [Mnemonics](https://github.com/dashevo/dashcore-mnemonic)
* [Elliptical Curve Integrated Encryption Scheme](https://github.com/dashevo/dashcore-ecies)
* [Signed Messages](https://github.com/dashevo/dashcore-message)
## Contributing
Please send pull requests for bug fixes, code optimization, and ideas for improvement. For more information on how to contribute, please refer to our [CONTRIBUTING](https://github.com/dashpay/bitcore-lib-dash/blob/master/CONTRIBUTING.md) file.
Please send pull requests for bug fixes, code optimization, and ideas for improvement. For more information on how to contribute, please refer to our [CONTRIBUTING](https://github.com/dashevo/dashcore-lib/blob/master/CONTRIBUTING.md) file.
## Building the Browser Bundle
To build a bitcore-lib-dash full bundle for the browser:
To build a dashcore-lib full bundle for the browser:
```sh
gulp browser
npm run build
```
This will generate files named `bitcore-lib-dash.js` and `bitcore-lib-dash.min.js`.
This will generate files named `dashcore-lib.js` and `dashcore-lib.min.js` in the `dist/` folder.
You can also use our pre-generated files, provided for each release along with a PGP signature by one of the project's maintainers. To get them, checkout a release commit (for example, https://github.com/dashpay/bitcore-lib-dash/commit/e33b6e3ba6a1e5830a079e02d949fce69ea33546 for v0.12.6).
## Usage on Browser
To verify signatures, use the following PGP keys:
- @braydonf: https://pgp.mit.edu/pks/lookup?op=get&search=0x9BBF07CAC07A276D `D909 EFE6 70B5 F6CC 89A3 607A 9BBF 07CA C07A 276D`
- @gabegattis: https://pgp.mit.edu/pks/lookup?op=get&search=0x441430987182732C `F3EA 8E28 29B4 EC93 88CB B0AA 4414 3098 7182 732C`
- @kleetus: https://pgp.mit.edu/pks/lookup?op=get&search=0x33195D27EF6BDB7F `F8B0 891C C459 C197 65C2 5043 3319 5D27 EF6B DB7F`
- @matiu: https://pgp.mit.edu/pks/lookup?op=get&search=0x9EDE6DE4DE531FAC `25CE ED88 A1B1 0CD1 12CD 4121 9EDE 6DE4 DE53 1FAC`
```
<script src='./dist/dashcore-lib.min.js' type="text/javascript"></script>
<script>
const PrivateKey = dashcore.PrivateKey;
const privateKey = new PrivateKey();
const address = privateKey.toAddress().toString();
</script>
```
## Development & Tests
```sh
git clone https://github.com/dashpay/bitcore-lib-dash
cd bitcore-lib-dash
git clone https://github.com/dashevo/dashcore-lib
cd dashcore-lib
npm install

@@ -87,13 +106,13 @@ ```

```sh
gulp test
npm test
```
You can also run just the Node.js tests with `gulp test:node`, just the browser tests with `gulp test:browser`
or create a test coverage report (you can open `coverage/lcov-report/index.html` to visualize it) with `gulp coverage`.
You can also run just the Node.js tests with `npm run test:node`, just the browser tests with `npm run test:browser`
or run a test coverage report with `npm run coverage`.
## License
Code released under [the MIT license](https://github.com/dashpay/bitcore-lib-dash/blob/master/LICENSE).
Code released under [the MIT license](LICENSE).
Copyright 2013-2017 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.
Copyright 2016-2017 The Dash Foundation, Inc.
Copyright 2016-2018 The Dash Foundation, Inc.

@@ -521,3 +521,34 @@ 'use strict';

});
it('should parse a serialised datahex proposal', function(){
var datahex1 = '5b5b2270726f706f73616c222c7b22656e645f65706f6368223a313531393834383631392c226e616d65223a226768696a6b6c6d6e6f707172737475767778797a3031323334353637383931353139303937393437222c227061796d656e745f61646472657373223a2279696b354841675641676a48316f5a4b6a63446676636632326277424e6253597a42222c227061796d656e745f616d6f756e74223a31302c2273746172745f65706f6368223a313531393039373934372c2274797065223a312c2275726c223a2268747470733a2f2f7777772e6461736863656e7472616c2e6f72672f702f746573745f70726f706f73616c5f31353139303937393437227d5d5d'
var datahex2 = '7b22656e645f65706f6368223a20313532323934373237392c20226e616d65223a2022746573742d6e617465222c20227061796d656e745f61646472657373223a20227953614559626252714e6a34504b626342397577364d50696448776f42426e687461222c20227061796d656e745f616d6f756e74223a2035352c202273746172745f65706f6368223a20313531373739393134342c202274797065223a20312c202275726c223a202268747470733a2f2f697066732e696f2f697066732f516d59374b456d4a4b707837624e4451325766444a70327a647376583141545a4b57643441584168444c4361424d227d';
var datahex2_array = '5b5b2270726f706f73616c222c7b22656e645f65706f6368223a313532323934373237392c226e616d65223a22746573742d6e617465222c227061796d656e745f61646472657373223a227953614559626252714e6a34504b626342397577364d50696448776f42426e687461222c227061796d656e745f616d6f756e74223a35352c2273746172745f65706f6368223a313531373739393134342c2274797065223a312c2275726c223a2268747470733a2f2f697066732e696f2f697066732f516d59374b456d4a4b707837624e4451325766444a70327a647376583141545a4b57643441584168444c4361424d227d5d5d';
var proposal1 = new Proposal(datahex1);
expect(proposal1.toString()).to.equal(datahex1);
expect(proposal1.type).to.equal(1);
expect(proposal1.end_epoch).to.equal(1519848619);
expect(proposal1.payment_address).to.equal('yik5HAgVAgjH1oZKjcDfvcf22bwBNbSYzB');
expect(proposal1.url).to.equal('https://www.dashcentral.org/p/test_proposal_1519097947');
var proposal2 = new Proposal(datahex2);
//We expect to be a different datahex2 as input is an object, and output will be an array (default).
expect(proposal2.toString()).to.equal(datahex2_array);
expect(proposal2.type).to.equal(1);
expect(proposal2.end_epoch).to.equal(1522947279);
expect(proposal2.payment_address).to.equal('ySaEYbbRqNj4PKbcB9uw6MPidHwoBBnhta');
expect(proposal2.url).to.equal('https://ipfs.io/ipfs/QmY7KEmJKpx7bNDQ2WfDJp2zdsvX1ATZKWd4AXAhDLCaBM');
})
it('should handle a trigger', function () {
//Todo : handle proposal and trigger object differently
var triggerDatahex1 = '5b5b2274726967676572222c207b226576656e745f626c6f636b5f686569676874223a2037393834382c20227061796d656e745f616464726573736573223a202279696b354841675641676a48316f5a4b6a63446676636632326277424e6253597a42222c20227061796d656e745f616d6f756e7473223a202231302e3030303030303030222c202270726f706f73616c5f686173686573223a202232306536396233356331353137633564373361613431623164333462353961626266333662333330626166373735663631323832643233313662666438366562222c202274797065223a20327d5d5d';
var trigger = new Proposal(triggerDatahex1);
//May be apply this test in Govobject directly and then apply the use of every new Proposal as new Govobject
// if their type is unknown (gobject list rpc call)
// expect(trigger.constructor.name).to.equal('Trigger')
})
});
var expectedHex = '5b5b2270726f706f73616c222c7b22656e645f65706f6368223a313736303035343430302c226e616d65223a225465737450726f706f73616c222c227061796d656e745f61646472657373223a22795847654e505158594658684c414e315a4b72416a787a7a426e5a324a5a4e4b6e68222c227061796d656e745f616d6f756e74223a31302c2273746172745f65706f6368223a313434343433353230302c2274797065223a312c2275726c223a22687474703a2f2f7777772e646173682e6f7267227d5d5d';

@@ -284,3 +284,3 @@ 'use strict';

var count = 0;
var stub = sandbox.stub(bitcore.crypto.BN.prototype, 'toBuffer', function(args) {
var stub = sandbox.stub(bitcore.crypto.BN.prototype, 'toBuffer').callsFake(function(args) {
// On the fourth call to the function give back an invalid private key

@@ -287,0 +287,0 @@ // otherwise use the normal behavior.

@@ -16,4 +16,4 @@ 'use strict';

should.equal(console.warn.calledOnce,true);
should.equal(console.warn.calledWith('More than one instance of bitcore-lib found. Please make sure that you are not mixing instances of classes of the different versions of bitcore.'),true)
should.equal(console.warn.calledWith('More than one instance of dashcore-lib found. Please make sure that you are not mixing instances of classes of the different versions of dashcore.'),true)
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc