Bladeren bron

transaction class completed

yauhenip 6 jaren geleden
bovenliggende
commit
e32e775029

+ 13
- 0
.idea/libraries/Maven__bouncycastle_bcprov_jdk15_136.xml Bestand weergeven

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: bouncycastle:bcprov-jdk15:136">
3
+    <CLASSES>
4
+      <root url="jar://$MAVEN_REPOSITORY$/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://$MAVEN_REPOSITORY$/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://$MAVEN_REPOSITORY$/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__org_ow2_util_bundles_bouncycastle_java5_136_1_0_0.xml Bestand weergeven

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: org.ow2.util.bundles:bouncycastle-java5-136:1.0.0">
3
+    <CLASSES>
4
+      <root url="jar://$MAVEN_REPOSITORY$/org/ow2/util/bundles/bouncycastle-java5-136/1.0.0/bouncycastle-java5-136-1.0.0.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://$MAVEN_REPOSITORY$/org/ow2/util/bundles/bouncycastle-java5-136/1.0.0/bouncycastle-java5-136-1.0.0-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://$MAVEN_REPOSITORY$/org/ow2/util/bundles/bouncycastle-java5-136/1.0.0/bouncycastle-java5-136-1.0.0-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 197
- 48
.idea/workspace.xml Bestand weergeven

@@ -2,7 +2,22 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="15cb9d44-2114-4e87-9e35-a3d14b1a4bbd" name="Default" comment="">
5
+      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__bouncycastle_bcprov_jdk15_136.xml" afterDir="false" />
6
+      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_ow2_util_bundles_bouncycastle_java5_136_1_0_0.xml" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
8
+      <change beforePath="$PROJECT_DIR$/0.1.iml" beforeDir="false" afterPath="$PROJECT_DIR$/0.1.iml" afterDir="false" />
9
+      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
10
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java" afterDir="false" />
11
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java" afterDir="false" />
5 12
       <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java" afterDir="false" />
13
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java" afterDir="false" />
14
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java" afterDir="false" />
15
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionInput.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionInput.java" afterDir="false" />
16
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionOutput.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionOutput.java" afterDir="false" />
17
+      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/ProcessLoader.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/ProcessLoader.class" afterDir="false" />
18
+      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Blockchain.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Blockchain.class" afterDir="false" />
19
+      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Wallet.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Wallet.class" afterDir="false" />
20
+      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/utility/Encryption.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/utility/Encryption.class" afterDir="false" />
6 21
     </list>
7 22
     <ignored path="$PROJECT_DIR$/target/" />
8 23
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -17,22 +32,26 @@
17 32
       <file leaf-file-name="Wallet.java" pinned="false" current-in-tab="false">
18 33
         <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java">
19 34
           <provider selected="true" editor-type-id="text-editor">
20
-            <state relative-caret-position="105">
21
-              <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
35
+            <state relative-caret-position="1695">
36
+              <caret line="123" column="30" selection-start-line="123" selection-start-column="30" selection-end-line="123" selection-end-column="30" />
22 37
               <folding>
23 38
                 <element signature="imports" expanded="true" />
24 39
                 <element signature="e#549#550#0" expanded="true" />
25 40
                 <element signature="e#571#572#0" expanded="true" />
41
+                <element signature="e#669#670#0" expanded="true" />
42
+                <element signature="e#702#703#0" expanded="true" />
43
+                <element signature="e#841#842#0" expanded="true" />
44
+                <element signature="e#873#874#0" expanded="true" />
26 45
               </folding>
27 46
             </state>
28 47
           </provider>
29 48
         </entry>
30 49
       </file>
31
-      <file leaf-file-name="Transaction.java" pinned="false" current-in-tab="true">
50
+      <file leaf-file-name="Transaction.java" pinned="false" current-in-tab="false">
32 51
         <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java">
33 52
           <provider selected="true" editor-type-id="text-editor">
34
-            <state relative-caret-position="356">
35
-              <caret line="48" column="66" lean-forward="true" selection-start-line="48" selection-start-column="66" selection-end-line="48" selection-end-column="66" />
53
+            <state relative-caret-position="318">
54
+              <caret line="117" column="26" lean-forward="true" selection-start-line="117" selection-start-column="26" selection-end-line="117" selection-end-column="26" />
36 55
               <folding>
37 56
                 <element signature="imports" expanded="true" />
38 57
               </folding>
@@ -43,8 +62,20 @@
43 62
       <file leaf-file-name="TransactionInput.java" pinned="false" current-in-tab="false">
44 63
         <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionInput.java">
45 64
           <provider selected="true" editor-type-id="text-editor">
