@pioneer-platform/pioneer-coins 9.2.23 → 9.2.25

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.
package/lib/coins.js CHANGED
@@ -1,6 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.xpubConvert = exports.getExplorerTxUrl = exports.needsMemoByNetwork = exports.getExplorerAddressUrl = exports.getExplorerUrl = exports.segwitCoins = exports.stakingCoins = exports.baseAmountToNative = exports.nativeToBaseAmount = exports.getPrecision = exports.CURRENCY_DECIMALS = exports.PoSchains = exports.COIN_ICONS_BY_SYMBOL = exports.supportedAssets = exports.supportedBlockchains = exports.getNativeAssetForBlockchain = exports.addressNListToBIP32 = exports.bip32ToAddressNList = exports.bip32Like = exports.GET_NETWORK_NAME = exports.SLIP_44_BY_LONG = exports.COIN_MAP_KEEPKEY_LONG = exports.COIN_MAP_LONG_XCHAIN = exports.COIN_MAP_LONG = exports.COIN_MAP = exports.UTXO_COINS = exports.THORCHAIN_NETWORKS = exports.HDWALLETS = exports.parseThorchainAssetString = exports.getSwapProtocals = exports.getRangoBlockchainName = void 0;
3
+ exports.segwitCoins = exports.stakingCoins = exports.CURRENCY_DECIMALS = exports.PoSchains = exports.COIN_ICONS_BY_SYMBOL = exports.supportedAssets = exports.supportedBlockchains = exports.GET_NETWORK_NAME = exports.SLIP_44_BY_LONG = exports.COIN_MAP_KEEPKEY_LONG = exports.COIN_MAP_LONG_XCHAIN = exports.COIN_MAP_LONG = exports.COIN_MAP = exports.UTXO_COINS = exports.THORCHAIN_NETWORKS = exports.HDWALLETS = exports.parseThorchainAssetString = exports.getSwapProtocals = exports.getRangoBlockchainName = void 0;
4
+ exports.bip32Like = bip32Like;
5
+ exports.bip32ToAddressNList = bip32ToAddressNList;
6
+ exports.addressNListToBIP32 = addressNListToBIP32;
7
+ exports.getNativeAssetForBlockchain = getNativeAssetForBlockchain;
8
+ exports.getPrecision = getPrecision;
9
+ exports.nativeToBaseAmount = nativeToBaseAmount;
10
+ exports.baseAmountToNative = baseAmountToNative;
11
+ exports.getExplorerUrl = getExplorerUrl;
12
+ exports.getExplorerAddressUrl = getExplorerAddressUrl;
13
+ exports.needsMemoByNetwork = needsMemoByNetwork;
14
+ exports.getExplorerTxUrl = getExplorerTxUrl;
15
+ exports.xpubConvert = xpubConvert;
4
16
  var TAG = " | coin tools | ";
5
17
  var log = require('@pioneer-platform/loggerdog')();
6
18
  // const bitcoin = require("bitcoinjs-lib");
@@ -340,7 +352,6 @@ function bip32Like(path) {
340
352
  return true;
341
353
  return /^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(path);
342
354
  }
