privacycash 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/getUtxos.js CHANGED
@@ -60,6 +60,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
60
60
  const spentFlags = await areUtxosSpent(connection, nonZeroUtxos);
61
61
  for (let i = 0; i < nonZeroUtxos.length; i++) {
62
62
  if (!spentFlags[i]) {
63
+ logger.debug(`found unspent encrypted_output ${nonZeroEncrypted[i]}`);
63
64
  am += nonZeroUtxos[i].amount.toNumber();
64
65
  valid_utxos.push(nonZeroUtxos[i]);
65
66
  valid_strings.push(nonZeroEncrypted[i]);
@@ -80,7 +81,9 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
80
81
  getMyUtxosPromise = null;
81
82
  }
82
83
  // store valid strings
84
+ logger.debug(`valid_strings len before set: ${valid_strings.length}`);
83
85
  valid_strings = [...new Set(valid_strings)];
86
+ logger.debug(`valid_strings len after set: ${valid_strings.length}`);
84
87
  storage.setItem(LSK_ENCRYPTED_OUTPUTS + localstorageKey(publicKey), JSON.stringify(valid_strings));
85
88
  return valid_utxos;
86
89
  })();
@@ -145,19 +148,17 @@ async function fetchUserUtxos({ publicKey, connection, url, storage, encryptionS
145
148
  if (!data.hasMore) {
146
149
  if (cachedString) {
147
150
  let cachedEncryptedOutputs = JSON.parse(cachedString);
148
- for (let encryptedOutput of cachedEncryptedOutputs) {
149
- if (decryptionTaskFinished % 100 == 0) {
150
- logger.info(`(decrypting cached utxo: ${decryptionTaskFinished + 1}/${decryptionTaskTotal}...)`);
151
- }
152
- let batchRes = await decrypt_outputs(cachedEncryptedOutputs, encryptionService, utxoKeypair, lightWasm);
153
- decryptionTaskFinished += cachedEncryptedOutputs.length;
154
- logger.debug('cachedbatchReslen', batchRes.length, ' source', cachedEncryptedOutputs.length);
155
- for (let i = 0; i < batchRes.length; i++) {
156
- let dres = batchRes[i];
157
- if (dres.status == 'decrypted' && dres.utxo) {
158
- myUtxos.push(dres.utxo);
159
- myEncryptedOutputs.push(dres.encryptedOutput);
160
- }
151
+ if (decryptionTaskFinished % 100 == 0) {
152
+ logger.info(`(decrypting cached utxo: ${decryptionTaskFinished + 1}/${decryptionTaskTotal}...)`);
153
+ }
154
+ let batchRes = await decrypt_outputs(cachedEncryptedOutputs, encryptionService, utxoKeypair, lightWasm);
155
+ decryptionTaskFinished += cachedEncryptedOutputs.length;
156
+ logger.debug('cachedbatchReslen', batchRes.length, ' source', cachedEncryptedOutputs.length);
157
+ for (let i = 0; i < batchRes.length; i++) {
158
+ let dres = batchRes[i];
159
+ if (dres.status == 'decrypted' && dres.utxo) {
160
+ myUtxos.push(dres.utxo);
161
+ myEncryptedOutputs.push(dres.encryptedOutput);
161
162
  }
162
163
  }
163
164
  }
package/dist/withdraw.js CHANGED
@@ -74,6 +74,8 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
74
74
  amount: '0'
75
75
  });
76
76
  const inputs = [firstInput, secondInput];
77
+ logger.debug(`firstInput index: ${firstInput.index}, commitment: ${firstInput.getCommitment()}`);
78
+ logger.debug(`secondInput index: ${secondInput.index}, commitment: ${secondInput.getCommitment()}`);
77
79
  const totalInputAmount = firstInput.amount.add(secondInput.amount);
78
80
  logger.debug(`Using UTXO with amount: ${firstInput.amount.toString()} and ${secondInput.amount.gt(new BN(0)) ? 'second UTXO with amount: ' + secondInput.amount.toString() : 'dummy UTXO'}`);
79
81
  if (totalInputAmount.toNumber() === 0) {
@@ -146,6 +148,8 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
146
148
  await outputs[0].log();
147
149
  logger.debug(`\nOutput[1] (empty):`);
148
150
  await outputs[1].log();
151
+ logger.debug(`Encrypted output 1: ${encryptedOutput1.toString('hex')}`);
152
+ logger.debug(`Encrypted output 2: ${encryptedOutput2.toString('hex')}`);
149
153
  logger.debug(`\nEncrypted output 1 size: ${encryptedOutput1.length} bytes`);
150
154
  logger.debug(`Encrypted output 2 size: ${encryptedOutput2.length} bytes`);
151
155
  logger.debug(`Total encrypted outputs size: ${encryptedOutput1.length + encryptedOutput2.length} bytes`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "privacycash",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://github.com/Privacy-Cash/privacy-cash-sdk",
package/src/getUtxos.ts CHANGED
@@ -90,6 +90,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
90
90
  const spentFlags = await areUtxosSpent(connection, nonZeroUtxos);
91
91
  for (let i = 0; i < nonZeroUtxos.length; i++) {
92
92
  if (!spentFlags[i]) {
93
+ logger.debug(`found unspent encrypted_output ${nonZeroEncrypted[i]}`)
93
94
  am += nonZeroUtxos[i].amount.toNumber();
94
95
  valid_utxos.push(nonZeroUtxos[i]);
95
96
  valid_strings.push(nonZeroEncrypted[i]);
@@ -108,7 +109,9 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
108
109
  getMyUtxosPromise = null
109
110
  }
110
111
  // store valid strings
112
+ logger.debug(`valid_strings len before set: ${valid_strings.length}`)
111
113
  valid_strings = [...new Set(valid_strings)];
114
+ logger.debug(`valid_strings len after set: ${valid_strings.length}`)
112
115
  storage.setItem(LSK_ENCRYPTED_OUTPUTS + localstorageKey(publicKey), JSON.stringify(valid_strings))
113
116
  return valid_utxos
114
117
  })()
@@ -188,19 +191,17 @@ async function fetchUserUtxos({ publicKey, connection, url, storage, encryptionS
188
191
  if (!data.hasMore) {
189
192
  if (cachedString) {
190
193
  let cachedEncryptedOutputs = JSON.parse(cachedString)
191
- for (let encryptedOutput of cachedEncryptedOutputs) {
192
- if (decryptionTaskFinished % 100 == 0) {
193
- logger.info(`(decrypting cached utxo: ${decryptionTaskFinished + 1}/${decryptionTaskTotal}...)`)
194
- }
195
- let batchRes = await decrypt_outputs(cachedEncryptedOutputs, encryptionService, utxoKeypair, lightWasm)
196
- decryptionTaskFinished += cachedEncryptedOutputs.length
197
- logger.debug('cachedbatchReslen', batchRes.length, ' source', cachedEncryptedOutputs.length)
198
- for (let i = 0; i < batchRes.length; i++) {
199
- let dres = batchRes[i]
200
- if (dres.status == 'decrypted' && dres.utxo) {
201
- myUtxos.push(dres.utxo)
202
- myEncryptedOutputs.push(dres.encryptedOutput!)
203
- }
194
+ if (decryptionTaskFinished % 100 == 0) {
195
+ logger.info(`(decrypting cached utxo: ${decryptionTaskFinished + 1}/${decryptionTaskTotal}...)`)
196
+ }
197
+ let batchRes = await decrypt_outputs(cachedEncryptedOutputs, encryptionService, utxoKeypair, lightWasm)
198
+ decryptionTaskFinished += cachedEncryptedOutputs.length
199
+ logger.debug('cachedbatchReslen', batchRes.length, ' source', cachedEncryptedOutputs.length)
200
+ for (let i = 0; i < batchRes.length; i++) {
201
+ let dres = batchRes[i]
202
+ if (dres.status == 'decrypted' && dres.utxo) {
203
+ myUtxos.push(dres.utxo)
204
+ myEncryptedOutputs.push(dres.encryptedOutput!)
204
205
  }
205
206
  }
206
207
  }
package/src/withdraw.ts CHANGED
@@ -107,6 +107,8 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
107
107
  });
108
108
 
109
109
  const inputs = [firstInput, secondInput];
110
+ logger.debug(`firstInput index: ${firstInput.index}, commitment: ${firstInput.getCommitment()}`)
111
+ logger.debug(`secondInput index: ${secondInput.index}, commitment: ${secondInput.getCommitment()}`)
110
112
  const totalInputAmount = firstInput.amount.add(secondInput.amount);
111
113
  logger.debug(`Using UTXO with amount: ${firstInput.amount.toString()} and ${secondInput.amount.gt(new BN(0)) ? 'second UTXO with amount: ' + secondInput.amount.toString() : 'dummy UTXO'}`);
112
114
  if (totalInputAmount.toNumber() === 0) {
@@ -192,7 +194,8 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
192
194
  await outputs[0].log();
193
195
  logger.debug(`\nOutput[1] (empty):`);
194
196
  await outputs[1].log();
195
-
197
+ logger.debug(`Encrypted output 1: ${encryptedOutput1.toString('hex')}`)
198
+ logger.debug(`Encrypted output 2: ${encryptedOutput2.toString('hex')}`)
196
199
  logger.debug(`\nEncrypted output 1 size: ${encryptedOutput1.length} bytes`);
197
200
  logger.debug(`Encrypted output 2 size: ${encryptedOutput2.length} bytes`);
198
201
  logger.debug(`Total encrypted outputs size: ${encryptedOutput1.length + encryptedOutput2.length} bytes`);