edge-currency-plugins 3.8.0 → 3.8.1

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.
@@ -169,11 +169,20 @@ var _utils3 = require('./utils');
169
169
  obj,
170
170
  _customTokens
171
171
  ) {
172
- const { publicAddress } = obj
172
+ let publicAddress = obj.publicAddress
173
173
  if (publicAddress === '') {
174
174
  throw new Error('InvalidPublicAddressError')
175
175
  }
176
176
 
177
+ // Remove any cashaddr prefixes from the public address if they exist.
178
+ if (
179
+ _optionalChain([coinInfo, 'access', _7 => _7.prefixes, 'access', _8 => _8.cashaddr, 'optionalAccess', _9 => _9.some, 'call', _10 => _10(prefix =>
180
+ publicAddress.startsWith(`${prefix}:`)
181
+ )]) === true
182
+ ) {
183
+ publicAddress = publicAddress.split(':')[1]
184
+ }
185
+
177
186
  // TODO: validate network address
178
187
 
179
188
  const query = []
@@ -303,6 +303,14 @@ var _types3 = require('../utxobased/db/types');
303
303
 
304
304
 
305
305
 
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
306
314
 
307
315
 
308
316
 
@@ -190,7 +190,8 @@ var _utils = require('./utils');
190
190
  return _keymanager.scriptPubkeyToAddress.call(void 0, {
191
191
  scriptPubkey: args.scriptPubkey,
192
192
  addressType,
193
- coin
193
+ coin,
194
+ includeCashaddrPrefix: pluginInfo.coinInfo.includeCashaddrPrefix
194
195
  })
195
196
  },
196
197
 
@@ -62,7 +62,7 @@ const engineInfo = {
62
62
  }
63
63
  ],
64
64
  formats: ['bip44', 'bip32'],
65
- forks: [], // 'bitcoinsv' is currently disabled, so not included in the forks
65
+ forks: ['ecash'], // 'bitcoinsv' is currently disabled, so not included in the forks
66
66
  gapLimit: 10,
67
67
  feeUpdateInterval: 60000,
68
68
  defaultFeeInfo: {
@@ -21,8 +21,8 @@ const currencyInfo = {
21
21
 
22
22
  // Explorers:
23
23
  blockExplorer: 'https://blockchair.com/ecash/block/%s',
24
- addressExplorer: 'https://explorer.e.cash/address/ecash:%s',
25
- transactionExplorer: 'https://explorer.e.cash/tx/%s',
24
+ addressExplorer: 'https://blockchair.com/ecash/address/%s',
25
+ transactionExplorer: 'https://blockchair.com/ecash/tx/%s',
26
26
 
27
27
  denominations: [
28
28
  { name: 'XEC', multiplier: '100', symbol: 'e' },
@@ -65,9 +65,10 @@ const engineInfo = {
65
65
  },
66
66
  asBlockbookAddress: _cleaners.asCodec.call(void 0,
67
67
  raw => {
68
- return _cleaners.asString.call(void 0, raw).split(':')[1]
68
+ const address = _cleaners.asString.call(void 0, raw)
69
+ return address.startsWith('ecash:') ? address.split(':')[1] : address
69
70
  },
70
- address => `ecash:${address}`
71
+ address => (address.startsWith('ecash:') ? address : `ecash:${address}`)
71
72
  )
72
73
  }
73
74
 
@@ -76,6 +77,7 @@ const engineInfo = {
76
77
  segwit: false,
77
78
  sighash: _altcoinjs.Psbt.BCH_SIGHASH_ALL,
78
79
  coinType: 899,
80
+ includeCashaddrPrefix: true,
79
81
 
80
82
  prefixes: {
81
83
  messagePrefix: ['\x18Bitcoin Signed Message::\n'],
@@ -271,6 +271,7 @@ var VerifyAddressEnum; (function (VerifyAddressEnum) {
271
271
 
272
272
 
273
273
 
274
+
274
275
 
275
276
 
276
277
  function bip43PurposeNumberToTypeEnum(
@@ -612,7 +613,8 @@ const addressToScriptPubkeyInternal = (
612
613
  coin: args.coin
613
614
  }),
614
615
  _cashAddress.CashaddrTypeEnum.pubkeyhash,
615
- standardPrefixes.cashaddr
616
+ standardPrefixes.cashaddr,
617
+ args.includeCashaddrPrefix
616
618
  )
617
619
  }
618
620
  if (legacyPrefixes.cashaddr != null) {
@@ -623,7 +625,8 @@ const addressToScriptPubkeyInternal = (
623
625
  coin: args.coin
624
626
  }),
625
627
  _cashAddress.CashaddrTypeEnum.pubkeyhash,
626
- legacyPrefixes.cashaddr
628
+ legacyPrefixes.cashaddr,
629
+ args.includeCashaddrPrefix
627
630
  )
628
631
  }
629
632
  payment = _altcoinjs.payments.p2pkh
@@ -637,7 +640,8 @@ const addressToScriptPubkeyInternal = (
637
640
  coin: args.coin
638
641
  }),
639
642
  _cashAddress.CashaddrTypeEnum.scripthash,
640
- standardPrefixes.cashaddr
643
+ standardPrefixes.cashaddr,
644
+ args.includeCashaddrPrefix
641
645
  )
642
646
  }
643
647
  if (legacyPrefixes.cashaddr != null) {
@@ -648,7 +652,8 @@ const addressToScriptPubkeyInternal = (
648
652
  coin: args.coin
649
653
  }),
650
654
  _cashAddress.CashaddrTypeEnum.scripthash,
651
- legacyPrefixes.cashaddr
655
+ legacyPrefixes.cashaddr,
656
+ args.includeCashaddrPrefix
652
657
  )
653
658
  }
654
659
  payment = _altcoinjs.payments.p2sh
@@ -142,6 +142,13 @@ export interface CoinInfo {
142
142
  * addresses.
143
143
  */
144
144
  coinType: number;
145
+ /**
146
+ * Whether the currency should include its cashaddr prefix in the formatted
147
+ * addresses.
148
+ *
149
+ * Defaults to `false`.
150
+ */
151
+ includeCashaddrPrefix?: boolean;
145
152
  /**
146
153
  * Optional sighash value to be passed to AltcoinJS as the sighashType field
147
154
  * on inputs. This is primarily used by currencies that leverage it as
@@ -87,6 +87,7 @@ export interface ScriptPubkeyToAddressArgs {
87
87
  addressType: AddressTypeEnum;
88
88
  coin: string;
89
89
  redeemScript?: string;
90
+ includeCashaddrPrefix?: boolean;
90
91
  }
91
92
  export interface ScriptPubkeyToAddressReturn {
92
93
  address: string;
@@ -0,0 +1,2 @@
1
+ import { FixtureType } from '../common';
2
+ export declare const ecash: FixtureType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-plugins",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
5
5
  "homepage": "https://edge.app/",
6
6
  "repository": "https://github.com/EdgeApp/edge-currency-plugins",