343
- exports.bip32Like = bip32Like;
344
355
  function bip32ToAddressNList(path) {
345
356
  if (!bip32Like(path)) {
346
357
  throw new Error("Not a bip32 path: '".concat(path, "'"));
@@ -370,11 +381,9 @@ function bip32ToAddressNList(path) {
370
381
  }
371
382
  return ret;
372
383
  }
373
- exports.bip32ToAddressNList = bip32ToAddressNList;
374
384
  function addressNListToBIP32(address) {
375
385
  return "m/".concat(address.map(function (num) { return (num >= HARDENED ? "".concat(num - HARDENED, "'") : num); }).join("/"));
376
386
  }
377
- exports.addressNListToBIP32 = addressNListToBIP32;
378
387
  function getNativeAssetForBlockchain(blockchain) {
379
388
  // @ts-ignore
380
389
  if (exports.COIN_MAP[blockchain.toLowerCase()]) {
@@ -385,7 +394,6 @@ function getNativeAssetForBlockchain(blockchain) {
385
394
  throw Error(" Unknown blockchain! " + blockchain);
386
395
  }
387
396
  }
388
- exports.getNativeAssetForBlockchain = getNativeAssetForBlockchain;
389
397
  exports.supportedBlockchains = [];
390
398
  exports.supportedAssets = [];
391
399
  exports.supportedBlockchains.push("Bitcoin", "Ethereum", "Thorchain", "Secret", "Kava", "Terra", "BinanceSmartChain", "Cardano", "Eos", "Fio", "Cosmos", "Osmosis", "Binance", "BitcoinCash", "Litecoin", "Avalanche");
@@ -597,14 +605,12 @@ function getPrecision(asset) {
597
605
  throw Error(" Unknown asset! " + asset);
598
606
  }
599
607
  }
600
- exports.getPrecision = getPrecision;
601
608
  function nativeToBaseAmount(asset, amount) {
602
609
  if (!exports.CURRENCY_DECIMALS[asset.toLowerCase()])
603
610
  throw Error("Unknown asset!");
604
611
  var output = amount / Math.pow(10, exports.CURRENCY_DECIMALS[asset.toLowerCase()]);
605
612
  return output;
606
613
  }
607
- exports.nativeToBaseAmount = nativeToBaseAmount;
608
614
  function baseAmountToNative(asset, amount) {
609
615
  if (!exports.CURRENCY_DECIMALS[asset.toLowerCase()])
610
616
  throw Error("Unknown asset!");
@@ -612,7 +618,6 @@ function baseAmountToNative(asset, amount) {
612
618
  output = parseInt(output);
613
619
  return output;
614
620
  }
615
- exports.baseAmountToNative = baseAmountToNative;
616
621
  exports.stakingCoins = ["EOS", "ATOM"];
617
622
  exports.segwitCoins = ["Bitcoin", "Testnet", "BitcoinGold", "Litecoin"];
618
623
  function getExplorerUrl(network, token, testnet) {
@@ -660,7 +665,6 @@ function getExplorerUrl(network, token, testnet) {
660
665
  return href;
661
666
  }
662
667
  }
663
- exports.getExplorerUrl = getExplorerUrl;
664
668
  function getExplorerAddressUrl(address, network, token, testnet) {
665
669
  if (testnet) {
666
670
  var href = void 0;
@@ -700,7 +704,6 @@ function getExplorerAddressUrl(address, network, token, testnet) {
700
704
  return href;
701
705
  }
702
706
  }
703
- exports.getExplorerAddressUrl = getExplorerAddressUrl;
704
707
  function needsMemoByNetwork(network) {
705
708
  var needsMemo = false;
706
709
  switch (network) {
@@ -716,7 +719,6 @@ function needsMemoByNetwork(network) {
716
719
  }
717
720
  return needsMemo;
718
721
  }
719
- exports.needsMemoByNetwork = needsMemoByNetwork;
720
722
  function getExplorerTxUrl(network, txid, testnet) {
721
723
  if (testnet) {
722
724
  var href = void 0;
@@ -762,7 +764,6 @@ function getExplorerTxUrl(network, txid, testnet) {
762
764
  return href;
763
765
  }
764
766
  }
765
- exports.getExplorerTxUrl = getExplorerTxUrl;
766
767
  // All known xpub formats
767
768
  var prefixes = new Map([
768
769
  ['xpub', '0488b21e'],
@@ -793,4 +794,3 @@ function xpubConvert(xpub, target) {
793
794
  data = Buffer.concat([Buffer.from(prefixes.get(target), 'hex'), data]);
794
795
  return b58.encode(data);
795
796
  }
796
- exports.xpubConvert = xpubConvert;
package/lib/paths.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPaths = exports.createPath = exports.blockchains = void 0;
3
+ exports.blockchains = void 0;
4
+ exports.createPath = createPath;
5
+ exports.getPaths = getPaths;
4
6
  var log = require('@pioneer-platform/loggerdog')();
5
7
  exports.blockchains = [
6
8
  // 'eip155:42161',
@@ -48,7 +50,6 @@ function createPath(entry) {
48
50
  catch (e) {
49
51
  }
50
52
  }
51
- exports.createPath = createPath;
52
53
  function getPaths(blockchains, isTestnet) {
53
54
  var output = [];
54
55
  if (!blockchains)
@@ -71,7 +72,7 @@ function getPaths(blockchains, isTestnet) {
71
72
  else {
72
73
  //legacy bip44
73
74
  output.push({
74
- note: "Bitcoin account 0",
75
+ note: "Bitcoin legacy account 0",
75
76
  networks: ['bip122:000000000019d6689c085ae165831e93'],
76
77
  script_type: "p2pkh",
77
78
  available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
@@ -81,10 +82,20 @@ function getPaths(blockchains, isTestnet) {
81
82
  curve: 'secp256k1',
82
83
  showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
83
84
  });
84
- //TODO non-native segwit wraped p2sh
85
+ output.push({
86
+ note: "Bitcoin account 0 Segwit (p2sh-p2wpkh) (ypub) (bip49)",
87
+ networks: ['bip122:000000000019d6689c085ae165831e93'],
88
+ script_type: "p2sh-p2wpkh",
89
+ available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
90
+ type: "ypub",
91
+ addressNList: [0x80000000 + 49, 0x80000000 + 0, 0x80000000 + 0],
92
+ addressNListMaster: [0x80000000 + 49, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
93
+ curve: 'secp256k1',
94
+ showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
95
+ });
85
96
  //bech32 bip84
86
97
  output.push({
87
- note: "Bitcoin account Native Segwit (Bech32)",
98
+ note: "Bitcoin account 0 Native Segwit (Bech32)",
88
99
  networks: ['bip122:000000000019d6689c085ae165831e93'],
89
100
  script_type: "p2wpkh", //bech32
90
101
  available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
@@ -94,6 +105,77 @@ function getPaths(blockchains, isTestnet) {
94
105
  curve: 'secp256k1',
95
106
  showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
96
107
  });
108
+ //account 1
109
+ output.push({
110
+ note: "Bitcoin legacy account 1",
111
+ networks: ['bip122:000000000019d6689c085ae165831e93'],
112
+ script_type: "p2pkh",
113
+ available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
114
+ type: "xpub",
115
+ addressNList: [0x80000000 + 44, 0x80000000 + 0, 0x80000000 + 1],
116
+ addressNListMaster: [0x80000000 + 44, 0x80000000 + 0, 0x80000000 + 1, 0, 0],
117
+ curve: 'secp256k1',
118
+ showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
119
+ });
120
+ output.push({
121
+ note: "Bitcoin account 1 Segwit (p2sh-p2wpkh) (ypub) (bip49)",
122
+ networks: ['bip122:000000000019d6689c085ae165831e93'],
123
+ script_type: "p2sh-p2wpkh",
124
+ available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
125
+ type: "ypub",
126
+ addressNList: [0x80000000 + 49, 0x80000000 + 0, 0x80000000 + 1],
127
+ addressNListMaster: [0x80000000 + 49, 0x80000000 + 0, 0x80000000 + 1, 0, 0],
128
+ curve: 'secp256k1',
129
+ showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
130
+ });
131
+ //bech32 bip84
132
+ output.push({
133
+ note: "Bitcoin account 1Native Segwit (Bech32)",
134
+ networks: ['bip122:000000000019d6689c085ae165831e93'],
135
+ script_type: "p2wpkh", //bech32
136
+ available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
137
+ type: "zpub",
138
+ addressNList: [0x80000000 + 84, 0x80000000 + 0, 0x80000000 + 1],
139
+ addressNListMaster: [0x80000000 + 84, 0x80000000 + 0, 0x80000000 + 1, 0, 0],
140
+ curve: 'secp256k1',
141
+ showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
142
+ });
143
+ //account 2
144
+ output.push({
145
+ note: "Bitcoin legacy account 2",
146
+ networks: ['bip122:000000000019d6689c085ae165831e93'],
147
+ script_type: "p2pkh",
148
+ available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
149
+ type: "xpub",
150
+ addressNList: [0x80000000 + 44, 0x80000000 + 0, 0x80000000 + 2],
151
+ addressNListMaster: [0x80000000 + 44, 0x80000000 + 0, 0x80000000 + 2, 0, 0],
152
+ curve: 'secp256k1',
153
+ showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
154
+ });
155
+ output.push({
156
+ note: "Bitcoin account 1 Segwit (p2sh-p2wpkh) (ypub) (bip49)",
157
+ networks: ['bip122:000000000019d6689c085ae165831e93'],
158
+ script_type: "p2sh-p2wpkh",
159
+ available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
160
+ type: "ypub",
161
+ addressNList: [0x80000000 + 49, 0x80000000 + 0, 0x80000000 + 2],
162
+ addressNListMaster: [0x80000000 + 49, 0x80000000 + 0, 0x80000000 + 2, 0, 0],
163
+ curve: 'secp256k1',
164
+ showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
165
+ });
166
+ //bech32 bip84
167
+ output.push({
168
+ note: "Bitcoin account 1Native Segwit (Bech32)",
169
+ networks: ['bip122:000000000019d6689c085ae165831e93'],
170
+ script_type: "p2wpkh", //bech32
171
+ available_scripts_types: ['p2pkh', 'p2sh', 'p2wpkh', 'p2sh-p2wpkh'],
172
+ type: "zpub",
173
+ addressNList: [0x80000000 + 84, 0x80000000 + 0, 0x80000000 + 2],
174
+ addressNListMaster: [0x80000000 + 84, 0x80000000 + 0, 0x80000000 + 2, 0, 0],
175
+ curve: 'secp256k1',
176
+ showDisplay: false // Not supported by TrezorConnect or Ledger, but KeepKey should do it
177
+ });
178
+ //account 0-2 parity with ShapeShift legacy
97
179
  }
98
180
  }
99
181
  if (blockchains.some(function (blockchain) { return blockchain.includes('eip155:'); })) {
@@ -320,7 +402,6 @@ function getPaths(blockchains, isTestnet) {
320
402
  }
321
403
  return output;
322
404
  }
323
- exports.getPaths = getPaths;
324
405
  // {
325
406
  // note:"",
326
407
  // type:"address",
package/lib/thorchain.js CHANGED
@@ -4,7 +4,8 @@
4
4
  ----------------------
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.parseMemo = exports.createMemo = void 0;
7
+ exports.createMemo = createMemo;
8
+ exports.parseMemo = parseMemo;
8
9
  var assetShortCodeMap = {
9
10
  'r': 'THOR.RUNE',
10
11
  'b': 'BTC.BTC',
@@ -245,7 +246,6 @@ function createMemo(tx) {
245
246
  throw new Error('Unsupported transaction type.');
246
247
  }
247
248
  }
248
- exports.createMemo = createMemo;
249
249
  // Function to parse a memo string into a transaction object
250
250
  function parseMemo(memo) {
251
251
  var parts = memo.split(':').map(function (part) {
@@ -411,4 +411,3 @@ function parseMemo(memo) {
411
411
  throw new Error("Unsupported memo type: ".concat(type));
412
412
  }
413
413
  }
414
- exports.parseMemo = parseMemo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/pioneer-coins",
3
- "version": "9.2.23",
3
+ "version": "9.2.25",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "_moduleAliases": {
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/express": "^4.17.6",
24
- "@types/node": "^13.13.50",
24
+ "@types/node": "18.19.71",
25
25
  "nodemon": "^2.0.3",
26
26
  "typescript": "^5.0.2"
27
27
  },
package/lib/networks.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Network } from "bitcoinjs-lib";
2
- export declare function getNetwork(coin: string, scriptType?: string): Network;
package/lib/networks.js DELETED
@@ -1,185 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.getNetwork = void 0;
15
- var bip32BTC = {
16
- p2sh: {
17
- bip32: {
18
- public: 0x0488b21e,
19
- private: 0x0488ade4,
20
- },
21
- },
22
- p2pkh: {
23
- bip32: {
24
- public: 0x0488b21e,
25
- private: 0x0488ade4,
26
- },
27
- },
28
- "p2sh-p2wpkh": {
29
- bip32: {
30
- public: 0x049d7cb2,
31
- private: 0x049d7878,
32
- },
33
- },
34
- p2wpkh: {
35
- bip32: {
36
- public: 0x04b24746,
37
- private: 0x04b2430c,
38
- },
39
- },
40
- };
41
- var networks = {
42
- bitcoin: __assign({ base: {
43
- messagePrefix: "\x18Bitcoin Signed Message:\n",
44
- bech32: "bc",
45
- pubKeyHash: 0x00,
46
- scriptHash: 0x05,
47
- wif: 0x80,
48
- } }, bip32BTC),
49
- dash: {
50
- base: {
51
- messagePrefix: "unused",
52
- bech32: "",
53
- pubKeyHash: 0x4c,
54
- scriptHash: 0x10,
55
- wif: 0xcc,
56
- },
57
- p2sh: bip32BTC.p2sh,
58
- p2pkh: bip32BTC.p2pkh,
59
- },
60
- digibyte: __assign({ base: {
61
- messagePrefix: "\x19Digibyte Signed Message:\n",
62
- bech32: "dgb",
63
- pubKeyHash: 0x1e,
64
- scriptHash: 0x3f,
65
- wif: 0x80,
66
- } }, bip32BTC),
67
- dogecoin: {
68
- base: {
69
- messagePrefix: "\x19Dogecoin Signed Message:\n",
70
- bech32: "",
71
- pubKeyHash: 0x1e,
72
- scriptHash: 0x16,
73
- wif: 0x9e,
74
- },
75
- p2sh: {
76
- bip32: {
77
- public: 0x02facafd,
78
- private: 0x02fac398,
79
- },
80
- },
81
- p2pkh: {
82
- bip32: {
83
- public: 0x02facafd,
84
- private: 0x02fac398,
85
- },
86
- },
87
- },
88
- litecoin: {
89
- base: {
90
- messagePrefix: "\x19Litecoin Signed Message:\n",
91
- bech32: "ltc",
92
- pubKeyHash: 0x30,
93
- scriptHash: 0x32,
94
- wif: 0xb0,
95
- },
96
- p2sh: {
97
- bip32: {
98
- public: 0x019da462,
99
- private: 0x019d9cfe,
100
- },
101
- },
102
- p2pkh: {
103
- bip32: {
104
- public: 0x019da462,
105
- private: 0x019d9cfe,
106
- },
107
- },
108
- "p2sh-p2wpkh": {
109
- bip32: {
110
- public: 0x01b26ef6,
111
- private: 0x01b26792,
112
- },
113
- },
114
- p2wpkh: bip32BTC.p2wpkh,
115
- },
116
- testnet: {
117
- base: {
118
- messagePrefix: "\x18Bitcoin Signed Message:\n",
119
- bech32: "tb",
120
- pubKeyHash: 0x6f,
121
- scriptHash: 0xc4,
122
- wif: 0xef,
123
- },
124
- p2sh: {
125
- bip32: {
126
- public: 0x043587cf,
127
- private: 0x04358394,
128
- },
129
- },
130
- p2pkh: {
131
- bip32: {
132
- public: 0x043587cf,
133
- private: 0x04358394,
134
- },
135
- },
136
- "p2sh-p2wpkh": {
137
- bip32: {
138
- public: 0x044a5262,
139
- private: 0x044a4e28,
140
- },
141
- },
142
- p2wpkh: {
143
- bip32: {
144
- public: 0x045f1cf6,
145
- private: 0x045f18bc,
146
- },
147
- },
148
- },
149
- };
150
- function getNetwork(coin, scriptType) {
151
- coin = coin.toLowerCase();
152
- var network;
153
- switch (coin) {
154
- case "dash":
155
- case "digibyte":
156
- case "dogecoin":
157
- case "litecoin":
158
- case "testnet":
159
- //HACK dont use "xpub" native formats
160
- //TODO handle all
161
- network = networks[coin];
162
- break;
163
- case "bitcoin":
164
- //TODO: all below are missing network data
165
- case "bitcoincash":
166
- case "cosmos":
167
- case "binance":
168
- case "ethereum":
169
- case "eos":
170
- case "cosmos":
171
- case "binance":
172
- case "fio":
173
- network = networks["bitcoin"];
174
- break;
175
- default:
176
- throw new Error("".concat(coin, " network not supported"));
177
- }
178
- // @ts-ignore
179
- var bip32 = network[scriptType || "p2sh"];
180
- if (!bip32) {
181
- throw new Error("".concat(scriptType, " not supported for ").concat(coin, " network"));
182
- }
183
- return __assign(__assign({}, network.base), bip32);
184
- }
185
- exports.getNetwork = getNetwork;