@leocuvee/turtlecoin-utils 0.0.14

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 (132) hide show
  1. package/.github/workflows/ci.yml +27 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +7 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/turtlecoin-utils.iml +12 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/.travis.yml +11 -0
  9. package/CONTRIBUTING.md +3 -0
  10. package/LICENSE +674 -0
  11. package/README.md +203 -0
  12. package/config.json +7 -0
  13. package/docs/.nojekyll +0 -0
  14. package/docs/CNAME +1 -0
  15. package/docs/assets/css/main.css +2321 -0
  16. package/docs/assets/images/icons.png +0 -0
  17. package/docs/assets/images/icons@2x.png +0 -0
  18. package/docs/assets/images/widgets.png +0 -0
  19. package/docs/assets/images/widgets@2x.png +0 -0
  20. package/docs/assets/js/main.js +1 -0
  21. package/docs/assets/js/search.js +3 -0
  22. package/docs/classes/address.html +964 -0
  23. package/docs/classes/addressprefix.html +431 -0
  24. package/docs/classes/block.html +965 -0
  25. package/docs/classes/blocktemplate.html +695 -0
  26. package/docs/classes/cryptonote.html +1137 -0
  27. package/docs/classes/ed25519.keypair.html +400 -0
  28. package/docs/classes/ed25519.keys.html +373 -0
  29. package/docs/classes/extranoncetag.extranoncedata.html +454 -0
  30. package/docs/classes/extranoncetag.extranoncepaymentid.html +453 -0
  31. package/docs/classes/extranoncetag.iextranonce.html +347 -0
  32. package/docs/classes/extratag.extramergedmining.html +494 -0
  33. package/docs/classes/extratag.extranonce.html +530 -0
  34. package/docs/classes/extratag.extrapadding.html +456 -0
  35. package/docs/classes/extratag.extrapublickey.html +460 -0
  36. package/docs/classes/extratag.iextratag.html +355 -0
  37. package/docs/classes/levinpacket.html +674 -0
  38. package/docs/classes/levinpayloads.handshake.html +731 -0
  39. package/docs/classes/levinpayloads.ilevinpayload.html +318 -0
  40. package/docs/classes/levinpayloads.liteblock.html +494 -0
  41. package/docs/classes/levinpayloads.missingtransactions.html +494 -0
  42. package/docs/classes/levinpayloads.newblock.html +540 -0
  43. package/docs/classes/levinpayloads.newtransactions.html +402 -0
  44. package/docs/classes/levinpayloads.peerentry.html +610 -0
  45. package/docs/classes/levinpayloads.ping.html +450 -0
  46. package/docs/classes/levinpayloads.rawblock.html +344 -0
  47. package/docs/classes/levinpayloads.requestchain.html +402 -0
  48. package/docs/classes/levinpayloads.requestgetobjects.html +448 -0
  49. package/docs/classes/levinpayloads.requesttxpool.html +402 -0
  50. package/docs/classes/levinpayloads.responsechain.html +494 -0
  51. package/docs/classes/levinpayloads.responsegetobjects.html +540 -0
  52. package/docs/classes/levinpayloads.timedsync.html +540 -0
  53. package/docs/classes/multisig.html +930 -0
  54. package/docs/classes/multisigmessage.html +694 -0
  55. package/docs/classes/parentblock.html +347 -0
  56. package/docs/classes/transaction.html +925 -0
  57. package/docs/classes/transactioninputs.coinbaseinput.html +390 -0
  58. package/docs/classes/transactioninputs.itransactioninput.html +321 -0
  59. package/docs/classes/transactioninputs.keyinput.html +459 -0
  60. package/docs/classes/transactionoutputs.itransactionoutput.html +317 -0
  61. package/docs/classes/transactionoutputs.keyoutput.html +422 -0
  62. package/docs/enums/extranoncetag.noncetagtype.html +246 -0
  63. package/docs/enums/extratag.extratagtype.html +280 -0
  64. package/docs/enums/levinprotocol.commandtype.html +391 -0
  65. package/docs/enums/transactioninputs.inputtype.html +246 -0
  66. package/docs/enums/transactionoutputs.outputtype.html +229 -0
  67. package/docs/globals.html +238 -0
  68. package/docs/index.html +271 -0
  69. package/docs/interfaces/interfaces.config.html +590 -0
  70. package/docs/interfaces/interfaces.daemonblocktemplateresponse.html +323 -0
  71. package/docs/interfaces/interfaces.generatedinput.html +304 -0
  72. package/docs/interfaces/interfaces.generatedoutput.html +285 -0
  73. package/docs/interfaces/interfaces.inputkeys.html +304 -0
  74. package/docs/interfaces/interfaces.ipreparedtransaction.html +268 -0
  75. package/docs/interfaces/interfaces.output.html +399 -0
  76. package/docs/interfaces/interfaces.preparedringsignature.html +377 -0
  77. package/docs/interfaces/interfaces.preparedtransaction.html +329 -0
  78. package/docs/interfaces/interfaces.randomoutput.html +285 -0
  79. package/docs/interfaces/interfaces.transactionrecipient.html +285 -0
  80. package/docs/interfaces/multisiginterfaces.partialkeyimage.html +277 -0
  81. package/docs/interfaces/multisiginterfaces.partialsigningkey.html +277 -0
  82. package/docs/modules/ed25519.html +195 -0
  83. package/docs/modules/extranoncetag.html +208 -0
  84. package/docs/modules/extratag.html +216 -0
  85. package/docs/modules/interfaces.html +231 -0
  86. package/docs/modules/levinpayloads.html +247 -0
  87. package/docs/modules/levinprotocol.html +191 -0
  88. package/docs/modules/multisiginterfaces.html +195 -0
  89. package/docs/modules/transactioninputs.html +208 -0
  90. package/docs/modules/transactionoutputs.html +204 -0
  91. package/index.d.ts +417 -0
  92. package/index.js +1508 -0
  93. package/lib/base58.js +220 -0
  94. package/lib/biginteger.js +1591 -0
  95. package/lib/blocktemplate.js +408 -0
  96. package/lib/crypto.js +19698 -0
  97. package/lib/mnemonic.js +1204 -0
  98. package/lib/nacl-fast-cn.js +608 -0
  99. package/lib/ringsigs.js +24262 -0
  100. package/lib/sha3.js +477 -0
  101. package/package.json +58 -0
  102. package/src/Address.ts +433 -0
  103. package/src/AddressPrefix.ts +117 -0
  104. package/src/Block.ts +556 -0
  105. package/src/BlockTemplate.ts +289 -0
  106. package/src/Common.ts +105 -0
  107. package/src/Config.ts +66 -0
  108. package/src/CryptoNote.ts +1072 -0
  109. package/src/LevinPacket.ts +366 -0
  110. package/src/Multisig.ts +600 -0
  111. package/src/MultisigMessage.ts +374 -0
  112. package/src/ParentBlock.ts +39 -0
  113. package/src/Transaction.ts +628 -0
  114. package/src/Types/ED25519.ts +187 -0
  115. package/src/Types/IExtraNonce.ts +225 -0
  116. package/src/Types/IExtraTag.ts +507 -0
  117. package/src/Types/ITransaction.ts +230 -0
  118. package/src/Types/ITransactionInput.ts +190 -0
  119. package/src/Types/ITransactionOutput.ts +108 -0
  120. package/src/Types/LevinPayloads.ts +1576 -0
  121. package/src/Types/MultisigInterfaces.ts +65 -0
  122. package/src/Types/PortableStorage.ts +289 -0
  123. package/src/Types.ts +36 -0
  124. package/src/index.ts +36 -0
  125. package/test/template.json +6 -0
  126. package/test/test.js +1457 -0
  127. package/tests/blocktemplate.json +6 -0
  128. package/tests/tests.js +215 -0
  129. package/tsconfig.json +15 -0
  130. package/tslint.json +36 -0
  131. package/typedoc.json +10 -0
  132. package/webpack.config.js +15 -0
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ ![image](https://user-images.githubusercontent.com/34389545/35821974-62e0e25c-0a70-11e8-87dd-2cfffeb6ed47.png)
2
+
3
+ [![NPM](https://nodei.co/npm/turtlecoin-utils.png?downloads=true&stars=true)](https://nodei.co/npm/turtlecoin-utils/)
4
+
5
+ #### Master Build Status
6
+ [![Build Status](https://travis-ci.org/turtlecoin/turtlecoin-utils.svg?branch=master)](https://travis-ci.org/turtlecoin/turtlecoin-utils)
7
+
8
+ # TurtleCoin Javascript Utilities
9
+
10
+ ## Disclaimer
11
+
12
+ ***Use of this code in its current state may lead to unexpected results***
13
+
14
+ This repository contains highly experimental code with the goal of making it possible to interact with a daemon including wallet functionaity (sending/receiving transactions) without the need for `turtle-service` or `wallet-api` using Node.js. By using the code in this repo, you understand that some functions may not work, others may work but be untested, while others may upset you.
15
+
16
+ The best way to address such situations is to submit a Pull Request to resolve the issue you're running into.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm i git+https://github.com/turtlecoin/turtlecoin-utils
22
+ ```
23
+
24
+ ## Initialization
25
+
26
+ ### JavaScript
27
+
28
+ ```javascript
29
+ const TurtleCoinUtils = require('turtlecoin-utils').CryptoNote
30
+ const coinUtils = new TurtleCoinUtils()
31
+ ```
32
+
33
+ ### TypeScript
34
+
35
+ ```typescript
36
+ import { CryptoNote } from 'turtlecoin-utils'
37
+ const coinUtils = new CryptoNote()
38
+ ```
39
+
40
+ You can find TypeScript type definitions [here](index.d.ts)
41
+
42
+ ### Forking
43
+
44
+ If initializing for a different CryptoNote project you can specify the configuration.
45
+ All parameters are optional.
46
+
47
+ ```javascript
48
+ const TurtleCoinUtils = require('turtlecoin-utils').CryptoNote
49
+ const coinUtils = new TurtleCoinUtils({
50
+ /* The amount of decimals your coin has */
51
+ coinUnitPlaces: 8,
52
+
53
+ /* Your address prefix - this can be found in CryptoNoteConfig */
54
+ addressPrefix: 6581243850,
55
+
56
+ /* The amount of keccak iterations to be performed when creating seeds and
57
+ addresses. Should be a large number if your are supplying poor entropy
58
+ to the createNewSeed / createNewAddress functions. */
59
+ keccakIterations: 100,
60
+
61
+ /* The default network fee to use in atomic units */
62
+ defaultNetworkFee: 10
63
+ })
64
+ ```
65
+
66
+ ## Public Methods
67
+
68
+ #### createNewSeed([entropy], [iterations])
69
+
70
+ Creates a new address seed using the provided entropy or if entropy is undefined, uses a randomly selected entropy source.
71
+
72
+ #### createNewAddress([entropy], [language], [addressPrefix])
73
+
74
+ Creates a new [address](#address) using the provided entropy, language (for the mnemonic), and address prefix if supplied.
75
+
76
+ #### createAddressFromSeed(seed, [language], [addressPrefix])
77
+
78
+ Creates a new [address](#address) using the provided seed, language (for the mnemonic), and address prefix if supplied.
79
+
80
+ #### createAddressFromMnemonic(mnemonic, [language], [addressPrefix])
81
+
82
+ Creates a new [address](#address) using the provided mnemonic, language (for the mnemonic), and address prefix if supplied.
83
+
84
+ #### createAddressFromKeys(privateSpendKey, privateViewKey, [addressPrefix])
85
+
86
+ Creates a new [address](#address) using the provided private spend key, private view key, and address prefix if supplied.
87
+
88
+ #### decodeAddressPrefix(address)
89
+
90
+ Decodes the [address prefix](#decoded-address-prefix) from the specified CryptoNote public address.
91
+
92
+ #### decodeAddress(address, [addressPrefix])
93
+
94
+ Decodes the address into the public key pairs, prefix, payment ID, etc. Returns a [decoded address](#decoded-address) object.
95
+
96
+ #### encodeRawAddress(rawAddress)
97
+
98
+ Encodes the rawAddress using CN-Base58 encoding.
99
+
100
+ #### encodeAddress(publicViewKey, publicSpendKey, [paymentId], [addressPrefix])
101
+
102
+ Encodes the publicViewKey, publicSpendKey, and payment ID into a standard CryptoNote address (or Integrated address if payment ID is supplied)
103
+
104
+ #### createIntegratedAddress(address, paymentId, [addressPrefix])
105
+
106
+ Creates an Integrated Address using the supplied address and payment ID.
107
+
108
+ #### privateKeyToPublicKey(privateKey)
109
+
110
+ Gets the corresponding private key from the given public key.
111
+
112
+ #### scanTransactionOutputs(transactionPublicKey, outputs, privateViewKey, publicSpendKey, [privateSpendKey])
113
+
114
+ *Documentation In Progress*
115
+
116
+ #### isOurTransactionOutput(transactionPublicKey, output, privateViewKey, publicSpendKey, [privateSpendKey])
117
+
118
+ *Documentation In Progress*
119
+
120
+ #### generateKeyImage(transactionPublicKey, privateViewKey, publicSpendKey, privateSpendKey, outputIndex)
121
+
122
+ *Documentation In Progress*
123
+
124
+ #### generateKeyImagePrimative(publicSpendKey, privateSpendKey, outputIndex, derivation)
125
+
126
+ The same as generateKeyImage, but allows you to reuse a derivation you have previously created, instead of re-deriving it. Returns [keyImage, privateEphemeral].
127
+
128
+ #### createTransaction(transfers, ourOutputs, randomOuts, mixin, feeAmount, [paymentId], [unlockTime])
129
+
130
+ *Documentation In Progress*
131
+
132
+ #### createTransactionAsync(transfers, ourOutputs, randomOuts, mixin, feeAmount, [paymentId], [unlockTime])
133
+
134
+ Functions as `createTransaction`, but runs asynchronously, and additionaly, supports user provided async functions.
135
+ The regular code only supports synchronous provided funcs, so ensure any async user provided functions are not being used in other calls you make.
136
+
137
+ #### serializeTransaction(transaction)
138
+
139
+ *Documentation In Progress*
140
+
141
+ #### generateKeyDerivation(transactionPublicKey, privateViewKey)
142
+
143
+ Creates the key 'derivation' given a transaction public key, and the private view key.
144
+ Can then be supplied to underivePublicKey, to determine if the transaction output belongs to you.
145
+ Returns a string.
146
+
147
+ #### underivePublicKey(derivation, outputIndex, outputKey)
148
+
149
+ Given the output index in the transaction, and the outputs key, along with a
150
+ derivation from `generateKeyDerivation`, this method will return a public spend key.
151
+ If the public spend key matches your public spend key, the transaction output is yours.
152
+ Returns a string.
153
+
154
+ ## Common Data Structures
155
+
156
+ #### Address
157
+
158
+ ```javascript
159
+ {
160
+ spend: {
161
+ privateKey: '517f0d3c5438416adad752557fdf001acfea189d35af8bba326c86928cc6100e',
162
+ publicKey: '0b5a6ed3fde5470fe13a6e817b5b4caf4ce014e65155ae2f6db66a3b9ad6e819'
163
+ },
164
+ view: {
165
+ privateKey: '40cf3cdab84ef0c2c17c100ffb1ba3cb1c86e22f2c4bed766a465d466b210a0f',
166
+ publicKey: '1909af618bef1ecd30339fe12fb133bbaad05cc0ea365caf02254a5f3ae735df'
167
+ },
168
+ address: 'TRTLuwmU3QWjU77wyHMvBiMdiQdKgj9qfEc3oiEhHfizSu8wZ6K8ZoWQQY57qNmDC48yg6UAHzyTugB9tMohMnUEArSCdrmeUdP',
169
+ mnemonic: 'lagoon much skirting goes okay afield royal cupcake lordship myriad necklace pliers noodles laboratory axes useful poverty igloo diode ablaze nifty inline point ritual necklace',
170
+ seed: '517f0d3c5438416adad752557fdf001acfea189d35af8bba326c86928cc6100e'
171
+ }
172
+ ```
173
+
174
+ #### Decoded Address
175
+
176
+ ```javascript
177
+ { publicViewKey: 'f0ba225065e1b9c2e43165b3e41f10fcb768853126dfa7e612a3df2deb332492',
178
+ publicSpendKey: 'f71e440f9a5aab08dbdab0f4f36bba813660a0600f109b1371dc53be33f23c99',
179
+ paymentId: '',
180
+ encodedPrefix: '9df6ee01',
181
+ prefix: 3914525,
182
+ rawAddress: '9df6ee01f71e440f9a5aab08dbdab0f4f36bba813660a0600f109b1371dc53be33f23c99f0ba225065e1b9c2e43165b3e41f10fcb768853126dfa7e612a3df2deb332492cc073a66' }
183
+ ```
184
+
185
+ #### Decoded Address Prefix
186
+
187
+ ```javascript
188
+ { prefix: '9df6ee01',
189
+ base58: 'TRTL',
190
+ decimal: 3914525,
191
+ hexadecimal: '3bbb1d' }
192
+ ```
193
+
194
+ ### Credits
195
+
196
+ Special thanks goes out to:
197
+
198
+ * Lucas Jones
199
+ * Paul Shapiro
200
+ * Luigi111
201
+ * [The MyMonero Project](https://github.com/mymonero/mymonero-app-js)
202
+ * The Masari Project: [gnock](https://github.com/gnock)
203
+ * The Plentum Project: [DaveLong](https://github.com/DaveLong)
package/config.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "coinUnitPlaces": 2,
3
+ "addressPrefix": 3914525,
4
+ "keccakIterations": 1,
5
+ "defaultNetworkFee": 10,
6
+ "mmMiningBlockVersion": 2
7
+ }
package/docs/.nojekyll ADDED
File without changes
package/docs/CNAME ADDED
@@ -0,0 +1 @@
1
+ utils.turtlecoin.dev