Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Commit

Permalink
Fixes a issue when start the wallet for the second time, and tries to…
Browse files Browse the repository at this point in the history
… send money to anyone.
  • Loading branch information
augustresende committed Jan 12, 2018
1 parent b37bd07 commit 0d04371
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions pages/create.pg
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function finishclick() {
var accs = wallet.getAccounts();
myaddress = accs[0].account;
checkChains(function (){
db.saveWallet(wallet.pack());
console.log("wallet loaded");
clientPoW();
walletloaded = true;
Expand Down
8 changes: 3 additions & 5 deletions pages/login.pg
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ db.getWallet(function (exists, pack) {
wallet.load(pack);
accs = wallet.getAccounts();
myaddress = accs[0].account;
checkChains(function (){
clientPoW();
console.log("Wallet loaded!");
walletloaded = true;
});
clientPoW();
console.log("Wallet loaded!");
walletloaded = true;
PageLoad("home");
}catch(e){
alert(e);
Expand Down
1 change: 1 addition & 0 deletions pages/send.pg
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ $('#sendvalue').submit(function(e) {
}
if(!error) {
try{
console.log("from: "+from+" to: "+to+" amount: "+amountRaw);
var blk = wallet.addPendingSendBlock(from, to, amountRaw);
var hash = blk.getHash(true);

Expand Down
4 changes: 4 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ socket.on('connect', function() {
Object.keys(r.blocks[account]).forEach(function(hash){
try {
wallet.addPendingReceiveBlock(hash, account, r.blocks[account][hash].source, r.blocks[account][hash].amount);
db.saveWallet(wallet.pack());
// Catch error, for debug
} catch(e) {console.log(err);}
});
Expand Down Expand Up @@ -300,9 +301,12 @@ function clientPoW() {
setTimeout(clientPoW, 200);
checkReadyBlocks();
txhistory = wallet.getLastNBlocks(parseXRBAccount(addresses[0]), 100, 0);
console.log("Trying to broadcast");
function checkReadyBlocks(){
console.log("checkReadyBlocks");
var blk = wallet.getNextReadyBlock();
if(blk !== false) {
console.log("broadcasting");
broadcastBlock(blk);
} else {
setTimeout(checkReadyBlocks, 500);
Expand Down

0 comments on commit 0d04371

Please sign in to comment.