46
-            <state relative-caret-position="30">
47
-              <caret line="2" column="29" selection-start-line="2" selection-start-column="29" selection-end-line="2" selection-end-column="29" />
65
+            <state relative-caret-position="120">
66
+              <caret line="8" column="10" selection-start-line="8" selection-start-column="10" selection-end-line="8" selection-end-column="10" />
67
+              <folding>
68
+                <element signature="e#237#238#0" expanded="true" />
69
+                <element signature="e#299#300#0" expanded="true" />
70
+                <element signature="e#556#557#0" expanded="true" />
71
+                <element signature="e#598#599#0" expanded="true" />
72
+                <element signature="e#668#669#0" expanded="true" />
73
+                <element signature="e#730#731#0" expanded="true" />
74
+                <element signature="e#772#773#0" expanded="true" />
75
+                <element signature="e#799#800#0" expanded="true" />
76
+                <element signature="e#850#851#0" expanded="true" />
77
+                <element signature="e#882#883#0" expanded="true" />
78
+              </folding>
48 79
             </state>
49 80
           </provider>
50 81
         </entry>
@@ -52,18 +83,38 @@
52 83
       <file leaf-file-name="TransactionOutput.java" pinned="false" current-in-tab="false">
53 84
         <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionOutput.java">
54 85
           <provider selected="true" editor-type-id="text-editor">
55
-            <state relative-caret-position="30">
56
-              <caret line="2" column="30" selection-start-line="2" selection-start-column="30" selection-end-line="2" selection-end-column="30" />
86
+            <state relative-caret-position="314">
87
+              <caret line="25" column="38" lean-forward="true" selection-start-line="25" selection-start-column="38" selection-end-line="25" selection-end-column="38" />
88
+              <folding>
89
+                <element signature="e#651#652#0" expanded="true" />
90
+                <element signature="e#676#677#0" expanded="true" />
91
+                <element signature="e#712#713#0" expanded="true" />
92
+                <element signature="e#740#741#0" expanded="true" />
93
+                <element signature="e#813#814#0" expanded="true" />
94
+                <element signature="e#868#869#0" expanded="true" />
95
+                <element signature="e#912#913#0" expanded="true" />
96
+                <element signature="e#943#944#0" expanded="true" />
97
+                <element signature="e#971#972#0" expanded="true" />
98
+                <element signature="e#1012#1013#0" expanded="true" />
99
+                <element signature="e#1046#1047#0" expanded="true" />
100
+                <element signature="e#1092#1093#0" expanded="true" />
101
+                <element signature="e#1134#1135#0" expanded="true" />
102
+                <element signature="e#1204#1205#0" expanded="true" />
103
+                <element signature="e#1266#1267#0" expanded="true" />
104
+                <element signature="e#717#718#0" expanded="true" />
105
+                <element signature="e#762#763#0" expanded="true" />
106
+              </folding>
57 107
             </state>
58 108
           </provider>
59 109
         </entry>
60 110
       </file>
61
-      <file leaf-file-name="Encryption.java" pinned="false" current-in-tab="false">
111
+      <file leaf-file-name="Encryption.java" pinned="false" current-in-tab="true">
62 112
         <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java">
63 113
           <provider selected="true" editor-type-id="text-editor">
64
-            <state relative-caret-position="108">
65
-              <caret line="30" column="32" lean-forward="true" selection-start-line="30" selection-start-column="32" selection-end-line="30" selection-end-column="32" />
114
+            <state relative-caret-position="510">
115
+              <caret line="36" column="5" lean-forward="true" selection-start-line="36" selection-start-column="5" selection-end-line="36" selection-end-column="5" />
66 116
               <folding>
117
+                <element signature="imports" expanded="true" />
67 118
                 <element signature="e#1683#1684#0" expanded="true" />
68 119
                 <element signature="e#1724#1725#0" expanded="true" />
69 120
               </folding>
@@ -71,11 +122,27 @@
71 122
           </provider>
72 123
         </entry>
73 124
       </file>
125
+      <file leaf-file-name="Block.java" pinned="false" current-in-tab="false">
126
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
127
+          <provider selected="true" editor-type-id="text-editor">
128
+            <state relative-caret-position="567">
129
+              <caret line="50" lean-forward="true" selection-start-line="50" selection-end-line="50" />
130
+            </state>
131
+          </provider>
132
+        </entry>
133
+      </file>
74 134
       <file leaf-file-name="Blockchain.java" pinned="false" current-in-tab="false">
75 135
         <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java">
76 136
           <provider selected="true" editor-type-id="text-editor">
77
-            <state relative-caret-position="55">
78
-              <caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
137
+            <state relative-caret-position="162">
138
+              <caret line="17" column="6" selection-start-line="17" selection-start-column="6" selection-end-line="17" selection-end-column="6" />
139
+              <folding>
140
+                <element signature="imports" expanded="true" />
141
+                <element signature="e#1713#1714#0" expanded="true" />
142
+                <element signature="e#1741#1742#0" expanded="true" />
143
+                <element signature="e#1814#1815#0" expanded="true" />
144
+                <element signature="e#1854#1855#0" expanded="true" />
145
+              </folding>
79 146
             </state>
