Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blockchain-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SaintDizier Corentin
blockchain-project
Commits
30a09594
Commit
30a09594
authored
1 year ago
by
corentinstd
Browse files
Options
Downloads
Patches
Plain Diff
commit tmp
parent
1247428f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/fr/miage/App.java
+6
-4
6 additions, 4 deletions
src/main/java/fr/miage/App.java
src/main/java/fr/miage/Transaction.java
+16
-1
16 additions, 1 deletion
src/main/java/fr/miage/Transaction.java
src/main/java/fr/miage/UTxO.java
+2
-4
2 additions, 4 deletions
src/main/java/fr/miage/UTxO.java
with
24 additions
and
9 deletions
src/main/java/fr/miage/App.java
+
6
−
4
View file @
30a09594
package
fr.miage
;
import
java.security.NoSuchAlgorithmException
;
/**
* Hello world!
*
*/
public
class
App
{
public
static
void
main
(
String
[]
args
)
public
static
void
main
(
String
[]
args
)
throws
NoSuchAlgorithmException
{
System
.
out
.
println
(
"Début de la blockchain"
);
// Création de la blockchain
Blockchain
blockchain
=
new
Blockchain
(
"BloBlockchain"
);
//Création de 2 wallets
Wallet
bobWallet
=
new
Wallet
(
"
publicKey1"
,
"privateKey1
"
);
Wallet
aliceWallet
=
new
Wallet
(
"p
ublicKey
2"
,
"privateKey2"
);
Wallet
bobWallet
=
new
Wallet
(
"
Ceci est la clé privé de bob
"
);
///System.out.println(bob
Wallet
.getP
ublicKey
()
);
//System.out.println(bobWallet.getPrivateKey());
}
}
This diff is collapsed.
Click to expand it.
src/main/java/fr/miage/Transaction.java
+
16
−
1
View file @
30a09594
...
...
@@ -6,9 +6,9 @@ public class Transaction {
private
String
id
;
private
List
<
UTxO
>
inputs
;
private
List
<
UTxO
>
outputs
;
//private double fees;
private
String
signature
;
private
String
typeTransaction
;
private
Bloc
bloc
;
public
Transaction
(
String
id
,
List
<
UTxO
>
inputs
,
List
<
UTxO
>
outputs
,
String
signature
,
String
typeTransaction
)
{
this
.
id
=
id
;
...
...
@@ -16,6 +16,21 @@ public class Transaction {
this
.
outputs
=
outputs
;
this
.
signature
=
signature
;
}
public
void
createTransaction
(
Wallet
fromWallet
,
String
toWallet
,
double
amount
,
List
<
UTxO
>
utxoInput
,
List
<
UTxO
>
utxoOutput
){
//créer transaction normale
this
.
signature
=
fromWallet
.
getPrivateKey
();
}
public
void
createFirstTranscation
(
Wallet
fromWallet
,
String
toWallet
,
double
amount
,
List
<
UTxO
>
utxoInput
,
List
<
UTxO
>
utxoOutput
){
//créer transaction normale
this
.
signature
=
fromWallet
.
getPrivateKey
();
utxoInput
.
add
(
new
UTxO
(
fromWallet
,
null
,
amount
))
}
//créer transaction coinbase
//un bloc avec que des coinbase avec un seul utxo de sortie
}
This diff is collapsed.
Click to expand it.
src/main/java/fr/miage/UTxO.java
+
2
−
4
View file @
30a09594
...
...
@@ -2,13 +2,11 @@ package fr.miage;
public
class
UTxO
{
//UTXO : Hash qui renvoie a la transaction d'avant
private
String
hashWallet
;
// hash du wallet
private
Transaction
transaction
;
// transaction précédente (provenance de l'argent) --> peut etre meme que le hash de la transaction
private
Wallet
hashWallet
;
// hash du wallet
private
double
montant
;
public
UTxO
(
String
hashWallet
,
Transaction
transaction
,
double
montant
)
{
public
UTxO
(
Wallet
hashWallet
,
Transaction
transaction
,
double
montant
)
{
this
.
hashWallet
=
hashWallet
;
this
.
transaction
=
transaction
;
this
.
montant
=
montant
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment