@dfns/lib-bitcoinjs 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +5 -1
  2. package/index.js +29 -3
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { DfnsApiClient } from '@dfns/sdk';
3
- import { Psbt, SignerAsync } from 'bitcoinjs-lib';
3
+ import { Network, Psbt, SignerAsync } from 'bitcoinjs-lib';
4
4
  export type DfnsWalletOptions = {
5
5
  walletId: string;
6
6
  dfnsClient: DfnsApiClient;
@@ -15,3 +15,7 @@ export declare class DfnsWallet implements SignerAsync {
15
15
  sign(hash: Buffer): Promise<Buffer>;
16
16
  SignPsbt(psbt: Psbt): Promise<Psbt>;
17
17
  }
18
+ export declare const litecoin: {
19
+ mainnet: Network;
20
+ testnet: Network;
21
+ };
package/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DfnsWallet = void 0;
3
+ exports.litecoin = exports.DfnsWallet = void 0;
4
4
  const sdk_1 = require("@dfns/sdk");
5
5
  const bitcoinjs_lib_1 = require("bitcoinjs-lib");
6
+ const compatibleNetworks = ['Bitcoin', 'BitcoinTestnet3', 'Litecoin', 'LitecoinTestnet'];
6
7
  const assertSigned = (res) => {
7
8
  if (res.status === 'Failed') {
8
9
  throw new sdk_1.DfnsError(-1, 'signing failed', res);
@@ -23,8 +24,8 @@ class DfnsWallet {
23
24
  if (res.status !== 'Active') {
24
25
  throw new sdk_1.DfnsError(-1, 'wallet not active', { walletId, status: res.status });
25
26
  }
26
- if (res.network !== 'Bitcoin' && res.network !== 'BitcoinTestnet3') {
27
- throw new sdk_1.DfnsError(-1, 'wallet is not bound to Bitcoin or BitcoinTestnet3', { walletId, network: res.network });
27
+ if (!compatibleNetworks.includes(res.network)) {
28
+ throw new sdk_1.DfnsError(-1, 'wallet is not bound to a Bitcoin compatible network', { walletId, network: res.network });
28
29
  }
29
30
  return new DfnsWallet(res, options);
30
31
  }
@@ -58,3 +59,28 @@ class DfnsWallet {
58
59
  }
59
60
  }
60
61
  exports.DfnsWallet = DfnsWallet;
62
+ /// Litecoin networks
63
+ exports.litecoin = {
64
+ mainnet: {
65
+ messagePrefix: '\x19Litecoin Signed Message:\n',
66
+ bech32: 'ltc',
67
+ bip32: {
68
+ public: 0x019da462,
69
+ private: 0x019d9cfe,
70
+ },
71
+ pubKeyHash: 0x30,
72
+ scriptHash: 0x32,
73
+ wif: 0xb0,
74
+ },
75
+ testnet: {
76
+ messagePrefix: '\x19Litecoin Signed Message:\n',
77
+ bech32: 'tltc',
78
+ bip32: {
79
+ public: 0x043587cf,
80
+ private: 0x04358394,
81
+ },
82
+ pubKeyHash: 0x6f,
83
+ scriptHash: 0xc4,
84
+ wif: 0xef,
85
+ },
86
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfns/lib-bitcoinjs",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "main": "./index.js",
5
5
  "type": "commonjs"
6
6
  }