Procházet zdrojové kódy

made project way simpler

Vincent Sima před 6 roky
rodič
revize
8f54c3eecc

+ 115
- 42
.idea/workspace.xml Zobrazit soubor

@@ -2,9 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="86492085-3833-4394-8353-122bd8bc6cb0" name="Default" comment="">
5
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/controller/WalletController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/controller/WalletController.java" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/controller/WalletController$UserController.class" beforeDir="false" />
5
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transactions.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transactions.java" afterDir="false" />
8 6
     </list>
9 7
     <ignored path="$PROJECT_DIR$/target/" />
10 8
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -16,20 +14,11 @@
16 14
   </component>
17 15
   <component name="FileEditorManager">
18 16
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
19
-      <file leaf-file-name="Application.java" pinned="false" current-in-tab="false">
20
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Application.java">
21
-          <provider selected="true" editor-type-id="text-editor">
22
-            <state relative-caret-position="60">
23
-              <caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" />
24
-            </state>
25
-          </provider>
26
-        </entry>
27
-      </file>
28
-      <file leaf-file-name="application.properties" pinned="false" current-in-tab="true">
17
+      <file leaf-file-name="application.properties" pinned="false" current-in-tab="false">
29 18
         <entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
30 19
           <provider selected="true" editor-type-id="text-editor">
31
-            <state relative-caret-position="60">
32
-              <caret line="4" selection-start-line="4" selection-start-column="1" selection-end-line="10" selection-end-column="32" />
20
+            <state relative-caret-position="45">
21
+              <caret line="3" column="36" selection-start-line="3" selection-start-column="36" selection-end-line="3" selection-end-column="36" />
33 22
             </state>
34 23
           </provider>
35 24
         </entry>
@@ -46,11 +35,47 @@
46 35
           </provider>
47 36
         </entry>
48 37
       </file>
49
-      <file leaf-file-name="WalletRepository.java" pinned="false" current-in-tab="false">
50
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Repositories/WalletRepository.java">
38
+      <file leaf-file-name="Block.java" pinned="false" current-in-tab="false">
39
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
51 40
           <provider selected="true" editor-type-id="text-editor">
52
-            <state relative-caret-position="75">
53
-              <caret line="8" lean-forward="true" selection-start-line="8" selection-end-line="8" />
41
+            <state relative-caret-position="28">
42
+              <caret line="24" column="16" lean-forward="true" selection-start-line="24" selection-end-line="25" />
43
+            </state>
44
+          </provider>
45
+        </entry>
46
+      </file>
47
+      <file leaf-file-name="Transactions.java" pinned="false" current-in-tab="true">
48
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transactions.java">
49
+          <provider selected="true" editor-type-id="text-editor">
50
+            <state relative-caret-position="202">
51
+              <caret line="31" column="114" selection-start-line="31" selection-start-column="114" selection-end-line="31" selection-end-column="114" />
52
+              <folding>
53
+                <element signature="imports" expanded="true" />
54
+                <element signature="e#854#855#0" expanded="true" />
55
+                <element signature="e#879#880#0" expanded="true" />
56
+                <element signature="e#913#914#0" expanded="true" />
57
+                <element signature="e#941#942#0" expanded="true" />
58
+                <element signature="e#981#982#0" expanded="true" />
59
+                <element signature="e#1017#1018#0" expanded="true" />
60
+                <element signature="e#1075#1076#0" expanded="true" />
61
+                <element signature="e#1125#1126#0" expanded="true" />
62
+                <element signature="e#1158#1159#0" expanded="true" />
63
+                <element signature="e#1187#1188#0" expanded="true" />
64
+                <element signature="e#1231#1232#0" expanded="true" />
65
+                <element signature="e#1267#1268#0" expanded="true" />
66
+                <element signature="e#1298#1299#0" expanded="true" />
67
+                <element signature="e#1325#1326#0" expanded="true" />
68
+                <element signature="e#1365#1366#0" expanded="true" />
69
+                <element signature="e#1397#1398#0" expanded="true" />
70
+                <element signature="e#1429#1430#0" expanded="true" />
71
+                <element signature="e#1458#1459#0" expanded="true" />
72
+                <element signature="e#1501#1502#0" expanded="true" />
73
+                <element signature="e#1537#1538#0" expanded="true" />
74
+                <element signature="e#1580#1581#0" expanded="true" />
75
+                <element signature="e#1612#1613#0" expanded="true" />
76
+                <element signature="e#1669#1670#0" expanded="true" />
77
+                <element signature="e#1711#1712#0" expanded="true" />
78
+              </folding>
54 79
             </state>