80 147
           </provider>
81 148
         </entry>
@@ -89,6 +156,11 @@
89 156
       </list>
90 157
     </option>
91 158
   </component>
159
+  <component name="FindInProjectRecents">
160
+    <findStrings>
161
+      <find>applys</find>
162
+    </findStrings>
163
+  </component>
92 164
   <component name="Git.Settings">
93 165
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
94 166
   </component>
@@ -102,9 +174,14 @@
102 174
   <component name="IdeDocumentHistory">
103 175
     <option name="CHANGED_PATHS">
104 176
       <list>
105
-        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java" />
177
+        <option value="$PROJECT_DIR$/pom.xml" />
106 178
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java" />
179
+        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionOutput.java" />
180
+        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionInput.java" />
181
+        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java" />
107 182
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java" />
183
+        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java" />
184
+        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java" />
108 185
       </list>
109 186
     </option>
110 187
   </component>
@@ -117,11 +194,10 @@
117 194
   <component name="NodePackageJsonFileManager">
118 195
     <packageJsonPaths />
119 196
   </component>
120
-  <component name="ProjectFrameBounds">
121
-    <option name="x" value="-57" />
122
-    <option name="y" value="-1047" />
123
-    <option name="width" value="1832" />
124
-    <option name="height" value="903" />
197
+  <component name="ProjectFrameBounds" extendedState="6">
198
+    <option name="y" value="23" />
199
+    <option name="width" value="1440" />
200
+    <option name="height" value="812" />
125 201
   </component>
126 202
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
127 203
   <component name="ProjectView">
@@ -218,6 +294,17 @@
218 294
     </option>
219 295
   </component>
220 296
   <component name="RunManager">
297
+    <configuration name="Blockchain" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
298
+      <option name="MAIN_CLASS_NAME" value="com.buecoin01.model.Blockchain" />
299
+      <module name="0.1" />
300
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
301
+      <extension name="coverage">
302
+        <pattern>
303
+          <option name="PATTERN" value="com.buecoin01.model.*" />
304
+          <option name="ENABLED" value="true" />
305
+        </pattern>
306
+      </extension>
307
+    </configuration>
221 308
     <configuration default="true" type="Application" factoryName="Application">
222 309
       <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
223 310
     </configuration>
@@ -259,6 +346,11 @@
259 346
       <properties />
260 347
       <listeners />
261 348
     </configuration>
349
+    <recent_temporary>
350
+      <list>
351
+        <item itemvalue="Application.Blockchain" />
352
+      </list>
353
+    </recent_temporary>
262 354
   </component>
263 355
   <component name="SvnConfiguration">
264 356
     <configuration />
@@ -270,16 +362,15 @@
270 362
       <option name="number" value="Default" />
271 363
       <option name="presentableId" value="Default" />
272 364
       <updated>1532353115597</updated>
273
-      <workItem from="1532353121145" duration="6982000" />
365
+      <workItem from="1532353121145" duration="22002000" />
274 366
     </task>
275 367
     <servers />
276 368
   </component>
277 369
   <component name="TimeTrackingManager">
278
-    <option name="totallyTimeSpent" value="6982000" />
370
+    <option name="totallyTimeSpent" value="22002000" />
279 371
   </component>
280 372
   <component name="ToolWindowManager">
281
-    <frame x="-57" y="-1047" width="1832" height="903" extended-state="0" />
282
-    <editor active="true" />
373
+    <frame x="0" y="23" width="1440" height="812" extended-state="6" />
283 374
     <layout>
284 375
       <window_info anchor="right" id="Palette" />
285 376
       <window_info anchor="bottom" id="Event Log" side_tool="true" />
@@ -293,15 +384,16 @@
293 384
       <window_info id="UI Designer" />
294 385
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
295 386
       <window_info anchor="bottom" id="TODO" order="6" />
387
+      <window_info anchor="bottom" id="Messages" />
296 388
       <window_info anchor="right" id="Palette&#9;" />
297 389
       <window_info id="Image Layers" />
298 390
       <window_info anchor="bottom" id="Java Enterprise" />
299 391
       <window_info anchor="right" id="Capture Analysis" />
300
-      <window_info anchor="bottom" id="Run" order="2" />
392
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.37062937" />
301 393
       <window_info anchor="bottom" id="Version Control" />
302 394
       <window_info anchor="bottom" id="Spring" />
303
-      <window_info anchor="bottom" id="Terminal" visible="true" weight="0.3287841" />
304
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.19497207" />
395
+      <window_info anchor="bottom" id="Terminal" weight="0.3287841" />
396
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
305 397
       <window_info anchor="right" id="Bean Validation" />
306 398
       <window_info id="Web" side_tool="true" />
307 399
       <window_info anchor="right" id="Theme Preview" />
@@ -335,63 +427,120 @@
335 427
         </state>
336 428
       </provider>
337 429
     </entry>
