Skip to content

Commit

Permalink
export: serialize wallet accounts length using uint32.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Aug 7, 2019
1 parent 93788f7 commit 22f6bb6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions lib/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ class WalletDetails extends Struct {
size += 4; // token depth
size += this.master.getSize();

size += 5; // timestamp
size += 33; // joinPubKey

size += 5; // timestamp
size += 1; // accounts length
size += 4; // accounts length

for (const account of this.accounts)
size += account.getSize();
Expand All @@ -332,7 +332,7 @@ class WalletDetails extends Struct {
bw.writeU40(this.timestamp);
bw.writeBytes(this.joinPubKey);

bw.writeU8(this.accounts.length);
bw.writeU32(this.accounts.length);
for (const account of this.accounts)
account.toWriter(bw);

Expand All @@ -355,7 +355,7 @@ class WalletDetails extends Struct {
this.timestamp = br.readU40();
this.joinPubKey = br.readBytes(33);

const accounts = br.readU8();
const accounts = br.readU32();

for (let i = 0; i < accounts; i++) {
const account = new AccountDetails();
Expand Down Expand Up @@ -385,7 +385,6 @@ class WalletDetails extends Struct {
master: this.master.toRaw().toString('hex'),
joinPubKey: this.joinPubKey.toString('hex'),
timestamp: this.timestamp,

accounts: this.accounts.map(a => a.getJSON(network)),
cosigners: this.cosigners.map(c => c.getJSON(network))
};
Expand Down
2 changes: 1 addition & 1 deletion lib/multisigdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ class MultisigDB extends EventEmitter {
/**
* Export wallet. (without lock)
* @param {Number} wid
* @returns [Wallet, Account[], Cosigner[]]
* @returns {WalletDetails}
*/

async _export(wid) {
Expand Down
2 changes: 1 addition & 1 deletion test/data/export.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@
},
"rawCosigner0": "0000000000010101010101010101010101010101010101010101010101010101010101010109636f7369676e6572310000002c352878f10a63636363636363636363eab4fa0503bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90eab695202bad879395e171121982a397d0a8fafb3063eea61d6984824798c08bc85add0852043d1dfd38115082cd78a7de23d6a2e9a5ccc437022ebc07c8e81e57d8f1797be292683aeea5d43c3f25ff0976718ae0b080f4e132f7084630c4b5b7a3d74a99a",
"rawAccount": "030102020100000001000000010000000b03bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90103fa60625880000000fef7d794e8cffe9f3f5a3c0857a7cab9eda6dbfcd53de7110d032ceed55ca3f40396a436242abcb53908c320c7483db796901524fa1a19b4ab15d012ba2f0c1591000000000764656661756c74",
"rawWallet": "0101000000111111111111111111111111111111111111111111111111111111111111111100000000003e04334be01bfa16e233a073d39172060f41f9c60ff4c9cd76b84a80aa74c8847bdb11e514aae4ac284a9b4f8544dfa61a2bcac17f536383122796ec464a438f018000028a85e0467678fc2499e375a76ecbc3dccbd6415d000308c749ece3230fca2a324623963c6ec20c4be9056b0d0089ecb95f1bfbb2939601030102020100000001000000010000000b03bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90103fa60625880000000fef7d794e8cffe9f3f5a3c0857a7cab9eda6dbfcd53de7110d032ceed55ca3f40396a436242abcb53908c320c7483db796901524fa1a19b4ab15d012ba2f0c1591000000000764656661756c74020000000000010101010101010101010101010101010101010101010101010101010101010109636f7369676e6572310000002c352878f10a63636363636363636363eab4fa0503bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90eab695202bad879395e171121982a397d0a8fafb3063eea61d6984824798c08bc85add0852043d1dfd38115082cd78a7de23d6a2e9a5ccc437022ebc07c8e81e57d8f1797be292683aeea5d43c3f25ff0976718ae0b080f4e132f7084630c4b5b7a3d74a99a0100000000020202020202020202020202020202020202020202020202020202020202020209636f7369676e6572320000002c86fff9ce00eab4fa0503fa60625880000000fef7d794e8cffe9f3f5a3c0857a7cab9eda6dbfcd53de7110d032ceed55ca3f40396a436242abcb53908c320c7483db796901524fa1a19b4ab15d012ba2f0c1591b4868c490203c12bbb10cd45afde168b548765106f8255e43142d1250a1551496d31e23b172020342880c3db62e49b6450ce1f55f7334ce5185d6e49e3ae9c2ebe078c82b7f0365e4097fc68ec413606cf3158005daa935941b4a3f36bffee25936b2e25aa15"
"rawWallet": "0101000000111111111111111111111111111111111111111111111111111111111111111100000000003e04334be01bfa16e233a073d39172060f41f9c60ff4c9cd76b84a80aa74c8847bdb11e514aae4ac284a9b4f8544dfa61a2bcac17f536383122796ec464a438f018000028a85e0467678fc2499e375a76ecbc3dccbd6415d000308c749ece3230fca2a324623963c6ec20c4be9056b0d0089ecb95f1bfbb2939601000000030102020100000001000000010000000b03bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90103fa60625880000000fef7d794e8cffe9f3f5a3c0857a7cab9eda6dbfcd53de7110d032ceed55ca3f40396a436242abcb53908c320c7483db796901524fa1a19b4ab15d012ba2f0c1591000000000764656661756c74020000000000010101010101010101010101010101010101010101010101010101010101010109636f7369676e6572310000002c352878f10a63636363636363636363eab4fa0503bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90eab695202bad879395e171121982a397d0a8fafb3063eea61d6984824798c08bc85add0852043d1dfd38115082cd78a7de23d6a2e9a5ccc437022ebc07c8e81e57d8f1797be292683aeea5d43c3f25ff0976718ae0b080f4e132f7084630c4b5b7a3d74a99a0100000000020202020202020202020202020202020202020202020202020202020202020209636f7369676e6572320000002c86fff9ce00eab4fa0503fa60625880000000fef7d794e8cffe9f3f5a3c0857a7cab9eda6dbfcd53de7110d032ceed55ca3f40396a436242abcb53908c320c7483db796901524fa1a19b4ab15d012ba2f0c1591b4868c490203c12bbb10cd45afde168b548765106f8255e43142d1250a1551496d31e23b172020342880c3db62e49b6450ce1f55f7334ce5185d6e49e3ae9c2ebe078c82b7f0365e4097fc68ec413606cf3158005daa935941b4a3f36bffee25936b2e25aa15"
}

0 comments on commit 22f6bb6

Please sign in to comment.