55 80
           </provider>
56 81
         </entry>
@@ -174,14 +199,14 @@
174 199
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/BlockchainVerification.java" />
175 200
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java" />
176 201
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/controller/TransactionController.java" />
177
-        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java" />
178 202
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/Repositories/TransactionRepository.java" />
179 203
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/EnableMongoRepositories.java" />
180 204
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/Application.java" />
181
-        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transactions.java" />
182
-        <option value="$PROJECT_DIR$/src/main/resources/application.properties" />
183 205
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java" />
184 206
         <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/controller/WalletController.java" />
207
+        <option value="$PROJECT_DIR$/src/main/resources/application.properties" />
208
+        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java" />
209
+        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transactions.java" />
185 210
       </list>
186 211
     </option>
187 212
   </component>
@@ -408,7 +433,7 @@
408 433
     <servers />
409 434
   </component>
410 435
   <component name="TimeTrackingManager">
411
-    <option name="totallyTimeSpent" value="8831000" />
436
+    <option name="totallyTimeSpent" value="9498000" />
412 437
   </component>
413 438
   <component name="ToolWindowManager">
414 439
     <frame x="0" y="0" width="1280" height="800" extended-state="6" />
@@ -652,6 +677,30 @@
652 677
           <caret line="117" column="26" selection-start-line="117" selection-start-column="26" selection-end-line="117" selection-end-column="26" />
653 678
           <folding>
654 679
             <element signature="imports" expanded="true" />
680
+            <element signature="e#854#855#0" expanded="true" />
681
+            <element signature="e#879#880#0" expanded="true" />
682
+            <element signature="e#913#914#0" expanded="true" />
683
+            <element signature="e#941#942#0" expanded="true" />
684
+            <element signature="e#981#982#0" expanded="true" />
685
+            <element signature="e#1017#1018#0" expanded="true" />
686
+            <element signature="e#1075#1076#0" expanded="true" />
687
+            <element signature="e#1125#1126#0" expanded="true" />
688
+            <element signature="e#1158#1159#0" expanded="true" />
689
+            <element signature="e#1187#1188#0" expanded="true" />
690
+            <element signature="e#1231#1232#0" expanded="true" />
691
+            <element signature="e#1267#1268#0" expanded="true" />
692
+            <element signature="e#1298#1299#0" expanded="true" />
693
+            <element signature="e#1325#1326#0" expanded="true" />
694
+            <element signature="e#1365#1366#0" expanded="true" />
695
+            <element signature="e#1397#1398#0" expanded="true" />
696
+            <element signature="e#1429#1430#0" expanded="true" />
697
+            <element signature="e#1458#1459#0" expanded="true" />
698
+            <element signature="e#1501#1502#0" expanded="true" />
699
+            <element signature="e#1537#1538#0" expanded="true" />
700
+            <element signature="e#1580#1581#0" expanded="true" />
701
+            <element signature="e#1612#1613#0" expanded="true" />
702
+            <element signature="e#1669#1670#0" expanded="true" />
703
+            <element signature="e#1711#1712#0" expanded="true" />
655 704
           </folding>
656 705
         </state>
657 706
       </provider>
@@ -786,13 +835,6 @@
786 835
         </state>
787 836
       </provider>
788 837
     </entry>