338
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
430
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Repositories/CoinRepository.java">
339 431
       <provider selected="true" editor-type-id="text-editor">
340 432
         <state relative-caret-position="105">
341
-          <caret line="10" column="13" selection-start-line="10" selection-start-column="13" selection-end-line="10" selection-end-column="13" />
433
+          <caret line="10" column="17" selection-start-line="10" selection-start-column="17" selection-end-line="10" selection-end-column="17" />
342 434
         </state>
343 435
       </provider>
344 436
     </entry>
345
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java">
437
+    <entry file="file://$PROJECT_DIR$/pom.xml">
346 438
       <provider selected="true" editor-type-id="text-editor">
347
-        <state relative-caret-position="55">
348
-          <caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
439
+        <state relative-caret-position="303">
440
+          <caret line="66" column="19" selection-start-line="66" selection-start-column="19" selection-end-line="66" selection-end-column="19" />
349 441
         </state>
350 442
       </provider>
351 443
     </entry>
352
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionInput.java">
444
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
353 445
       <provider selected="true" editor-type-id="text-editor">
354
-        <state relative-caret-position="30">
355
-          <caret line="2" column="29" selection-start-line="2" selection-start-column="29" selection-end-line="2" selection-end-column="29" />
446
+        <state relative-caret-position="567">
447
+          <caret line="50" lean-forward="true" selection-start-line="50" selection-end-line="50" />
356 448
         </state>
357 449
       </provider>
358 450
     </entry>
359
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionOutput.java">
451
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java">
360 452
       <provider selected="true" editor-type-id="text-editor">
361
-        <state relative-caret-position="30">
362
-          <caret line="2" column="30" selection-start-line="2" selection-start-column="30" selection-end-line="2" selection-end-column="30" />
453
+        <state relative-caret-position="162">
454
+          <caret line="17" column="6" selection-start-line="17" selection-start-column="6" selection-end-line="17" selection-end-column="6" />
455
+          <folding>
456
+            <element signature="imports" expanded="true" />
457
+            <element signature="e#1713#1714#0" expanded="true" />
458
+            <element signature="e#1741#1742#0" expanded="true" />
459
+            <element signature="e#1814#1815#0" expanded="true" />
460
+            <element signature="e#1854#1855#0" expanded="true" />
461
+          </folding>
363 462
         </state>
364 463
       </provider>
365 464
     </entry>
366 465
     <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java">
367 466
       <provider selected="true" editor-type-id="text-editor">
368
-        <state relative-caret-position="105">
369
-          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
467
+        <state relative-caret-position="1695">
468
+          <caret line="123" column="30" selection-start-line="123" selection-start-column="30" selection-end-line="123" selection-end-column="30" />
370 469
           <folding>
371 470
             <element signature="imports" expanded="true" />
372 471
             <element signature="e#549#550#0" expanded="true" />
373 472
             <element signature="e#571#572#0" expanded="true" />
473
+            <element signature="e#669#670#0" expanded="true" />
474
+            <element signature="e#702#703#0" expanded="true" />
475
+            <element signature="e#841#842#0" expanded="true" />
476
+            <element signature="e#873#874#0" expanded="true" />
374 477
           </folding>
375 478
         </state>
376 479
       </provider>
377 480
     </entry>
378
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java">
481
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java">
379 482
       <provider selected="true" editor-type-id="text-editor">
380
-        <state relative-caret-position="108">
381
-          <caret line="30" column="32" lean-forward="true" selection-start-line="30" selection-start-column="32" selection-end-line="30" selection-end-column="32" />
483
+        <state relative-caret-position="318">
484
+          <caret line="117" column="26" lean-forward="true" selection-start-line="117" selection-start-column="26" selection-end-line="117" selection-end-column="26" />
382 485
           <folding>
383
-            <element signature="e#1683#1684#0" expanded="true" />
384
-            <element signature="e#1724#1725#0" expanded="true" />
486
+            <element signature="imports" expanded="true" />
385 487
           </folding>
386 488
         </state>
387 489
       </provider>
388 490
     </entry>
389
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java">
491
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionInput.java">
492
+      <provider selected="true" editor-type-id="text-editor">
493
+        <state relative-caret-position="120">
494
+          <caret line="8" column="10" selection-start-line="8" selection-start-column="10" selection-end-line="8" selection-end-column="10" />
495
+          <folding>
496
+            <element signature="e#237#238#0" expanded="true" />
497
+            <element signature="e#299#300#0" expanded="true" />
498
+            <element signature="e#556#557#0" expanded="true" />
499
+            <element signature="e#598#599#0" expanded="true" />
500
+            <element signature="e#668#669#0" expanded="true" />
501
+            <element signature="e#730#731#0" expanded="true" />
502
+            <element signature="e#772#773#0" expanded="true" />
503
+            <element signature="e#799#800#0" expanded="true" />
504
+            <element signature="e#850#851#0" expanded="true" />
505
+            <element signature="e#882#883#0" expanded="true" />
506
+          </folding>
507
+        </state>
508
+      </provider>
509
+    </entry>
510
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionOutput.java">
390 511
       <provider selected="true" editor-type-id="text-editor">
391
-        <state relative-caret-position="356">
392
-          <caret line="48" column="66" lean-forward="true" selection-start-line="48" selection-start-column="66" selection-end-line="48" selection-end-column="66" />
512
+        <state relative-caret-position="314">
513
+          <caret line="25" column="38" lean-forward="true" selection-start-line="25" selection-start-column="38" selection-end-line="25" selection-end-column="38" />
514
+          <folding>
515
+            <element signature="e#651#652#0" expanded="true" />
516
+            <element signature="e#676#677#0" expanded="true" />
517
+            <element signature="e#712#713#0" expanded="true" />
518
+            <element signature="e#740#741#0" expanded="true" />
519
+            <element signature="e#813#814#0" expanded="true" />
520
+            <element signature="e#868#869#0" expanded="true" />
521
+            <element signature="e#912#913#0" expanded="true" />
522
+            <element signature="e#943#944#0" expanded="true" />
523
+            <element signature="e#971#972#0" expanded="true" />
524
+            <element signature="e#1012#1013#0" expanded="true" />
525
+            <element signature="e#1046#1047#0" expanded="true" />
526
+            <element signature="e#1092#1093#0" expanded="true" />
527
+            <element signature="e#1134#1135#0" expanded="true" />
528
+            <element signature="e#1204#1205#0" expanded="true" />
529
+            <element signature="e#1266#1267#0" expanded="true" />
530
+            <element signature="e#717#718#0" expanded="true" />
531
+            <element signature="e#762#763#0" expanded="true" />
532
+          </folding>
533
+        </state>
534
+      </provider>
535
+    </entry>
536
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java">
537
+      <provider selected="true" editor-type-id="text-editor">
538
+        <state relative-caret-position="510">
539
+          <caret line="36" column="5" lean-forward="true" selection-start-line="36" selection-start-column="5" selection-end-line="36" selection-end-column="5" />
393 540
           <folding>
394 541
             <element signature="imports" expanded="true" />
542
+            <element signature="e#1683#1684#0" expanded="true" />
543
+            <element signature="e#1724#1725#0" expanded="true" />
395 544
           </folding>
396 545
         </state>
397 546
       </provider>

+ 2
- 0
0.1.iml Bestand weergeven

@@ -105,5 +105,7 @@
105 105
     <orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.0.7.RELEASE" level="project" />
106 106
     <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.0.7.RELEASE" level="project" />
107 107
     <orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.5.1" level="project" />
108
+    <orderEntry type="library" name="Maven: org.ow2.util.bundles:bouncycastle-java5-136:1.0.0" level="project" />
109
+    <orderEntry type="library" name="Maven: bouncycastle:bcprov-jdk15:136" level="project" />
108 110
   </component>
109 111
 </module>

+ 5
- 0
pom.xml Bestand weergeven

@@ -59,6 +59,11 @@
59 59
 			<artifactId>spring-boot-starter-test</artifactId>
60 60
 			<scope>test</scope>
61 61
 		</dependency>
62
+        <dependency>
63
+            <groupId>org.ow2.util.bundles</groupId>
64
+            <artifactId>bouncycastle-java5-136</artifactId>
65
+            <version>1.0.0</version>
66
+        </dependency>
62 67
 	</dependencies>
63 68
 
64 69
 	<build>

+ 24
- 5
src/main/java/com/buecoin01/model/Block.java Bestand weergeven

@@ -5,6 +5,7 @@ import com.buecoin01.utility.Encryption;
5 5
 
6 6
 import javax.persistence.*;
7 7
 import java.time.LocalDateTime;
8
+import java.util.ArrayList;
8 9
 
9 10
 
10 11
 @Entity
@@ -20,13 +21,16 @@ public class Block {
20 21
     @Column
21 22
     private String hash;
22 23
     private String previousHash;
23
-    private String data;
24
+    //private String data;
25
+    public String merkleRoot;
26
+    public ArrayList<Transaction> transactions = new ArrayList<>();
24 27
     private LocalDateTime timeStamp;
25 28
     private int nonce;
26 29
 
27 30
     public Block(String previousHash, LocalDateTime time) {
28 31
         this.timeStamp = time;
29 32
         this.previousHash = previousHash;
33
+        this.hash = calculateHash();
30 34
     }
31 35
 
32 36
     public String getHash() {
@@ -37,9 +41,9 @@ public class Block {
37 41
         return previousHash;
38 42
     }
39 43
 
40
-    public String getData() {
41
-        return data;
42
-    }
44
+//    public String getData() {
45
+//        return data;
46
+//    }
43 47
 
44 48
     public LocalDateTime getTimeStamp() {
45 49
         return timeStamp;
@@ -50,7 +54,7 @@ public class Block {
50 54
                   previousHash +
51 55
                         timeStamp.toString() +
52 56
                         Integer.toString(nonce) +
53
-                        data);
57
+                        merkleRoot);
54 58
     }
55 59
 
56 60
     public long getId() {
@@ -72,4 +76,19 @@ public class Block {
72 76
         System.out.println("You have been awarded 1 Zip!");
73 77
         Coin coin = new Coin(minerID);
74 78
     }
79
+
80
+    //add transactions to this block
81
+    public boolean addTransaction(Transaction transaction){
82
+        //process transaction and check if valid, unless block is genesis block then ignore
83
+        if (transaction == null) return false;
84
+        if (previousHash != "0"){
85
+            if (!(transaction.processTransaction())){
86
+                System.out.println("Transaction failed to process. Discarded.");
87
+                return false;
88
+            }
89
+        }
90
+        transactions.add(transaction);
91
+        System.out.println("Transaction Successfully added to the Block!");
92
+        return true;
93
+    }
75 94
 }

+ 38
- 2
src/main/java/com/buecoin01/model/Blockchain.java Bestand weergeven

@@ -2,14 +2,42 @@ package com.buecoin01.model;
2 2
 
3 3
 import com.buecoin01.model.Block;
4 4
 import com.buecoin01.utility.Encryption;
5
+import com.buecoin01.utility.TransactionOutput;
5 6
 import com.google.gson.GsonBuilder;
6 7
 
7
-import java.util.ArrayList;
8
-import java.util.List;
8
+import java.security.Security;
9
+import java.util.*;
9 10
 
10 11
 public class Blockchain {
11 12
     private static List<Block> blockchain = new ArrayList<>();
13
+    private static Map<String, TransactionOutput> UTXOs = new HashMap<>();
14
+    public static float minimumTransaction = 0.1f;
12 15
     private static int difficulty = 5;
16
+    public static Wallet walletA;
17
+    public static Wallet walletB;
18
+    //public static Transaction genesisTransaction;
19
+
20
+    public static void main(String[] args) {
21
+        //Setup Bouncey castle as a Security Provider
22
+        Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
23
+
24
+        //Create the new wallets
25
+        walletA = new Wallet();
26
+        walletB = new Wallet();
27
+
28
+        //Test public and private keys
29
+        System.out.println("Private and public keys:");
30
+        System.out.println(Encryption.getStringFromKey(walletA.getPrivateKey()));
31
+        System.out.println(Encryption.getStringFromKey(walletA.getPublicKey()));
32
+        //Create a test transaction from WalletA to walletB
33
+        Transaction transaction = new Transaction(walletA.getPublicKey(), walletB.getPublicKey(), 5, null);
34
+        transaction.generateSignature(walletA.getPrivateKey());
35
+
36
+        //Verify the signature works and verify it from the public key
37
+        System.out.println("Is signature verified");
38
+        System.out.println(transaction.verifySignature());
39
+
40
+    }
13 41
 
14 42
     public String chainToJson() {
15 43
         return new GsonBuilder()
@@ -18,6 +46,14 @@ public class Blockchain {
18 46
                 .toJson(blockchain);
19 47
     }
20 48
 
49
+    public static Map<String, TransactionOutput> getUTXOs() {
50
+        return UTXOs;
51
+    }
52
+
53
+    public static void setUTXOs(Map<String, TransactionOutput> UTXOs) {
54
+        Blockchain.UTXOs = UTXOs;
55
+    }
56
+
21 57
     public static List<Block> getBlockchain() {
22 58
         return blockchain;
23 59
     }

+ 68
- 0
src/main/java/com/buecoin01/model/Transaction.java Bestand weergeven

@@ -13,6 +13,8 @@ public class Transaction {
13 13
     private String transactionId; //hash of the transaction
14 14
     private PublicKey sender;
15 15
     private PublicKey reciepient;
16
+    private String senderName;
17
+    private String reciepientName;
16 18
     private float value;
17 19
     private byte[] signature;
18 20
 
@@ -49,4 +51,70 @@ public class Transaction {
49 51
         String data = Encryption.getStringFromKey(sender) + Encryption.getStringFromKey(reciepient) + Float.toString(value);
50 52
         return Encryption.verifyECDSASig(sender, data, signature);
51 53
     }
54
+
55
+    //Check if transaction can be created
56
+    public boolean processTransaction() {
57
+        if (!verifySignature()) {
58
+            System.out.println("Transaction Signature failed to verify");
59
+            return false;
60
+        }
61
+
62
+        //gather transaction inputs to make sure they're unspent
63
+        for (TransactionInput i : inputs) {
64
+           i.setUTXO(Blockchain.getUTXOs().get(i.getTransactionOutputId()));
65
+
66
+        }
67
+        //check if transaction is valid
68
+        if(getInputsValue()< Blockchain.minimumTransaction){
69
+            System.out.println("Transaction Input to small: " + getInputsValue());
70
+            return false;
71
+        }
72
+        //add outputs to Unspent list
73
+        for (TransactionOutput o : outputs){
74
+            Blockchain.getUTXOs().put(o.getId(),o);
75
+        }
76
+        //remove transaction inputs from UXTO lists as spent
77
+        for(TransactionInput i :inputs){
78
+            if(i.getUTXO() == null) continue; // if Transaction cant be found, skip
79
+            Blockchain.getUTXOs().remove(i.getUTXO().getId());
80
+        }
81
+        return true;
82
+    }
83
+
84
+        // returns sum of inputs(UXTOs) values
85
+    public float getInputsValue(){
86
+        float total = 0;
87
+        for(TransactionInput i : inputs){
88
+            if(i.getUTXO() == null) continue; // if Transaction cant be found, skip
89
+            total= total + i.getUTXO().getValue();
90
+        }
91
+        return total;
92
+    }
93
+
94
+    public float getOutPutsValue(){
95
+        float total = 0;
96
+        for(TransactionOutput o : outputs){
97
+            total = total + o.getValue();
98
+        }
99
+        return total;
100
+    }
101
+    // tacks in array of transactions and returns a merkle root
102
+    public static  String getMerkleRoot(ArrayList<Transaction> transactions){
103
+        int count = transactions.size();
104
+        ArrayList<String> previousTreeLayer = new ArrayList<>();
105
+        for(Transaction transaction: transactions){
106
+            previousTreeLayer.add(transaction.transactionId);
107
+        }
108
+        ArrayList<String> treeLayer = previousTreeLayer;
109
+        while(count > 1){
110
+            treeLayer = new ArrayList<>();
111
+            for(int i = 1; i < previousTreeLayer.size();i++){
112
+             treeLayer.add(Encryption.applySha256(previousTreeLayer.get(i-1)) + previousTreeLayer.get(i));
113
+            }
114
+            count = treeLayer.size();
115
+            previousTreeLayer = treeLayer;
116
+        }
117
+        String merkleRoot = (treeLayer.size() == 1) ? treeLayer.get(0) : "";
118
+        return merkleRoot;
119
+    }
52 120
 }

+ 55
- 0
src/main/java/com/buecoin01/model/Wallet.java Bestand weergeven

@@ -1,14 +1,21 @@
1 1
 package com.buecoin01.model;
2 2
 
3
+import com.buecoin01.utility.TransactionInput;
4
+import com.buecoin01.utility.TransactionOutput;
5
+
3 6
 import javax.persistence.*;
4 7
 import java.security.*;
5 8
 import java.security.spec.ECGenParameterSpec;
9
+import java.util.ArrayList;
10
+import java.util.HashMap;
11
+import java.util.Map;
6 12
 
7 13
 @Entity
8 14
 public class Wallet {
9 15
 
10 16
     private PrivateKey privateKey;
11 17
     private PublicKey publicKey;
18
+    public HashMap<String, TransactionOutput> UTXOs = new HashMap<>(); // only UTXOs owned by this wallet
12 19
     @Id
13 20
     @Column(name = "id")
14 21
     @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -28,6 +35,15 @@ public class Wallet {
28 35
     public Wallet() {
29 36
         generateKeyPair();
30 37
     }
38
+
39
+    public PrivateKey getPrivateKey() {
40
+        return privateKey;
41
+    }
42
+
43
+    public PublicKey getPublicKey() {
44
+        return publicKey;
45
+    }
46
+
31 47
     public long getAmount() {
32 48
         return amount;
33 49
     }
@@ -68,4 +84,43 @@ public class Wallet {
68 84
             throw new RuntimeException(e);
69 85
         }
70 86
     }
87
+    //returns balance and store the UTXO's owned by this wallet in this.UXTOs
88
+    public float getBalance(){
89
+        float total = 0;
90
+        for (Map.Entry<String, TransactionOutput> item: Blockchain.getUTXOs().entrySet()){
91
+            TransactionOutput UTXO = item.getValue();
92
+            if (UTXO.isMine(publicKey)){ //if output belongs to me (if coins belong to me)
93
+                UTXOs.put(UTXO.getId(), UTXO);   // add it to our list of unspent transaction
94
+                total = total + UTXO.getValue();
95
+
96
+            }
97
+        }
98
+        return total;
99
+    }
100
+
101
+    //generates and returns a new transaction from this wallet
102
+
103
+
104
+    public Transaction sendFunds(PublicKey _recipient, float value){
105
+        if(getBalance() < value) {  //gather balance and check funds
106
+            System.out.println("Not Enough Funds. Transaction Discarded.");
107
+            return null;
108
+       }
109
+
110
+       // create arraylist of inputs
111
+        ArrayList<TransactionInput> inputs = new ArrayList<>();
112
+        float total = 0;
113
+        for(Map.Entry<String, TransactionOutput> item: UTXOs.entrySet()){
114
+            TransactionOutput UTXO = item.getValue();
115
+            total= total + UTXO.getValue();
116
+            inputs.add(new TransactionInput(UTXO.getId()));
117
+            if (total > value) break;
118
+        }
119
+        Transaction newTransaction = new Transaction(publicKey, _recipient,value, inputs);
120
+        newTransaction.generateSignature(privateKey);
121
+        for (TransactionInput input : inputs){
122
+            UTXOs.remove(input.getTransactionOutputId());
123
+        }
124
+        return newTransaction;
125
+    }
71 126
 }

+ 1
- 1
src/main/java/com/buecoin01/utility/Encryption.java Bestand weergeven

@@ -23,7 +23,7 @@ public class Encryption {
23 23
     //Apply ECDSA Signature and return result as bytes
24 24
     public static byte[] applyECDSASig(PrivateKey privateKey, String input) {
25 25
         Signature dsa;
26
-        byte[] realSig = new byte[0];
26
+        byte[] realSig;
27 27
         try {
28 28
             dsa = Signature.getInstance("ECDSA","BC");
29 29
             dsa.initSign(privateKey);

+ 27
- 1
src/main/java/com/buecoin01/utility/TransactionInput.java Bestand weergeven

@@ -1,4 +1,30 @@
1 1
 package com.buecoin01.utility;
2 2
 
3
+
4
+//This class will be used to reference TransactionOutputs that have not yet been spent.
5
+//The transactionOutputId will be used to find the relevant TransactionOutput, allowing miners to check your ownership.
3 6
 public class TransactionInput {
4
-}
7
+    private String transactionOutputId;
8
+   // private TransactionOutput UTXO; // UTXO means Unspent Transaction Outputs
9
+   private TransactionOutput UTXO;
10
+
11
+    public TransactionInput(String transactionOutputId) {
12
+        this.transactionOutputId = transactionOutputId;
13
+    }
14
+
15
+    public String getTransactionOutputId() {
16
+        return transactionOutputId;
17
+    }
18
+
19
+    public void setTransactionOutputId(String transactionOutputId) {
20
+        this.transactionOutputId = transactionOutputId;
21
+    }
22
+
23
+    public TransactionOutput getUTXO() {
24
+        return UTXO;
25
+    }
26
+
27
+    public void setUTXO(TransactionOutput UTXO) {
28
+        this.UTXO = UTXO;
29
+    }
30
+}

+ 50
- 0
src/main/java/com/buecoin01/utility/TransactionOutput.java Bestand weergeven

@@ -1,4 +1,54 @@
1 1
 package com.buecoin01.utility;
2 2
 
3
+import java.security.PublicKey;
4
+
3 5
 public class TransactionOutput {
6
+    private String id;
7
+    private PublicKey reciepient; //new owner of the coins
8
+    private float value; //the amount of coins they own
9
+    private String parentTransactionId;
10
+
11
+    public TransactionOutput(PublicKey reciepient, float value, String parentTransactionId) {
12
+        this.reciepient = reciepient;
13
+        this.value = value;
14
+        this.parentTransactionId = parentTransactionId;
15
+        this.id = Encryption.applySha256(Encryption.getStringFromKey(reciepient)+Float.toString(value)+parentTransactionId);
16
+    }
17
+
18
+    public String getId() {
19
+        return id;
20
+    }
21
+
22
+    public void setId(String id) {
23
+        this.id = id;
24
+    }
25
+
26
+    public PublicKey getReciepient() {
27
+        return reciepient;
28
+    }
29
+
30
+    public void setReciepient(PublicKey reciepient) {
31
+        this.reciepient = reciepient;
32
+    }
33
+
34
+    public float getValue() {
35
+        return value;
36
+    }
37
+
38
+    public void setValue(float value) {
39
+        this.value = value;
40
+    }
41
+
42
+    public String getParentTransactionId() {
43
+        return parentTransactionId;
44
+    }
45
+
46
+    public void setParentTransactionId(String parentTransactionId) {
47
+        this.parentTransactionId = parentTransactionId;
48
+    }
49
+
50
+    //Check if coin belongs to publicKey
51
+    public boolean isMine(PublicKey publicKey) {
52
+        return publicKey == reciepient;
53
+    }
4 54
 }

BIN
target/classes/com/buecoin01/ProcessLoader.class Bestand weergeven


BIN
target/classes/com/buecoin01/model/Block.class Bestand weergeven


BIN
target/classes/com/buecoin01/model/Blockchain.class Bestand weergeven


BIN
target/classes/com/buecoin01/model/Transaction.class Bestand weergeven


BIN
target/classes/com/buecoin01/model/Wallet.class Bestand weergeven


BIN
target/classes/com/buecoin01/utility/Encryption.class Bestand weergeven


BIN
target/classes/com/buecoin01/utility/TransactionInput.class Bestand weergeven


BIN
target/classes/com/buecoin01/utility/TransactionOutput.class Bestand weergeven