Fixing bin backups, making them completely compatible with the web wallet now
This commit is contained in:
parent
37b783ad89
commit
867cd8d4b3
4 changed files with 31 additions and 11 deletions
|
@ -27,8 +27,12 @@ public class Main {
|
||||||
|
|
||||||
public static final String BILTHON_16_BRAIN_KEY = System.getenv("BILTHON_16_BRAINKEY");
|
public static final String BILTHON_16_BRAIN_KEY = System.getenv("BILTHON_16_BRAINKEY");
|
||||||
|
|
||||||
|
public static final String BILTHON_36_BRAIN_KEY = System.getenv("BILTHON_36_BRAINKEY");
|
||||||
|
|
||||||
public static final String GENERIC_PASSWORD = System.getenv("GENERIC_PASSWORD");
|
public static final String GENERIC_PASSWORD = System.getenv("GENERIC_PASSWORD");
|
||||||
|
|
||||||
|
public static final String DISCLOSABLE_PASSWORD = System.getenv("DISCLOSABLE_PASSWORD");
|
||||||
|
|
||||||
// Static block information used for transaction serialization tests
|
// Static block information used for transaction serialization tests
|
||||||
public static int REF_BLOCK_NUM = 56204;
|
public static int REF_BLOCK_NUM = 56204;
|
||||||
public static int REF_BLOCK_PREFIX = 1614747814;
|
public static int REF_BLOCK_PREFIX = 1614747814;
|
||||||
|
@ -54,7 +58,7 @@ public class Main {
|
||||||
// test.testGetDynamicParams();
|
// test.testGetDynamicParams();
|
||||||
// test.testGetRequiredFeesSerialization();
|
// test.testGetRequiredFeesSerialization();
|
||||||
// test.testRequiredFeesResponse();
|
// test.testRequiredFeesResponse();
|
||||||
test.testTransactionBroadcastSequence();
|
// test.testTransactionBroadcastSequence();
|
||||||
// test.testAccountLookupDeserialization();
|
// test.testAccountLookupDeserialization();
|
||||||
// test.testPrivateKeyManipulations();
|
// test.testPrivateKeyManipulations();
|
||||||
// test.testPublicKeyManipulations();
|
// test.testPublicKeyManipulations();
|
||||||
|
@ -72,7 +76,7 @@ public class Main {
|
||||||
// test.testAccountUpdateOperationBroadcast();
|
// test.testAccountUpdateOperationBroadcast();
|
||||||
// test.testCreateBinFile();
|
// test.testCreateBinFile();
|
||||||
// test.testImportBinFile();
|
// test.testImportBinFile();
|
||||||
// test.testExportBinFile();
|
test.testExportBinFile();
|
||||||
// test.testLzmaCompression();
|
// test.testLzmaCompression();
|
||||||
// test.testLzmaDecompression();
|
// test.testLzmaDecompression();
|
||||||
// test.testSimpleDecompression();
|
// test.testSimpleDecompression();
|
||||||
|
|
|
@ -633,7 +633,7 @@ public class Test {
|
||||||
String password = Main.GENERIC_PASSWORD;
|
String password = Main.GENERIC_PASSWORD;
|
||||||
try {
|
try {
|
||||||
String current = new File(".").getCanonicalPath();
|
String current = new File(".").getCanonicalPath();
|
||||||
File file = new File(current + "/bts_vinicius_default_20170218_20170219.bin");
|
File file = new File(current + "/bilthon-36.bin");
|
||||||
Path path = Paths.get(file.getAbsolutePath());
|
Path path = Paths.get(file.getAbsolutePath());
|
||||||
byte[] data = Files.readAllBytes(path);
|
byte[] data = Files.readAllBytes(path);
|
||||||
byte[] publicKey = new byte[FileBin.PUBLIC_KEY_LENGTH];
|
byte[] publicKey = new byte[FileBin.PUBLIC_KEY_LENGTH];
|
||||||
|
@ -673,12 +673,13 @@ public class Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExportBinFile(){
|
public void testExportBinFile(){
|
||||||
String password = Main.GENERIC_PASSWORD;
|
String password = Main.DISCLOSABLE_PASSWORD;
|
||||||
BrainKey brainKey = new BrainKey(Main.BILTHON_11_BRAIN_KEY, 0);
|
BrainKey brainKey = new BrainKey(Main.BILTHON_36_BRAIN_KEY, 0);
|
||||||
Wallet wallet = new Wallet("bilthon-11", brainKey.getBrainKey(), brainKey.getSequenceNumber(), Chains.BITSHARES.CHAIN_ID, password);
|
String accountName = "bilthon-36";
|
||||||
|
Wallet wallet = new Wallet(accountName, brainKey.getBrainKey(), brainKey.getSequenceNumber(), Chains.BITSHARES.CHAIN_ID, password);
|
||||||
byte[] privateKey = brainKey.getPrivateKey().getPrivKeyBytes();
|
byte[] privateKey = brainKey.getPrivateKey().getPrivKeyBytes();
|
||||||
PrivateKeyBackup privateKeyBackup = new PrivateKeyBackup(privateKey, brainKey.getSequenceNumber(), 1, wallet.getEncryptionKey(password));
|
PrivateKeyBackup privateKeyBackup = new PrivateKeyBackup(privateKey, brainKey.getSequenceNumber(), 1, wallet.getEncryptionKey(password));
|
||||||
LinkedAccount linkedAccount = new LinkedAccount("bilthon-11", Chains.BITSHARES.CHAIN_ID);
|
LinkedAccount linkedAccount = new LinkedAccount(accountName, Chains.BITSHARES.CHAIN_ID);
|
||||||
|
|
||||||
ArrayList<Wallet> walletList = new ArrayList<>();
|
ArrayList<Wallet> walletList = new ArrayList<>();
|
||||||
walletList.add(wallet);
|
walletList.add(wallet);
|
||||||
|
@ -691,7 +692,7 @@ public class Test {
|
||||||
System.out.println("Serialized: "+Util.bytesToHex(serialized));
|
System.out.println("Serialized: "+Util.bytesToHex(serialized));
|
||||||
try {
|
try {
|
||||||
String current = new File(".").getCanonicalPath();
|
String current = new File(".").getCanonicalPath();
|
||||||
String fullPath = current + "/scwall_bilthon_11.bin";
|
String fullPath = current + "/scwall_"+accountName+".bin";
|
||||||
System.out.println("Full path: "+fullPath);
|
System.out.println("Full path: "+fullPath);
|
||||||
File file = new File(fullPath);
|
File file = new File(fullPath);
|
||||||
FileOutputStream out = new FileOutputStream(file);
|
FileOutputStream out = new FileOutputStream(file);
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class SubscriptionResponse {
|
||||||
secondArgument.add(dynamicGlobal);
|
secondArgument.add(dynamicGlobal);
|
||||||
}else if(grapheneObject.getObjectType() == ObjectType.TRANSACTION_OBJECT){
|
}else if(grapheneObject.getObjectType() == ObjectType.TRANSACTION_OBJECT){
|
||||||
BroadcastedTransaction broadcastedTransaction = new BroadcastedTransaction(grapheneObject.getObjectId());
|
BroadcastedTransaction broadcastedTransaction = new BroadcastedTransaction(grapheneObject.getObjectId());
|
||||||
broadcastedTransaction.setTransaction(context.deserialize(jsonObject.get(BroadcastedTransaction.KEY_TRX), Transaction.class));
|
broadcastedTransaction.setTransaction((Transaction) context.deserialize(jsonObject.get(BroadcastedTransaction.KEY_TRX), Transaction.class));
|
||||||
broadcastedTransaction.setTransactionId(jsonObject.get(BroadcastedTransaction.KEY_TRX_ID).getAsString());
|
broadcastedTransaction.setTransactionId(jsonObject.get(BroadcastedTransaction.KEY_TRX_ID).getAsString());
|
||||||
secondArgument.add(broadcastedTransaction);
|
secondArgument.add(broadcastedTransaction);
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package de.bitsharesmunich.graphenej.models.backup;
|
package de.bitsharesmunich.graphenej.models.backup;
|
||||||
|
|
||||||
import de.bitsharesmunich.graphenej.Chains;
|
import de.bitsharesmunich.graphenej.Address;
|
||||||
import de.bitsharesmunich.graphenej.Util;
|
import de.bitsharesmunich.graphenej.Util;
|
||||||
import de.bitsharesmunich.graphenej.crypto.SecureRandomGenerator;
|
import de.bitsharesmunich.graphenej.crypto.SecureRandomGenerator;
|
||||||
|
import org.bitcoinj.core.ECKey;
|
||||||
|
import org.bitcoinj.core.Sha256Hash;
|
||||||
|
import org.spongycastle.crypto.digests.SHA256Digest;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -55,7 +59,18 @@ public class Wallet {
|
||||||
this.brainkey_sequence = brainkeySequence;
|
this.brainkey_sequence = brainkeySequence;
|
||||||
this.chain_id = chainId;
|
this.chain_id = chainId;
|
||||||
|
|
||||||
//TODO: Find out how to fill "password_pubkey" and "brainkey_pubkey" fields.
|
try {
|
||||||
|
byte[] passwordHash = Sha256Hash.hash(password.getBytes("UTF8"));
|
||||||
|
this.password_pubkey = new Address(ECKey.fromPublicOnly(ECKey.fromPrivate(passwordHash).getPubKey())).toString();
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
byte[] brainkeyHash = Sha256Hash.hash(brainKey.getBytes("UTF8"));
|
||||||
|
this.brainkey_pubkey = new Address(ECKey.fromPublicOnly(ECKey.fromPrivate(brainkeyHash).getPubKey())).toString();
|
||||||
|
} catch(UnsupportedEncodingException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(Util.TIME_DATE_FORMAT);
|
SimpleDateFormat dateFormat = new SimpleDateFormat(Util.TIME_DATE_FORMAT);
|
||||||
|
|
Loading…
Reference in a new issue