# btc

## Description

The `getKeys` function generates a Bitcoin wallet address and its corresponding private key based on a given mnemonic phrase and environment (mainnet or testnet).

## Parameters

| Name       | Type   | Description                                                      |
| ---------- | ------ | ---------------------------------------------------------------- |
| `mnemonic` | string | The mnemonic phrase used to generate the wallet                  |
| `env`      | string | The environment (mainnet or testnet) used to generate the wallet |

## Response

| Name                | Type   | Description                                                                                       |
| ------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| `code`              | number | 1 if successful, 0 if there was an error                                                          |
| `result`            | object | An object containing the Bitcoin private key and address if code is 1, otherwise an error message |
| `result.privateKey` | string | The private key of the generated wallet                                                           |
| `result.address`    | string | The Bitcoin address of the generated wallet                                                       |
| `error`             | string | The error message if code is 0                                                                    |

## Example Request and Response

### Prerequisites

Before making requests with NO.AI SDK, you must have it installed.

You can install NO.AI SDK using either **`npm`** or **`yarn`**. Use the following commands to install NO.AI SDK:

```sh
npm install @nest25/wallet-lib
OR
yarn add @nest25/wallet-lib
```

### Request

Here is an example of how to make a `getKeys` request using the NO.AI SDK:

```javascript
// import Nest SDK
import { Wallet } from 'nest25/wallet-lib';

// Create a new instance of the Wallet class
const wallet = new Wallet('mainnet');
// test mnemonic for BTC mainnet (use the createWallet function to get one)
const testMnemonic = 'forest almost like horn board swamp wish wedding rough number live when';

const main = async () => {
  // get the keys for the test mnemonic
  const response = await wallet.getKeys('btc', testMnemonic);
  // log the response
  console.log(response);
};

main();

```

### Response

```sh
{
        code: 1,
        result: {
          privateKey: 'L4TDvVVhGfdeKqDYSb79b9TEQpMVsLrVTpqqXhgH7eoEyQaSvqc1',
          address: '12UfEfFeY5oBFc1z2o8y1bzVj3D5TNFaHm'
        }
}
```

## Use Cases

* **Bitcoin Wallet:** This function can be used by a cryptocurrency wallet provider to generate a Bitcoin wallet for a user based on their mnemonic phrase and the desired environment.
* **Online Merchants:** This function can be used by an online merchant to generate a Bitcoin address for receiving payments from customers on the mainnet or testnet.
