# Libnexajs

**This library is a fork of Bitcore Lib Cash library with changes to make it work for Nexa project. The library still in development, don't use it in production!**

# Libnexa Javascript library

## Principles

Nexa is another powerful peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Nexa network allows for highly resilient nexa infrastructure, and the developer community needs reliable, open-source tools to implement nexa apps and services.

## Get Started

```sh
npm i libnexa-js
```

Adding libnexa-js to your app's `package.json`:

```json
"dependencies": {
    "libnexa-js": "^1.0.0",
    ...
}
```

## Documentation

The complete docs are hosted here: [libnexa-js documentation](https://nexa.gitlab.io/libnexa-js/).

## Examples

- [Generate a random address](docs/examples.md#generate-a-random-address)
- [Generate a HD masterkey using Bip39](docs/examples.md#generate-an-address-using-BIP39-mnemonic-seed)
- [Generate a address from a SHA256 hash](docs/examples.md#generate-a-address-from-a-sha256-hash)
- [Import an address via WIF (Wallet Import Format)](docs/examples.md#import-an-address-via-wif)
- [Create a Transaction](docs/examples.md#create-a-transaction)
- [Sign a Bitcoin message](docs/examples.md#sign-a-bitcoin-message)
- [Verify a Bitcoin 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)

## Building the Browser Bundle

To build libnexa full bundle for the browser:

```sh
gulp browser
```

This will generate files named `libnexa.js` and `libnexa.min.js`.

<!--
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 the [releases](https://github.com/bitpay/bitcore/blob/master/packages/bitcore-lib-cash/CHANGELOG.md).
-->

## Development

```sh
git clone https://gitlab.com/nexa/libnexa-js.git
cd libnexa-js
npm install
```

## Tests

### Install Mocha for tests

#### install as development dependency for your project

```sh
npm install --save-dev mocha
```

#### Run all the tests

```sh
npm test
```

#### Run a specific test

```sh
./node_modules/mocha/bin/mocha.js test/example.js
```

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`.

## Security

We're using libnexa in production in the Otoplo wallet, as are many others, but please use common sense when doing anything related to finances! We take no responsibility for your implementation decisions.

If you find a security issue, please email info@nexa.org

## Contributing

Feel free to open an MR and we will review it.

## License

Code released under [the MIT license](https://gitlab.com/nexa/libnexa-js/-/blob/main/LICENSE).

Copyright 2024, Maintained by Bitcoin Unlimited Developers.
