# j-bsv

> BitcoinSV Custodial & non-Custodial Wallets

Latest version **1.0.1** (published 2024-02-09) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install j-bsv
pnpm add j-bsv
yarn add j-bsv
bun add j-bsv
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-02-09 |
| First published | 2024-02-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 52.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | yfbsei |
| Maintainers | yfbsei |
| Keywords | secp256k1, secp, secp256, elliptic, elliptic curve, curve, signature, ecc, TTS, BSV, sig, bip0340, bip340, bitcoin, bip, ecdsa, endomorphism, cryptography, security, yfbsei, Jamallo, Threshold signature |

## Links

- npm: https://www.npmjs.com/package/j-bsv
- Repository: https://github.com/yfbsei/J-BSV
- Homepage: https://github.com/yfbsei/J-BSV#readme
- Issues: https://github.com/yfbsei/J-BSV/issues
- npm.io page: https://npm.io/package/j-bsv

## Dependencies (4)

- [bn.js](https://npm.io/package/bn.js.md) ^5.2.1
- [base58-js](https://npm.io/package/base58-js.md) ^1.0.4
- [@noble/secp256k1](https://npm.io/package/@noble/secp256k1.md) ^1.6.3
- [bigint-conversion](https://npm.io/package/bigint-conversion.md) ^2.2.2

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2024-02-09

## README

# J-BSV
BitcoinSV Custodial &amp; non-Custodial Wallets | Threshold signature

## Getting started
`npm i j-bsv`
\
\
`import { Custodial_Wallet, Non_Custodial_Wallet } from 'j-bsv';`

## Custodial Wallet

### Generate wallet
Master wallet(HD)
\
`const [mnemonic, wallet] = Custodial_Wallet.fromRandom('main'); // main network`
\
`const [mnemonic, wallet] = Custodial_Wallet.fromRandom('test'); // test network`

### Import from mnemonic
```
const 
    mnemonic = "teach scatter sample solar casino festival decrease pause random drip memory mystery",
    wallet = Custodial_Wallet.fromMnemonic('main', mnemonic);
```

### Import from seed
```
const 
    seed = "000102030405060708090a0b0c0d0e0f",
    wallet = Custodial_Wallet.fromSeed('main', seed);
```

### Password
```
const [mnemonic, wallet] = Custodial_Wallet.fromRandom('main', 'password123');
// ...
const wallet = Custodial_Wallet.fromMnemonic('main', mnemonic, 'password123');
// Incorrect password returns random wallet
```

### Derive child 
`wallet.derive("m/0", 'pri');`
\
\
Public Keys can't derive from a hardend path \
`wallet.derive("m/0'", 'pub'); // Throws Error`

### Signature
sign
\
`const {sig, serialized_sig, msgHash, recovery_id} = wallet.sign('hello world');`

verfiy siganture
\
`wallet.verifySig(sig, msgHash); // true`


## Non-Custodial Wallet

### Generate wallet
`const wallet = Non_Custodial_Wallet.fromRandom("main", 3, 2); // main network`
\
`const wallet = Non_Custodial_Wallet.fromRandom("test", 3, 2); // test network`

### Import from shares
```
const shares = [
    '79479395a59a8e9d930f2b10ccd5ac3671b0ff0bf8a66aaa1d74978c5353694b',
    '98510126c920e18b148130ac1145686cb299d21f0e010b98ede44169a7bb1c13',
    'b75a6eb7eca7347895f3364755b524a2f382a532235bac87be53eb46fc22cedb'
  ]

const wallet = Non_Custodial_Wallet.fromShares("main", shares, 2);
```

### Shares
`const share_for_each_participant = wallet.getShares();`

### Restore private key
`const groups_prikey = wallet.restore_pri_key();`

### Signature
sign
\
`const { sig, serialized_sig, msgHash, recovery_id } = wallet.sign("hello world");`

verfiy siganture
\
`wallet.verifySig(sig, msgHash); // true`

---
_Source: https://npm.io/package/j-bsv · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
