Skip to content
Snippets Groups Projects
Commit 1247428f authored by corentinstd's avatar corentinstd
Browse files

modif wallet

parent 17e9862a
No related branches found
No related tags found
No related merge requests found
......@@ -9,21 +9,33 @@ public class Wallet {
private String publicKey;
private String privateKey; // pour la signature
private double solde;
private List<UTxO> utxos;
public Wallet(String publicKey, String privateKey) {
this.publicKey = publicKey;
this.privateKey = privateKey;
public Wallet(String privateKey) throws NoSuchAlgorithmException {
this.init(privateKey);
}
public void initWallet(byte[] data) throws NoSuchAlgorithmException{
}
private String hashSha256(String privateKey) throws NoSuchAlgorithmException{
private void init(String privateKey) throws NoSuchAlgorithmException{
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] hash = md.digest(privateKey.getBytes(StandardCharsets.UTF_8));
StringBuilder hashedByte = new StringBuilder();
for(byte b : hash){
hashedByte.append(String.format("%02x", b));
}
this.publicKey = hashedByte.toString();
this.privateKey = privateKey;
this.solde = 20;
this.utxos.add(new UTxO(this, null, solde))
}
public String getPrivateKey() {
return privateKey;
}
public String getPublicKey() {
return publicKey;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment