edge-currency-plugins 1.0.0-rc.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.
Files changed (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/lib/bch.js +15 -0
  4. package/lib/bsv.js +15 -0
  5. package/lib/btc.js +15 -0
  6. package/lib/common/constants.js +11 -0
  7. package/lib/common/fees/calcMinerFeePerByte.js +62 -0
  8. package/lib/common/fees/makeFees.js +182 -0
  9. package/lib/common/fees/processInfoServerFees.js +30 -0
  10. package/lib/common/fees/processMempoolSpaceFees.js +38 -0
  11. package/lib/common/plugin/makeCurrencyPlugin.js +66 -0
  12. package/lib/common/plugin/makeCurrencyTools.js +211 -0
  13. package/lib/common/plugin/makeEngineEmitter.js +102 -0
  14. package/lib/common/plugin/makeMetadata.js +99 -0
  15. package/lib/common/plugin/pluginState.js +253 -0
  16. package/lib/common/plugin/serverScores.js +328 -0
  17. package/lib/common/plugin/types.js +173 -0
  18. package/lib/common/plugin/utils.js +18 -0
  19. package/lib/common/utxobased/db/Models/ProcessorTransaction.js +122 -0
  20. package/lib/common/utxobased/db/Models/baselet.js +81 -0
  21. package/lib/common/utxobased/db/makeBaselets.js +123 -0
  22. package/lib/common/utxobased/db/makeMutex.js +17 -0
  23. package/lib/common/utxobased/db/makeProcessor.js +554 -0
  24. package/lib/common/utxobased/db/types.js +67 -0
  25. package/lib/common/utxobased/engine/await-lock.js +65 -0
  26. package/lib/common/utxobased/engine/constants.js +7 -0
  27. package/lib/common/utxobased/engine/makeServerStates.js +394 -0
  28. package/lib/common/utxobased/engine/makeUtxoEngine.js +690 -0
  29. package/lib/common/utxobased/engine/makeUtxoEngineState.js +1443 -0
  30. package/lib/common/utxobased/engine/makeUtxoWalletTools.js +216 -0
  31. package/lib/common/utxobased/engine/paymentRequest.js +102 -0
  32. package/lib/common/utxobased/engine/types.js +21 -0
  33. package/lib/common/utxobased/engine/util/defaultValidateConfirmations.js +19 -0
  34. package/lib/common/utxobased/engine/util/getOwnUtxosFromTx.js +54 -0
  35. package/lib/common/utxobased/engine/utils.js +239 -0
  36. package/lib/common/utxobased/info/all.js +67 -0
  37. package/lib/common/utxobased/info/badcoin.js +73 -0
  38. package/lib/common/utxobased/info/bitcoin.js +91 -0
  39. package/lib/common/utxobased/info/bitcoincash.js +93 -0
  40. package/lib/common/utxobased/info/bitcoincashtestnet.js +72 -0
  41. package/lib/common/utxobased/info/bitcoingold.js +85 -0
  42. package/lib/common/utxobased/info/bitcoingoldtestnet.js +71 -0
  43. package/lib/common/utxobased/info/bitcoinsv.js +76 -0
  44. package/lib/common/utxobased/info/bitcointestnet.js +81 -0
  45. package/lib/common/utxobased/info/dash.js +76 -0
  46. package/lib/common/utxobased/info/digibyte.js +76 -0
  47. package/lib/common/utxobased/info/dogecoin.js +76 -0
  48. package/lib/common/utxobased/info/eboost.js +70 -0
  49. package/lib/common/utxobased/info/feathercoin.js +76 -0
  50. package/lib/common/utxobased/info/groestlcoin.js +88 -0
  51. package/lib/common/utxobased/info/litecoin.js +82 -0
  52. package/lib/common/utxobased/info/qtum.js +67 -0
  53. package/lib/common/utxobased/info/ravencoin.js +70 -0
  54. package/lib/common/utxobased/info/scriptTemplates/bitcoincashScriptTemplates.js +56 -0
  55. package/lib/common/utxobased/info/scriptTemplates/types.js +14 -0
  56. package/lib/common/utxobased/info/smartcash.js +78 -0
  57. package/lib/common/utxobased/info/ufo.js +75 -0
  58. package/lib/common/utxobased/info/utxoPickers/dogeUtxoPicker.js +34 -0
  59. package/lib/common/utxobased/info/vertcoin.js +82 -0
  60. package/lib/common/utxobased/info/zcoin.js +72 -0
  61. package/lib/common/utxobased/keymanager/base.js +60 -0
  62. package/lib/common/utxobased/keymanager/bip69.js +31 -0
  63. package/lib/common/utxobased/keymanager/bitcoincashUtils/base32.js +88 -0
  64. package/lib/common/utxobased/keymanager/bitcoincashUtils/bn.js +210 -0
  65. package/lib/common/utxobased/keymanager/bitcoincashUtils/cashAddress.js +282 -0
  66. package/lib/common/utxobased/keymanager/cleaners.js +198 -0
  67. package/lib/common/utxobased/keymanager/coinmapper.js +12 -0
  68. package/lib/common/utxobased/keymanager/declarations/base58grscheck.d.js +1 -0
  69. package/lib/common/utxobased/keymanager/declarations/blake-hash.d.js +1 -0
  70. package/lib/common/utxobased/keymanager/declarations/bn.d.js +1 -0
  71. package/lib/common/utxobased/keymanager/declarations/bs58smartcheck.d.js +1 -0
  72. package/lib/common/utxobased/keymanager/declarations/wif-smart.d.js +1 -0
  73. package/lib/common/utxobased/keymanager/declarations/wifgrs.d.js +1 -0
  74. package/lib/common/utxobased/keymanager/keymanager.js +1214 -0
  75. package/lib/common/utxobased/keymanager/utxopicker/accumulative.js +52 -0
  76. package/lib/common/utxobased/keymanager/utxopicker/forceUseUtxo.js +59 -0
  77. package/lib/common/utxobased/keymanager/utxopicker/subtractFee.js +17 -0
  78. package/lib/common/utxobased/keymanager/utxopicker/types.js +42 -0
  79. package/lib/common/utxobased/keymanager/utxopicker/utils.js +159 -0
  80. package/lib/common/utxobased/keymanager/utxopicker.js +17 -0
  81. package/lib/common/utxobased/network/BlockBook.js +200 -0
  82. package/lib/common/utxobased/network/BlockBookAPI.js +335 -0
  83. package/lib/common/utxobased/network/Deferred.js +29 -0
  84. package/lib/common/utxobased/network/MakeSocketEmitter.js +35 -0
  85. package/lib/common/utxobased/network/Socket.js +362 -0
  86. package/lib/common/utxobased/network/nodejsWS.js +59 -0
  87. package/lib/common/utxobased/network/socketQueue.js +60 -0
  88. package/lib/common/utxobased/network/types.js +19 -0
  89. package/lib/common/utxobased/network/windowWS.js +54 -0
  90. package/lib/firo.js +15 -0
  91. package/lib/ftc.js +15 -0
  92. package/lib/index.js +19 -0
  93. package/lib/ltc.js +15 -0
  94. package/lib/src/bch.d.ts +3 -0
  95. package/lib/src/bsv.d.ts +3 -0
  96. package/lib/src/btc.d.ts +3 -0
  97. package/lib/src/common/constants.d.ts +9 -0
  98. package/lib/src/common/fees/calcMinerFeePerByte.d.ts +13 -0
  99. package/lib/src/common/fees/makeFees.d.ts +20 -0
  100. package/lib/src/common/fees/processInfoServerFees.d.ts +7 -0
  101. package/lib/src/common/fees/processMempoolSpaceFees.d.ts +13 -0
  102. package/lib/src/common/plugin/makeCurrencyPlugin.d.ts +3 -0
  103. package/lib/src/common/plugin/makeCurrencyTools.d.ts +8 -0
  104. package/lib/src/common/plugin/makeEngineEmitter.d.ts +23 -0
  105. package/lib/src/common/plugin/makeMetadata.d.ts +14 -0
  106. package/lib/src/common/plugin/pluginState.d.ts +34 -0
  107. package/lib/src/common/plugin/serverScores.d.ts +61 -0
  108. package/lib/src/common/plugin/types.d.ts +135 -0
  109. package/lib/src/common/plugin/utils.d.ts +6 -0
  110. package/lib/src/common/utxobased/db/Models/ProcessorTransaction.d.ts +16 -0
  111. package/lib/src/common/utxobased/db/Models/baselet.d.ts +28 -0
  112. package/lib/src/common/utxobased/db/makeBaselets.d.ts +33 -0
  113. package/lib/src/common/utxobased/db/makeMutex.d.ts +3 -0
  114. package/lib/src/common/utxobased/db/makeProcessor.d.ts +42 -0
  115. package/lib/src/common/utxobased/db/types.d.ts +47 -0
  116. package/lib/src/common/utxobased/engine/await-lock.d.ts +29 -0
  117. package/lib/src/common/utxobased/engine/constants.d.ts +4 -0
  118. package/lib/src/common/utxobased/engine/makeServerStates.d.ts +37 -0
  119. package/lib/src/common/utxobased/engine/makeUtxoEngine.d.ts +3 -0
  120. package/lib/src/common/utxobased/engine/makeUtxoEngineState.d.ts +108 -0
  121. package/lib/src/common/utxobased/engine/makeUtxoWalletTools.d.ts +52 -0
  122. package/lib/src/common/utxobased/engine/paymentRequest.d.ts +18 -0
  123. package/lib/src/common/utxobased/engine/types.d.ts +19 -0
  124. package/lib/src/common/utxobased/engine/util/defaultValidateConfirmations.d.ts +3 -0
  125. package/lib/src/common/utxobased/engine/util/getOwnUtxosFromTx.d.ts +4 -0
  126. package/lib/src/common/utxobased/engine/utils.d.ts +43 -0
  127. package/lib/src/common/utxobased/info/all.d.ts +22 -0
  128. package/lib/src/common/utxobased/info/badcoin.d.ts +3 -0
  129. package/lib/src/common/utxobased/info/bitcoin.d.ts +3 -0
  130. package/lib/src/common/utxobased/info/bitcoincash.d.ts +3 -0
  131. package/lib/src/common/utxobased/info/bitcoincashtestnet.d.ts +3 -0
  132. package/lib/src/common/utxobased/info/bitcoingold.d.ts +3 -0
  133. package/lib/src/common/utxobased/info/bitcoingoldtestnet.d.ts +3 -0
  134. package/lib/src/common/utxobased/info/bitcoinsv.d.ts +3 -0
  135. package/lib/src/common/utxobased/info/bitcointestnet.d.ts +6 -0
  136. package/lib/src/common/utxobased/info/dash.d.ts +3 -0
  137. package/lib/src/common/utxobased/info/digibyte.d.ts +3 -0
  138. package/lib/src/common/utxobased/info/dogecoin.d.ts +3 -0
  139. package/lib/src/common/utxobased/info/eboost.d.ts +3 -0
  140. package/lib/src/common/utxobased/info/feathercoin.d.ts +6 -0
  141. package/lib/src/common/utxobased/info/groestlcoin.d.ts +3 -0
  142. package/lib/src/common/utxobased/info/litecoin.d.ts +6 -0
  143. package/lib/src/common/utxobased/info/qtum.d.ts +3 -0
  144. package/lib/src/common/utxobased/info/ravencoin.d.ts +3 -0
  145. package/lib/src/common/utxobased/info/scriptTemplates/bitcoincashScriptTemplates.d.ts +2 -0
  146. package/lib/src/common/utxobased/info/scriptTemplates/types.d.ts +9 -0
  147. package/lib/src/common/utxobased/info/smartcash.d.ts +3 -0
  148. package/lib/src/common/utxobased/info/ufo.d.ts +3 -0
  149. package/lib/src/common/utxobased/info/utxoPickers/dogeUtxoPicker.d.ts +2 -0
  150. package/lib/src/common/utxobased/info/vertcoin.d.ts +3 -0
  151. package/lib/src/common/utxobased/info/zcoin.d.ts +6 -0
  152. package/lib/src/common/utxobased/keymanager/base.d.ts +9 -0
  153. package/lib/src/common/utxobased/keymanager/bip69.d.ts +19 -0
  154. package/lib/src/common/utxobased/keymanager/bitcoincashUtils/base32.d.ts +19 -0
  155. package/lib/src/common/utxobased/keymanager/bitcoincashUtils/bn.d.ts +2 -0
  156. package/lib/src/common/utxobased/keymanager/bitcoincashUtils/cashAddress.d.ts +12 -0
  157. package/lib/src/common/utxobased/keymanager/cleaners.d.ts +55 -0
  158. package/lib/src/common/utxobased/keymanager/coinmapper.d.ts +2 -0
  159. package/lib/src/common/utxobased/keymanager/keymanager.d.ts +198 -0
  160. package/lib/src/common/utxobased/keymanager/utxopicker/accumulative.d.ts +2 -0
  161. package/lib/src/common/utxobased/keymanager/utxopicker/forceUseUtxo.d.ts +2 -0
  162. package/lib/src/common/utxobased/keymanager/utxopicker/subtractFee.d.ts +2 -0
  163. package/lib/src/common/utxobased/keymanager/utxopicker/types.d.ts +36 -0
  164. package/lib/src/common/utxobased/keymanager/utxopicker/utils.d.ts +15 -0
  165. package/lib/src/common/utxobased/keymanager/utxopicker.d.ts +8 -0
  166. package/lib/src/common/utxobased/network/BlockBook.d.ts +33 -0
  167. package/lib/src/common/utxobased/network/BlockBookAPI.d.ts +163 -0
  168. package/lib/src/common/utxobased/network/Deferred.d.ts +8 -0
  169. package/lib/src/common/utxobased/network/MakeSocketEmitter.d.ts +13 -0
  170. package/lib/src/common/utxobased/network/Socket.d.ts +41 -0
  171. package/lib/src/common/utxobased/network/nodejsWS.d.ts +2 -0
  172. package/lib/src/common/utxobased/network/socketQueue.d.ts +8 -0
  173. package/lib/src/common/utxobased/network/types.d.ts +17 -0
  174. package/lib/src/common/utxobased/network/windowWS.d.ts +2 -0
  175. package/lib/src/firo.d.ts +3 -0
  176. package/lib/src/ftc.d.ts +3 -0
  177. package/lib/src/index.d.ts +4 -0
  178. package/lib/src/ltc.d.ts +3 -0
  179. package/lib/src/tbch.d.ts +3 -0
  180. package/lib/src/tbtc.d.ts +3 -0
  181. package/lib/src/tbtg.d.ts +3 -0
  182. package/lib/src/types.d.ts +6 -0
  183. package/lib/src/util/delay.d.ts +1 -0
  184. package/lib/src/util/filterUndefined.d.ts +1 -0
  185. package/lib/src/util/indexAtProtected.d.ts +5 -0
  186. package/lib/src/util/typeUtil.d.ts +8 -0
  187. package/lib/src/util/undefinedIfEmptyString.d.ts +1 -0
  188. package/lib/src/util/unixTime.d.ts +1 -0
  189. package/lib/tbch.js +15 -0
  190. package/lib/tbtc.js +15 -0
  191. package/lib/tbtg.js +15 -0
  192. package/lib/test/common/fees/calcMinerFeePerByte.spec.d.ts +1 -0
  193. package/lib/test/common/fees/fees.spec.d.ts +1 -0
  194. package/lib/test/common/plugin/currencyPlugin.fixtures/common.d.ts +29 -0
  195. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/bitcoin.d.ts +2 -0
  196. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/bitcoincash.d.ts +2 -0
  197. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/bitcoinsv.d.ts +2 -0
  198. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/digibyte.d.ts +2 -0
  199. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/feathercoin.d.ts +2 -0
  200. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/groestlcoin.d.ts +2 -0
  201. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/litecoin.d.ts +2 -0
  202. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/smartcash.d.ts +2 -0
  203. package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/zcoin.d.ts +2 -0
  204. package/lib/test/common/plugin/currencyPlugin.fixtures/index.d.ts +2 -0
  205. package/lib/test/common/plugin/currencyPlugin.spec.d.ts +1 -0
  206. package/lib/test/common/plugin/makeMetadata.spec.d.ts +1 -0
  207. package/lib/test/common/plugin/serverScores.spec.d.ts +1 -0
  208. package/lib/test/common/utxobased/addressFormat/addressFormatIndex/addressFormat.spec.d.ts +1 -0
  209. package/lib/test/common/utxobased/db/Processor.spec.d.ts +1 -0
  210. package/lib/test/common/utxobased/engine/PaymentRequest.spec.d.ts +1 -0
  211. package/lib/test/common/utxobased/engine/UtxoWalletTools.spec.d.ts +1 -0
  212. package/lib/test/common/utxobased/engine/engine.fixtures/bitcoinTestnet/tests.d.ts +70 -0
  213. package/lib/test/common/utxobased/engine/engine.fixtures/index.d.ts +65 -0
  214. package/lib/test/common/utxobased/engine/engine.spec.d.ts +1 -0
  215. package/lib/test/common/utxobased/keymanager/coins/altcointestfixtures.d.ts +54 -0
  216. package/lib/test/common/utxobased/keymanager/coins/bitcoincashtransactiontest.spec.d.ts +1 -0
  217. package/lib/test/common/utxobased/keymanager/coins/bitcointransactiontest.spec.d.ts +1 -0
  218. package/lib/test/common/utxobased/keymanager/coins/cashaddr.spec.d.ts +1 -0
  219. package/lib/test/common/utxobased/keymanager/coins/checkdatasig.spec.d.ts +1 -0
  220. package/lib/test/common/utxobased/keymanager/coins/groestlcointransactiontest.spec.d.ts +1 -0
  221. package/lib/test/common/utxobased/keymanager/coins/keymanagertest.spec.d.ts +1 -0
  222. package/lib/test/common/utxobased/network/BlockBook.spec.d.ts +1 -0
  223. package/lib/test/util/objectKeys.d.ts +8 -0
  224. package/lib/test/util/testLog.d.ts +3 -0
  225. package/lib/test/utils.d.ts +10 -0
  226. package/lib/types.js +7 -0
  227. package/lib/util/delay.js +4 -0
  228. package/lib/util/filterUndefined.js +4 -0
  229. package/lib/util/indexAtProtected.js +9 -0
  230. package/lib/util/typeUtil.js +9 -0
  231. package/lib/util/undefinedIfEmptyString.js +2 -0
  232. package/lib/util/unixTime.js +2 -0
  233. package/package.json +101 -0
@@ -0,0 +1,198 @@
1
+ import { AddressPath } from '../../plugin/types';
2
+ import { IUTXO } from '../db/types';
3
+ import { ScriptTemplate } from '../info/scriptTemplates/types';
4
+ import * as utxopicker from './utxopicker';
5
+ export declare enum BIP43PurposeTypeEnum {
6
+ Airbitz = "airbitz",
7
+ Legacy = "legacy",
8
+ Segwit = "segwit",
9
+ WrappedSegwit = "wrappedSegwit"
10
+ }
11
+ export declare enum AddressTypeEnum {
12
+ p2pkh = "p2pkh",
13
+ p2sh = "p2sh",
14
+ p2wpkh = "p2wpkh",
15
+ p2wsh = "p2wsh"
16
+ }
17
+ export declare enum ScriptTypeEnum {
18
+ p2wpkh = "p2wpkh",
19
+ p2wpkhp2sh = "p2wpkhp2sh",
20
+ p2wsh = "p2wsh",
21
+ p2pk = "p2pk",
22
+ p2pkh = "p2pkh",
23
+ p2sh = "p2sh",
24
+ replayProtection = "replayprotection",
25
+ replayProtectionP2SH = "replayprotectionp2sh"
26
+ }
27
+ export declare enum TransactionInputTypeEnum {
28
+ Legacy = "legacy",
29
+ Segwit = "segwit"
30
+ }
31
+ export interface VerifyAddressArgs {
32
+ address: string;
33
+ coin: string;
34
+ }
35
+ export declare enum VerifyAddressEnum {
36
+ good = "good",
37
+ legacy = "legacy",
38
+ bad = "bad"
39
+ }
40
+ export interface SeedOrMnemonicToXPrivArgs {
41
+ seed: string;
42
+ type: BIP43PurposeTypeEnum;
43
+ coinType?: number;
44
+ account?: number;
45
+ coin: string;
46
+ }
47
+ export interface XPrivToXPubArgs {
48
+ xpriv: string;
49
+ type: BIP43PurposeTypeEnum;
50
+ coin: string;
51
+ }
52
+ export interface XPrivToPrivateKeyArgs {
53
+ xpriv: string;
54
+ type: BIP43PurposeTypeEnum;
55
+ bip44ChangeIndex: number;
56
+ bip44AddressIndex: number;
57
+ coin: string;
58
+ }
59
+ export interface XPubToPubkeyArgs {
60
+ xpub: string;
61
+ type: BIP43PurposeTypeEnum;
62
+ bip44ChangeIndex: number;
63
+ bip44AddressIndex: number;
64
+ coin: string;
65
+ }
66
+ export interface AddressToScriptPubkeyArgs {
67
+ address: string;
68
+ addressType?: AddressTypeEnum;
69
+ coin: string;
70
+ }
71
+ export interface PubkeyToScriptPubkeyArgs {
72
+ pubkey: string;
73
+ scriptType: ScriptTypeEnum;
74
+ }
75
+ export interface PubkeyToScriptPubkeyReturn {
76
+ scriptPubkey: string;
77
+ redeemScript?: string;
78
+ }
79
+ export interface ScriptPubkeyToAddressArgs {
80
+ scriptPubkey: string;
81
+ addressType: AddressTypeEnum;
82
+ coin: string;
83
+ redeemScript?: string;
84
+ }
85
+ export interface ScriptPubkeyToAddressReturn {
86
+ address: string;
87
+ legacyAddress: string;
88
+ }
89
+ export interface ScriptPubkeyToScriptHashArgs {
90
+ scriptPubkey: string;
91
+ scriptType: ScriptTypeEnum;
92
+ coin: string;
93
+ }
94
+ export interface ScriptPubkeyToP2SHArgs {
95
+ scriptPubkey: string;
96
+ coin?: string;
97
+ }
98
+ export interface ScriptPubkeyToP2SHReturn {
99
+ scriptPubkey: string;
100
+ redeemScript: string;
101
+ address?: string;
102
+ }
103
+ export interface WIFToPrivateKeyArgs {
104
+ wifKey: string;
105
+ coin: string;
106
+ }
107
+ export interface PrivateKeyToWIFArgs {
108
+ privateKey: string;
109
+ coin: string;
110
+ }
111
+ export interface TxInput {
112
+ type: TransactionInputTypeEnum;
113
+ prevTxid: string;
114
+ index: number;
115
+ prevTx?: string;
116
+ prevScriptPubkey?: string;
117
+ redeemScript?: string;
118
+ value?: number;
119
+ }
120
+ export interface TxOutput {
121
+ scriptPubkey: string;
122
+ amount: number;
123
+ }
124
+ export interface MakeTxArgs {
125
+ forceUseUtxo: IUTXO[];
126
+ utxos: IUTXO[];
127
+ targets: MakeTxTarget[];
128
+ feeRate: number;
129
+ setRBF: boolean;
130
+ coin: string;
131
+ freshChangeAddress: string;
132
+ subtractFee?: boolean;
133
+ }
134
+ export interface MakeTxTarget {
135
+ address: string;
136
+ value: number;
137
+ }
138
+ interface MakeTxReturn extends Required<utxopicker.UtxoPickerResult> {
139
+ hex: string;
140
+ psbtBase64: string;
141
+ }
142
+ export interface SignTxArgs {
143
+ privateKeys: string[];
144
+ psbtBase64: string;
145
+ coin: string;
146
+ }
147
+ interface SignTxReturn {
148
+ id: string;
149
+ hex: string;
150
+ }
151
+ export interface BitcoinJSNetwork {
152
+ wif: number;
153
+ bip32: Bip32;
154
+ messagePrefix: string;
155
+ bech32: string;
156
+ pubKeyHash: number;
157
+ scriptHash: number;
158
+ }
159
+ export interface Bip32 {
160
+ public: number;
161
+ private: number;
162
+ }
163
+ export declare function bip43PurposeNumberToTypeEnum(num: number): BIP43PurposeTypeEnum;
164
+ export interface SelectedCoinPrefixes {
165
+ messagePrefix: string;
166
+ wif: number;
167
+ legacyXPriv: number;
168
+ legacyXPub: number;
169
+ wrappedSegwitXPriv?: number;
170
+ wrappedSegwitXPub?: number;
171
+ segwitXPriv?: number;
172
+ segwitXPub?: number;
173
+ pubkeyHash: number;
174
+ scriptHash: number;
175
+ bech32?: string;
176
+ cashaddr?: string;
177
+ }
178
+ export declare const verifyAddress: (args: VerifyAddressArgs) => VerifyAddressEnum;
179
+ export declare const getAddressTypeFromAddress: (address: string, coinName: string) => AddressTypeEnum;
180
+ export declare function seedOrMnemonicToXPriv(args: SeedOrMnemonicToXPrivArgs): string;
181
+ export declare const xprivToXPub: (args: XPrivToXPubArgs) => string;
182
+ export declare function derivationLevelScriptHash(scriptTemplate: ScriptTemplate): number;
183
+ export declare const isPathUsingDerivationLevelScriptHash: (scriptTemplate: ScriptTemplate, path: AddressPath) => boolean;
184
+ export declare const xpubToPubkey: (args: XPubToPubkeyArgs) => string;
185
+ export declare const addressToScriptPubkey: (args: AddressToScriptPubkeyArgs) => string;
186
+ export declare function scriptPubkeyToAddress(args: ScriptPubkeyToAddressArgs): ScriptPubkeyToAddressReturn;
187
+ export declare function scriptPubkeyToScriptHash(args: ScriptPubkeyToScriptHashArgs): string;
188
+ export declare function scriptPubkeyToP2SH(args: ScriptPubkeyToP2SHArgs): ScriptPubkeyToP2SHReturn;
189
+ export declare function pubkeyToScriptPubkey(args: PubkeyToScriptPubkeyArgs): PubkeyToScriptPubkeyReturn;
190
+ export declare const toNewFormat: (address: string, coinName: string) => string;
191
+ export declare const xprivToPrivateKey: (args: XPrivToPrivateKeyArgs) => string;
192
+ export declare function privateKeyToWIF(args: PrivateKeyToWIFArgs): string;
193
+ export declare const wifToPrivateKey: (args: WIFToPrivateKeyArgs) => string;
194
+ export declare function privateKeyToPubkey(privateKey: string): string;
195
+ export declare function signMessageBase64(message: string, privateKey: string): string;
196
+ export declare function makeTx(args: MakeTxArgs): Promise<MakeTxReturn>;
197
+ export declare function signTx(args: SignTxArgs): Promise<SignTxReturn>;
198
+ export {};
@@ -0,0 +1,2 @@
1
+ import { UtxoPickerArgs, UtxoPickerResult } from './types';
2
+ export declare function accumulative(args: UtxoPickerArgs): UtxoPickerResult;
@@ -0,0 +1,2 @@
1
+ import { UtxoPickerArgs, UtxoPickerResult } from './types';
2
+ export declare function forceUseUtxo(args: UtxoPickerArgs): UtxoPickerResult;
@@ -0,0 +1,2 @@
1
+ import { UtxoPickerArgs, UtxoPickerResult } from './types';
2
+ export declare function subtractFee(args: UtxoPickerArgs): UtxoPickerResult;
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" />
2
+ import { PsbtInput } from 'bip174/src/lib/interfaces';
3
+ import { ScriptTypeEnum } from '../keymanager';
4
+ export declare type Input = UTXO;
5
+ export interface UTXO extends PsbtInput {
6
+ hash: Buffer;
7
+ index: number;
8
+ sequence?: number;
9
+ value: number;
10
+ script: Buffer;
11
+ scriptPubkey: Buffer;
12
+ scriptType: ScriptTypeEnum;
13
+ }
14
+ export interface Output {
15
+ script: Buffer;
16
+ scriptPubkey: Buffer;
17
+ value: number;
18
+ }
19
+ export interface Target {
20
+ script: string;
21
+ value: number;
22
+ }
23
+ export interface UtxoPickerArgs {
24
+ utxos: UTXO[];
25
+ useUtxos?: UTXO[];
26
+ targets: Target[];
27
+ feeRate: number;
28
+ changeScript: string;
29
+ }
30
+ export interface UtxoPickerResult {
31
+ inputs?: Input[];
32
+ outputs?: Output[];
33
+ changeUsed: boolean;
34
+ fee: number;
35
+ }
36
+ export declare type UtxoPickingFunc = (args: UtxoPickerArgs) => UtxoPickerResult;
@@ -0,0 +1,15 @@
1
+ import { Input, Output, UTXO, UtxoPickerResult } from './types';
2
+ export declare const compactSize: (num: number) => number;
3
+ export declare const withCompactSize: (num: number) => number;
4
+ export declare function inputBytes(input: UTXO): number;
5
+ export declare function outputBytes(output: Output): number;
6
+ export declare function dustThreshold(output: Output, feeRate: number): number;
7
+ export declare function transactionBytes(inputs: UTXO[], outputs: Output[]): number;
8
+ export declare function uintOrNaN(v: number): number;
9
+ export declare function sumForgiving(range: Array<{
10
+ value: number;
11
+ }>): number;
12
+ export declare function sumOrNaN(range: Array<{
13
+ value: number;
14
+ }>): number;
15
+ export declare function finalize(inputs: Input[], outputs: Output[], feeRate: number, changeScript: string): UtxoPickerResult;
@@ -0,0 +1,8 @@
1
+ import { UtxoPickingFunc } from './utxopicker/types';
2
+ export * from './utxopicker/types';
3
+ export interface UtxoPicker {
4
+ forceUseUtxo: UtxoPickingFunc;
5
+ subtractFee: UtxoPickingFunc;
6
+ accumulative: UtxoPickingFunc;
7
+ }
8
+ export declare const utxoPicker: UtxoPicker;
@@ -0,0 +1,33 @@
1
+ import { Cleaner } from 'cleaners';
2
+ import { EdgeLog, EdgeTransaction } from 'edge-core-js/types';
3
+ import { EngineEmitter } from '../../plugin/makeEngineEmitter';
4
+ import { AddressResponse, AddresssMessageParams, AddressUtxosResponse, BroadcastTxResponse, InfoResponse, SubscribeAddressResponse, TransactionResponse } from './BlockBookAPI';
5
+ import Deferred from './Deferred';
6
+ import { SocketEmitter } from './MakeSocketEmitter';
7
+ import { OnQueueSpaceCB } from './Socket';
8
+ export declare type WatchAddressesCB = (response: SubscribeAddressResponse) => void | Promise<void>;
9
+ export declare type WatchBlocksCB = () => void | Promise<void>;
10
+ export interface BlockBook {
11
+ isConnected: boolean;
12
+ connect: () => Promise<void>;
13
+ disconnect: () => Promise<void>;
14
+ onQueueSpace: (cb: OnQueueSpaceCB) => void;
15
+ fetchInfo: () => Promise<InfoResponse>;
16
+ fetchAddress: (address: string, params?: AddresssMessageParams) => Promise<AddressResponse>;
17
+ watchAddresses: (addresses: string[], deferredAddressSub: Deferred<unknown>) => void;
18
+ watchBlocks: (deferredBlockSub: Deferred<unknown>) => void;
19
+ fetchAddressUtxos: (account: string) => Promise<AddressUtxosResponse>;
20
+ fetchTransaction: (hash: string) => Promise<TransactionResponse>;
21
+ broadcastTx: (transaction: EdgeTransaction) => Promise<BroadcastTxResponse>;
22
+ }
23
+ interface BlockBookConfig {
24
+ socketEmitter: SocketEmitter;
25
+ engineEmitter: EngineEmitter;
26
+ wsAddress: string;
27
+ log: EdgeLog;
28
+ walletId: string;
29
+ onQueueSpaceCB: OnQueueSpaceCB;
30
+ asAddress?: Cleaner<string>;
31
+ }
32
+ export declare function makeBlockBook(config: BlockBookConfig): BlockBook;
33
+ export {};
@@ -0,0 +1,163 @@
1
+ import { Cleaner } from 'cleaners';
2
+ import { EdgeTransaction } from 'edge-core-js/types';
3
+ /**
4
+ * Websocket Task
5
+ */
6
+ export interface BlockbookTask<T> {
7
+ method: string;
8
+ params: unknown;
9
+ cleaner: Cleaner<T>;
10
+ }
11
+ export interface BlockbookAccountUtxo {
12
+ txid: string;
13
+ vout: number;
14
+ value: string;
15
+ confirmations?: number;
16
+ coinbase?: boolean;
17
+ height?: number;
18
+ lockTime?: number;
19
+ address?: string;
20
+ path?: string;
21
+ }
22
+ export declare const asBlockbookAccountUtxo: (asAddress?: Cleaner<string>) => Cleaner<BlockbookAccountUtxo>;
23
+ export interface BlockbookTransaction {
24
+ txid: string;
25
+ hex: string;
26
+ blockHeight: number;
27
+ confirmations: number;
28
+ blockTime: number;
29
+ fees: string;
30
+ vin: Array<{
31
+ txid: string;
32
+ sequence?: number;
33
+ n: number;
34
+ vout: number;
35
+ addresses: string[];
36
+ isAddress: boolean;
37
+ value: string;
38
+ hex?: string;
39
+ }>;
40
+ vout: Array<{
41
+ n: number;
42
+ value: string;
43
+ addresses: string[];
44
+ hex?: string;
45
+ }>;
46
+ }
47
+ export declare const asBlockbookTransaction: (asAddress?: Cleaner<string>) => Cleaner<BlockbookTransaction>;
48
+ /**
49
+ * Error Response
50
+ */
51
+ export declare type BlockbookErrorResponse = ReturnType<typeof asBlockbookErrorResponse>;
52
+ export declare const asBlockbookErrorResponse: import("cleaners").ObjectCleaner<{
53
+ error: {
54
+ message: any;
55
+ };
56
+ }>;
57
+ /**
58
+ * Blockbook Response Generic
59
+ */
60
+ export declare type BlockbookResponse<T> = T;
61
+ export declare const asBlockbookResponse: <T>(asT: Cleaner<T>) => Cleaner<T>;
62
+ /**
63
+ * Ping Message
64
+ */
65
+ export declare const pingMessage: () => BlockbookTask<PingResponse>;
66
+ export declare type PingResponse = ReturnType<typeof asPingResponse>;
67
+ export declare const asPingResponse: import("cleaners").ObjectCleaner<object>;
68
+ /**
69
+ * Get Info
70
+ */
71
+ export declare const infoMessage: () => BlockbookTask<InfoResponse>;
72
+ export declare type InfoResponse = ReturnType<typeof asInfoResponse>;
73
+ export declare const asInfoResponse: import("cleaners").ObjectCleaner<{
74
+ name: string;
75
+ shortcut: string;
76
+ decimals: number;
77
+ version: string;
78
+ bestHeight: number;
79
+ bestHash: string;
80
+ block0Hash: string;
81
+ testnet: boolean;
82
+ backend: {
83
+ version: any;
84
+ subversion: any;
85
+ } | undefined;
86
+ }>;
87
+ /**
88
+ * Get Account UTXO
89
+ */
90
+ export declare const addressUtxosMessage: (address: string, asAddress?: Cleaner<string>) => BlockbookTask<AddressUtxosResponse>;
91
+ export declare type AddressUtxosResponse = BlockbookAccountUtxo[];
92
+ export declare const asAddressUtxosResponse: (asAddress?: Cleaner<string>) => Cleaner<AddressUtxosResponse>;
93
+ /**
94
+ * Get Transaction
95
+ */
96
+ export declare const transactionMessage: (hash: string, asAddress?: Cleaner<string>) => BlockbookTask<TransactionResponse>;
97
+ export declare type TransactionResponse = BlockbookTransaction;
98
+ export declare const asTransactionResponse: (asAddress?: Cleaner<string>) => Cleaner<BlockbookTransaction>;
99
+ /**
100
+ * Send Transaction
101
+ */
102
+ export declare const broadcastTxMessage: (transaction: EdgeTransaction) => BlockbookTask<BroadcastTxResponse>;
103
+ export declare type BroadcastTxResponse = ReturnType<typeof asBroadcastTxResponse>;
104
+ export declare const asBroadcastTxResponse: import("cleaners").ObjectCleaner<{
105
+ result: string;
106
+ }>;
107
+ /**
108
+ * Get Account Info
109
+ */
110
+ export interface AddresssMessageParams {
111
+ details?: 'basic' | 'txids' | 'txs';
112
+ from?: number;
113
+ to?: number;
114
+ page?: number;
115
+ pageSize?: number;
116
+ }
117
+ export declare const addressMessage: (address: string, asAddress?: Cleaner<string>, params?: AddresssMessageParams) => BlockbookTask<AddressResponse>;
118
+ export interface AddressResponse {
119
+ address: string;
120
+ balance: string;
121
+ totalReceived: string;
122
+ totalSent: string;
123
+ txs: number;
124
+ unconfirmedBalance: string;
125
+ unconfirmedTxs: number;
126
+ txids: string[];
127
+ transactions: BlockbookTransaction[];
128
+ page: number;
129
+ totalPages: number;
130
+ itemsOnPage: number;
131
+ }
132
+ export declare const asAddressResponse: (asAddress?: Cleaner<string>) => import("cleaners").ObjectCleaner<{
133
+ address: string;
134
+ balance: string;
135
+ totalReceived: string;
136
+ totalSent: string;
137
+ txs: number;
138
+ unconfirmedBalance: string;
139
+ unconfirmedTxs: number;
140
+ txids: string[];
141
+ transactions: BlockbookTransaction[];
142
+ page: number;
143
+ totalPages: number;
144
+ itemsOnPage: number;
145
+ }>;
146
+ /**
147
+ * Subscribe New Block
148
+ */
149
+ export declare const subscribeNewBlockMessage: () => BlockbookTask<SubscribeNewBlockResponse>;
150
+ export declare type SubscribeNewBlockResponse = ReturnType<typeof asSubscribeNewBlockResponse>;
151
+ export declare const asSubscribeNewBlockResponse: import("cleaners").ObjectCleaner<{
152
+ height: number;
153
+ hash: string;
154
+ }>;
155
+ /**
156
+ * Subscribe Address
157
+ */
158
+ export declare const subscribeAddressesMessage: (addresses: string[], asAddress?: Cleaner<string>) => BlockbookTask<SubscribeAddressResponse>;
159
+ export interface SubscribeAddressResponse {
160
+ address: string;
161
+ tx: BlockbookTransaction;
162
+ }
163
+ export declare const asSubscribeAddressResponse: (asAddress?: Cleaner<string>) => Cleaner<SubscribeAddressResponse>;
@@ -0,0 +1,8 @@
1
+ export default class Deferred<T> {
2
+ private _resolve;
3
+ private _reject;
4
+ private readonly _promise;
5
+ get promise(): Promise<T>;
6
+ resolve(value: T): void;
7
+ reject(reason?: unknown): void;
8
+ }
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ export declare interface SocketEmitter {
4
+ emit: ((event: SocketEvent.CONNECTION_OPEN, uri: string) => void) & ((event: SocketEvent.CONNECTION_CLOSE, uri: string, error?: Error) => boolean) & ((event: SocketEvent.CONNECTION_TIMER, uri: string, queryTime: number) => boolean);
5
+ on: ((event: SocketEvent.CONNECTION_OPEN, listener: (uri: string) => void) => this) & ((event: SocketEvent.CONNECTION_CLOSE, listener: (uri: string, error?: Error) => void) => this) & ((event: SocketEvent.CONNECTION_TIMER, listener: (uri: string, queryTime: number) => void) => this);
6
+ }
7
+ export declare class SocketEmitter extends EventEmitter {
8
+ }
9
+ export declare enum SocketEvent {
10
+ CONNECTION_OPEN = "connection:open",
11
+ CONNECTION_CLOSE = "connection:close",
12
+ CONNECTION_TIMER = "connection:timer"
13
+ }
@@ -0,0 +1,41 @@
1
+ import { Cleaner } from 'cleaners';
2
+ import { EdgeLog } from 'edge-core-js/types';
3
+ import Deferred from './Deferred';
4
+ import { SocketEmitter } from './MakeSocketEmitter';
5
+ import { ReadyState } from './types';
6
+ export declare type OnFailHandler = (error: Error) => void;
7
+ export interface WsTask<T> {
8
+ method: string;
9
+ params: unknown;
10
+ deferred: Deferred<T>;
11
+ cleaner?: Cleaner<T>;
12
+ }
13
+ export interface WsSubscription<T> {
14
+ method: string;
15
+ params: unknown;
16
+ cb: (value: T) => void;
17
+ subscribed: boolean;
18
+ cleaner: Cleaner<T>;
19
+ deferred: Deferred<unknown>;
20
+ }
21
+ export interface Socket {
22
+ readyState: ReadyState;
23
+ connect: () => Promise<void>;
24
+ disconnect: () => void;
25
+ submitTask: <T>(task: WsTask<T>) => void;
26
+ onQueueSpace: (cb: OnQueueSpaceCB) => void;
27
+ subscribe: <T>(subscription: WsSubscription<T>) => void;
28
+ isConnected: () => boolean;
29
+ }
30
+ export declare type OnQueueSpaceCB = (uri: string) => Promise<WsTask<unknown> | boolean | undefined>;
31
+ interface SocketConfig {
32
+ queueSize?: number;
33
+ timeout?: number;
34
+ walletId: string;
35
+ emitter: SocketEmitter;
36
+ log: EdgeLog;
37
+ healthCheck: () => Promise<void>;
38
+ onQueueSpaceCB: OnQueueSpaceCB;
39
+ }
40
+ export declare function makeSocket(uri: string, config: SocketConfig): Socket;
41
+ export {};
@@ -0,0 +1,2 @@
1
+ import { InnerSocket, InnerSocketCallbacks } from './types';
2
+ export declare function setupWS(uri: string, callbacks: InnerSocketCallbacks): InnerSocket;
@@ -0,0 +1,8 @@
1
+ interface UpdateQueue {
2
+ id: string;
3
+ action?: string;
4
+ updateFunc: () => void;
5
+ }
6
+ export declare function pushUpdate(update: UpdateQueue): void;
7
+ export declare function removeIdFromQueue(id: string): void;
8
+ export {};
@@ -0,0 +1,17 @@
1
+ export interface InnerSocketCallbacks {
2
+ onError: (error?: Error) => void;
3
+ onMessage: (message: string) => void;
4
+ onClose: (error?: Error) => void;
5
+ onOpen: () => void;
6
+ }
7
+ export declare enum ReadyState {
8
+ CONNECTING = 0,
9
+ OPEN = 1,
10
+ CLOSING = 2,
11
+ CLOSED = 3
12
+ }
13
+ export interface InnerSocket {
14
+ readyState: ReadyState;
15
+ disconnect: () => void;
16
+ send: (message: string) => void;
17
+ }
@@ -0,0 +1,2 @@
1
+ import { InnerSocket, InnerSocketCallbacks } from './types';
2
+ export declare function setupBrowser(uri: string, callbacks: InnerSocketCallbacks): InnerSocket;
@@ -0,0 +1,3 @@
1
+ import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types';
2
+ declare const plugin: (options: EdgeCorePluginOptions) => EdgeCurrencyPlugin;
3
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types';
2
+ declare const plugin: (options: EdgeCorePluginOptions) => EdgeCurrencyPlugin;
3
+ export default plugin;
@@ -0,0 +1,4 @@
1
+ import { EdgeCorePlugins } from 'edge-core-js/types';
2
+ declare const plugins: EdgeCorePlugins;
3
+ export default plugins;
4
+ export { setMemletConfig } from 'memlet';
@@ -0,0 +1,3 @@
1
+ import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types';
2
+ declare const plugin: (options: EdgeCorePluginOptions) => EdgeCurrencyPlugin;
3
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types';
2
+ declare const plugin: (options: EdgeCorePluginOptions) => EdgeCurrencyPlugin;
3
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types';
2
+ declare const plugin: (options: EdgeCorePluginOptions) => EdgeCurrencyPlugin;
3
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types';
2
+ declare const plugin: (options: EdgeCorePluginOptions) => EdgeCurrencyPlugin;
3
+ export default plugin;
@@ -0,0 +1,6 @@
1
+ import { EdgeCorePlugins } from 'edge-core-js/types';
2
+ declare global {
3
+ interface Window {
4
+ addEdgeCorePlugins?: (plugins: EdgeCorePlugins) => void;
5
+ }
6
+ }
@@ -0,0 +1 @@
1
+ export declare const delay: (ms: number) => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const filterUndefined: <T>(values: (T | undefined)[]) => T[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Gets an element out of an array but includes protection if the index
3
+ * overflows the length of the array.
4
+ **/
5
+ export declare const indexAtProtected: <T extends any[] | undefined>(array: T, index: number) => T extends (infer U)[] ? U : undefined;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Like Pick, but removed fields are optional.
3
+ */
4
+ export declare type SoftPick<T, K extends keyof T> = Pick<T, K> & Partial<T>;
5
+ /**
6
+ * Like Omit, but removed fields are optional.
7
+ */
8
+ export declare type SoftOmit<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
@@ -0,0 +1 @@
1
+ export declare const undefinedIfEmptyString: (str?: string | undefined) => string | undefined;
@@ -0,0 +1 @@
1
+ export declare const unixTime: (ts?: number) => number;
package/lib/tbch.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _makeCurrencyPlugin = require('./common/plugin/makeCurrencyPlugin');
4
+ var _bitcoincashtestnet = require('./common/utxobased/info/bitcoincashtestnet');
5
+
6
+ const plugin = (options) =>
7
+ _makeCurrencyPlugin.makeCurrencyPlugin.call(void 0, options, _bitcoincashtestnet.info)
8
+
9
+ if (typeof window !== 'undefined') {
10
+ _optionalChain([window, 'access', _ => _.addEdgeCorePlugins, 'optionalCall', _2 => _2({
11
+ [_bitcoincashtestnet.info.currencyInfo.pluginId]: plugin
12
+ })])
13
+ }
14
+
15
+ exports. default = plugin