789
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
790
-      <provider selected="true" editor-type-id="text-editor">
791
-        <state relative-caret-position="190">
792
-          <caret line="18" column="20" lean-forward="true" selection-start-line="15" selection-start-column="3" selection-end-line="18" selection-end-column="20" />
793
-        </state>
794
-      </provider>
795
-    </entry>
796 838
     <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/EnableMongoRepositories.java">
797 839
       <provider selected="true" editor-type-id="text-editor">
798 840
         <state relative-caret-position="30">
@@ -800,16 +842,6 @@
800 842
         </state>
801 843
       </provider>
802 844
     </entry>
803
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transactions.java">
804
-      <provider selected="true" editor-type-id="text-editor">
805
-        <state relative-caret-position="586">
806
-          <caret line="51" lean-forward="true" selection-start-line="51" selection-end-line="51" />
807
-          <folding>
808
-            <element signature="imports" expanded="true" />
809
-          </folding>
810
-        </state>
811
-      </provider>
812
-    </entry>
813 845
     <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Application.java">
814 846
       <provider selected="true" editor-type-id="text-editor">
815 847
         <state relative-caret-position="60">
@@ -911,8 +943,49 @@
911 943
     </entry>
912 944
     <entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
913 945
       <provider selected="true" editor-type-id="text-editor">
914
-        <state relative-caret-position="60">
915
-          <caret line="4" selection-start-line="4" selection-start-column="1" selection-end-line="10" selection-end-column="32" />
946
+        <state relative-caret-position="45">
947
+          <caret line="3" column="36" selection-start-line="3" selection-start-column="36" selection-end-line="3" selection-end-column="36" />
948
+        </state>
949
+      </provider>
950
+    </entry>
951
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
952
+      <provider selected="true" editor-type-id="text-editor">
953
+        <state relative-caret-position="28">
954
+          <caret line="24" column="16" lean-forward="true" selection-start-line="24" selection-end-line="25" />
955
+        </state>
956
+      </provider>
957
+    </entry>
958
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transactions.java">
959
+      <provider selected="true" editor-type-id="text-editor">
960
+        <state relative-caret-position="202">
961
+          <caret line="31" column="114" selection-start-line="31" selection-start-column="114" selection-end-line="31" selection-end-column="114" />
962
+          <folding>
963
+            <element signature="imports" expanded="true" />
964
+            <element signature="e#854#855#0" expanded="true" />
965
+            <element signature="e#879#880#0" expanded="true" />
966
+            <element signature="e#913#914#0" expanded="true" />
967
+            <element signature="e#941#942#0" expanded="true" />
968
+            <element signature="e#981#982#0" expanded="true" />
969
+            <element signature="e#1017#1018#0" expanded="true" />
970
+            <element signature="e#1075#1076#0" expanded="true" />
971
+            <element signature="e#1125#1126#0" expanded="true" />
972
+            <element signature="e#1158#1159#0" expanded="true" />
973
+            <element signature="e#1187#1188#0" expanded="true" />
974
+            <element signature="e#1231#1232#0" expanded="true" />
975
+            <element signature="e#1267#1268#0" expanded="true" />
976
+            <element signature="e#1298#1299#0" expanded="true" />
977
+            <element signature="e#1325#1326#0" expanded="true" />
978
+            <element signature="e#1365#1366#0" expanded="true" />
979
+            <element signature="e#1397#1398#0" expanded="true" />
980
+            <element signature="e#1429#1430#0" expanded="true" />
981
+            <element signature="e#1458#1459#0" expanded="true" />
982
+            <element signature="e#1501#1502#0" expanded="true" />
983
+            <element signature="e#1537#1538#0" expanded="true" />
984
+            <element signature="e#1580#1581#0" expanded="true" />
985
+            <element signature="e#1612#1613#0" expanded="true" />
986
+            <element signature="e#1669#1670#0" expanded="true" />
987
+            <element signature="e#1711#1712#0" expanded="true" />
988
+          </folding>
916 989
         </state>
