Skip to content

Commit

Permalink
lock unlock account
Browse files Browse the repository at this point in the history
  • Loading branch information
lovelycs committed Sep 20, 2018
1 parent e427922 commit 89677a3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Wallet/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class Account {
}

unlock(address, privKey) {
this.addrList = this.addrList || [];
if (this.addrList.indexOf(address) >= 0) {
return;
}
this.addrList.push(address);
this._loopAddr(address, privKey);
}
Expand All @@ -35,7 +39,7 @@ class Account {
if (i < 0) {
return;
}
this.addrList = this.addrList.splice(i, 1);
this.addrList.splice(i, 1);
}

_loopAddr(address, privKey) {
Expand All @@ -52,16 +56,19 @@ class Account {
};

this.Vite.Ledger.getReceiveBlock(address).then((accountBlock)=>{
if (this.addrList.indexOf(address) < 0) {
return;
}

if (!accountBlock) {
loop();
return;
}

let { hash, signature } = this.Vite.Account.signTX(accountBlock, privKey);
accountBlock.hash = hash;
accountBlock.signature = signature;

// [TODO]
console.log(accountBlock);
this.Vite.Ledger.sendTx(accountBlock).then((data)=>{
console.log(data);
}).catch((err)=>{
Expand Down

0 comments on commit 89677a3

Please sign in to comment.