Skip to content

Commit e9b3d45

Browse files
authored
Merge pull request #15 from GusRuss89/account-colors
Add account colors
2 parents 963a586 + 3d6809f commit e9b3d45

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Wallet.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ module.exports = function (password) {
268268
subscribed: false,
269269
chain: [],
270270
representative: "",
271-
label: ""
271+
label: "",
272+
color: ""
272273
}
273274
for (let k in o) {
274275
key[k] = o[k];
@@ -375,6 +376,7 @@ module.exports = function (password) {
375376
balance: bigInt(keys[i].balance),
376377
pendingBalance: bigInt(keys[i].pendingBalance),
377378
label: keys[i].label,
379+
color: keys[i].color,
378380
lastHash: keys[i].chain.length > 0 ? keys[i].chain[keys[i].chain.length - 1] : false
379381
});
380382
}
@@ -690,6 +692,16 @@ module.exports = function (password) {
690692
return false;
691693
}
692694

695+
api.setColor = function (acc, color) {
696+
for (let i in keys) {
697+
if (keys[i].account == acc) {
698+
keys[i].color = color;
699+
return true;
700+
}
701+
}
702+
return false;
703+
}
704+
693705
api.removePendingBlocks = function () {
694706
current.pendingBlocks = [];
695707
}
@@ -1306,13 +1318,15 @@ module.exports = function (password) {
13061318
pack.accounts.push({
13071319
type: KEY_TYPE.SEEDED,
13081320
label: key.label,
1321+
color: key.color,
13091322
seedIndex: key.seedIndex,
13101323
});
13111324
break;
13121325
case KEY_TYPE.EXPLICIT:
13131326
pack.accounts.push({
13141327
type: KEY_TYPE.EXPLICIT,
13151328
label: key.label,
1329+
color: key.color,
13161330
secretKey: uint8_hex(key.priv),
13171331
});
13181332
break;
@@ -1387,13 +1401,15 @@ module.exports = function (password) {
13871401
case KEY_TYPE.SEEDED: {
13881402
let key = _private.newKeyDataFromSeed(acc.seedIndex);
13891403
key.label = acc.label;
1404+
key.color = acc.color || '';
13901405
_private.addKey(key);
13911406
lastKeyFromSeed = Math.max(lastKeyFromSeed, acc.seedIndex);
13921407
break;
13931408
}
13941409
case KEY_TYPE.EXPLICIT: {
13951410
let key = _private.newKeyDataFromSecret(hex_uint8(acc.secretKey));
13961411
key.label = acc.label;
1412+
key.color = acc.color || '';
13971413
_private.addKey(key);
13981414
break;
13991415
}

0 commit comments

Comments
 (0)