917 990
       </provider>
918 991
     </entry>

+ 0
- 14
src/main/java/com/buecoin01/model/Block.java Zobrazit soubor

@@ -79,18 +79,4 @@ public class Block {
79 79
         System.out.println("You have been awarded 1 Zip!");
80 80
     }
81 81
 
82
-    //add transactions to this block
83
-    public boolean addTransaction(Transactions transactions){
84
-        //process transaction and check if valid, unless block is genesis block then ignore
85
-        if (transactions == null) return false;
86
-        if (previousHash != "0"){
87
-            if (!(transactions.processTransaction())){
88
-                System.out.println("Transaction failed to process. Discarded.");
89
-                return false;
90
-            }
91
-        }
92
-        transactionList.add(transactions);
93
-        System.out.println("Transaction Successfully added to the Block!");
94
-        return true;
95 82
     }
96
-}

+ 47
- 101
src/main/java/com/buecoin01/model/Transactions.java Zobrazit soubor

@@ -10,136 +10,82 @@ import org.springframework.stereotype.Component;
10 10
 import javax.persistence.*;
11 11
 import java.security.PrivateKey;
12 12
 import java.security.PublicKey;
13
+import java.time.LocalDateTime;
13 14
 import java.util.ArrayList;
14 15
 import java.util.List;
15 16
 
16 17
 @Component
17 18
 @Entity
18 19
 public class Transactions {
19
-    @Transient
20
-    private static int sequence = 0; //how many transactions have been generated
21
-    @Transient
22
-    private List <TransactionInput> inputs = new ArrayList <>();
23
-    @Transient
24
-    private List <TransactionOutput> outputs = new ArrayList <>();
25
-    @Transient
26
-    private byte[] signature;
27
-
28 20
     @Id
29 21
     @Column(name = "id")
30 22
     @GeneratedValue(strategy = GenerationType.IDENTITY)
31 23
     private long id;
32 24
 
33 25
     @Column
34
-    private String transactionId; //hash of the transaction
35
-
36
-    private PublicKey sender;
37
-    private PublicKey reciepient;
38
-    private String senderName;
39
-    private String reciepientName;
40
-    private float value;
41
-    private String signature2;
42
-
26
+    private String transactionId;
27
+    private String fromId;
28
+    private String toId;
29
+    private float amount;
30
+    private LocalDateTime timestamp;
31
+
32
+    public Transactions(String transactionId, String fromId, String toId, float amount, LocalDateTime timestamp) {
33
+        this.transactionId = transactionId;
34
+        this.fromId = fromId;
35
+        this.toId = toId;
36
+        this.amount = amount;
37
+        this.timestamp = timestamp;
38
+    }
43 39
 
44
-public Transactions(){}
40
+    public long getId() {
41
+        return id;
42
+    }
45 43
 
46
-    public Transactions( PublicKey from, PublicKey to, float value, ArrayList <TransactionInput> inputs) {
47
-        this.sender = from;
48
-        this.reciepient = to;
49
-        this.value = value;
50
-        this.inputs = inputs;
44
+    public void setId(long id) {
45
+        this.id = id;
51 46
     }
52 47
 
53
-    //generating transactionId
54
-    private String calculateHash() {
55
-        sequence++; //increasing tho avoid identical hash codes
56
-        return Encryption.applySha256(
57
-                Encryption.getStringFromKey( sender ) +
58
-                        Encryption.getStringFromKey( reciepient ) +
59
-                        Float.toString( value ) + sequence
60
-        );
48
+    public String getTransactionId() {
49
+        return transactionId;
61 50
     }
62 51
 
52
+    public void setTransactionId(String transactionId) {
53
+        this.transactionId = transactionId;
54
+    }
63 55
 
64
-    //WRITE METHOD TO TURN SIGNATURE DEOM BYTE ARRAY TO STRING
56
+    public String getFromId() {
57
+        return fromId;
58
+    }
65 59
 
60
+    public void setFromId(String fromId) {
61
+        this.fromId = fromId;
62
+    }
66 63
 
67
-    //Sign all the data that should not be tempered
68
-    public void generateSignature(PrivateKey privateKey) {
69
-        String data = Encryption.getStringFromKey( sender ) + Encryption.getStringFromKey( reciepient ) + Float.toString( value );
70
-        signature = Encryption.applyECDSASig( privateKey, data );
64
+    public String getToId() {
65
+        return toId;
71 66
     }
72 67
 
73
-    //Verify the data we signed hasn't been tampered with
74
-    public boolean verifySignature() {
75
-        String data = Encryption.getStringFromKey( sender ) + Encryption.getStringFromKey( reciepient ) + Float.toString( value );
76
-        return Encryption.verifyECDSASig( sender, data, signature );
68
+    public void setToId(String toId) {
69
+        this.toId = toId;
77 70
     }
78 71
 
79
-    //Check if transaction can be created
80
-    public boolean processTransaction() {
81
-        if ( !verifySignature() ) {
82
-            System.out.println( "Transaction Signature failed to verify" );
83
-            return false;
84
-        }
85
-
86
-        //gather transaction inputs to make sure they're unspent
87
-        for (TransactionInput i : inputs) {
88
-            i.setUTXO( BlockchainVerification.getUTXOs().get( i.getTransactionOutputId() ) );
89
-
90
-        }
91
-        //check if transaction is valid
92
-        if ( getInputsValue() <  BlockchainVerification.minimumTransaction ) {
93
-            System.out.println( "Transaction Input to small: " + getInputsValue() );
94
-            return false;
95
-        }
96
-        //add outputs to Unspent list
97
-        for (TransactionOutput o : outputs) {
98
-            BlockchainVerification.getUTXOs().put( o.getId(), o );
99
-        }
100
-        //remove transaction inputs from UXTO lists as spent
101
-        for (TransactionInput i : inputs) {
102
-            if ( i.getUTXO() == null ) continue; // if Transaction cant be found, skip
103
-            BlockchainVerification.getUTXOs().remove( i.getUTXO().getId() );
104
-        }
105
-        return true;
72
+    public float getAmount() {
73
+        return amount;
106 74
     }
107 75
 
108
-    // returns sum of inputs(UXTOs) values
109
-    public float getInputsValue() {
110
-        float total = 0;
111
-        for (TransactionInput i : inputs) {
112
-            if ( i.getUTXO() == null ) continue; // if Transaction cant be found, skip
113
-            total = total + i.getUTXO().getValue();
114
-        }
115
-        return total;
76
+    public void setAmount(float amount) {
77
+        this.amount = amount;
116 78
     }
117 79
 
118
-    public float getOutPutsValue() {
119
-        float total = 0;
120
-        for (TransactionOutput o : outputs) {
121
-            total = total + o.getValue();
122
-        }
123
-        return total;
80
+    public LocalDateTime getTimestamp() {
81
+        return timestamp;
124 82
     }
125 83
 
126
-    // tacks in array of transactions and returns a merkle root
127
-    public static String getMerkleRoot(ArrayList <Transactions> transactions) {
128
-        int count = transactions.size();
129
-        ArrayList <String> previousTreeLayer = new ArrayList <>();
130
-        for (Transactions transaction : transactions) {
131
-            previousTreeLayer.add( transaction.transactionId );
132
-        }
133
-        ArrayList <String> treeLayer = previousTreeLayer;
134
-        while (count > 1) {
135
-            treeLayer = new ArrayList <>();
136
-            for (int i = 1; i < previousTreeLayer.size(); i++) {
137
-                treeLayer.add( Encryption.applySha256( previousTreeLayer.get( i - 1 ) ) + previousTreeLayer.get( i ) );
138
-            }
139
-            count = treeLayer.size();
140
-            previousTreeLayer = treeLayer;
141
-        }
142
-        String merkleRoot = ( treeLayer.size() == 1 ) ? treeLayer.get( 0 ) : "";
143
-        return merkleRoot;
84
+    public void setTimestamp(LocalDateTime timestamp) {
85
+        this.timestamp = timestamp;
144 86
     }
145
-}
87
+
88
+    public Transactions(){}
89
+
90
+
91
+}

+ 2
- 58
src/main/java/com/buecoin01/model/Wallet.java Zobrazit soubor

@@ -27,6 +27,8 @@ public class Wallet {
27 27
     private String name;
28 28
 
29 29
 
30
+    public Wallet(){}
31
+
30 32
     public Wallet(String publicId, long amount, String name) {
31 33
         this.publicId = publicId;
32 34
         this.amount = amount;
@@ -41,10 +43,6 @@ public class Wallet {
41 43
         this.name = name;
42 44
     }
43 45
 
44
-    public Wallet() {
45
-        //generateKeyPair();
46
-    }
47
-
48 46
     public PrivateKey getPrivateKey() {
49 47
         return privateKey;
50 48
     }
@@ -78,58 +76,4 @@ public class Wallet {
78 76
     public void setId(long id) {
79 77
         this.id = id;
80 78
     }
81
-
82
-//    public void generateKeyPair() {
83
-//        try {
84
-//            KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ECDSA","BC");
85
-//            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
86
-//            ECGenParameterSpec ecSpec = new ECGenParameterSpec("prime192v1");
87
-//
88
-//            keyGen.initialize(ecSpec, random);
89
-//            KeyPair keyPair = keyGen.generateKeyPair();
90
-//            privateKey = keyPair.getPrivate();
91
-//            publicKey = keyPair.getPublic();
92
-//        } catch(Exception e) {
93
-//            throw new RuntimeException(e);
94
-//        }
95
-//    }
96
-    //returns balance and store the UTXO's owned by this wallet in this.UXTOs
97
-    public float getBalance(){
98
-        float total = 0;
99
-        for (Map.Entry<String, TransactionOutput> item: BlockchainVerification.getUTXOs().entrySet()){
100
-            TransactionOutput UTXO = item.getValue();
101
-            if (UTXO.isMine(publicKey)){ //if output belongs to me (if coins belong to me)
102
-                UTXOs.put(UTXO.getId(), UTXO);   // add it to our list of unspent transaction
103
-                total = total + UTXO.getValue();
104
-
105
-            }
106
-        }
107
-        return total;
108
-    }
109
-
110
-    //generates and returns a new transaction from this wallet
111
-
112
-
113
-    public Transactions sendFunds(PublicKey _recipient, float value){
114
-        if(getBalance() < value) {  //gather balance and check funds
115
-            System.out.println("Not Enough Funds. Transaction Discarded.");
116
-            return null;
117
-       }
118
-
119
-       // create arraylist of inputs
120
-        ArrayList<TransactionInput> inputs = new ArrayList<>();
121
-        float total = 0;
122
-        for(Map.Entry<String, TransactionOutput> item: UTXOs.entrySet()){
123
-            TransactionOutput UTXO = item.getValue();
124
-            total= total + UTXO.getValue();
125
-            inputs.add(new TransactionInput(UTXO.getId()));
126
-            if (total > value) break;
127
-        }
128
-        Transactions newTransactions = new Transactions(publicKey, _recipient,value, inputs);
129
-        newTransactions.generateSignature(privateKey);
130
-        for (TransactionInput input : inputs){
131
-            UTXOs.remove(input.getTransactionOutputId());
132
-        }
133
-        return newTransactions;
134
-    }
135 79
 }

binární
target/classes/com/buecoin01/model/Block.class Zobrazit soubor


binární
target/classes/com/buecoin01/model/Transactions.class Zobrazit soubor


binární
target/classes/com/buecoin01/model/Wallet.class Zobrazit soubor