@shakesco/silent 1.1.0 → 1.1.2

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/README.md CHANGED
@@ -207,8 +207,4 @@ function main() {
207
207
 
208
208
  The receiver can use `private_key` to spend the funds!
209
209
 
210
- Thats it! 🎊🎊🎊
211
-
212
- ### Contribute
213
-
214
- If you love what we do to progress privacy, [contribute](https://donate.shakesco.com/@shakesco.sns "shakesco_donate") to further development
210
+ Thats it! 🎊🎊🎊
@@ -200,7 +200,7 @@ class SilentPaymentBuilder {
200
200
  const matches = {};
201
201
  var k = 0;
202
202
 
203
- do {
203
+ while (outputsToCheck.length > 0) {
204
204
  const t_k = taggedHash(
205
205
  Buffer.concat([
206
206
  Buffer.from(ecdhSharedSecret.encodeCompressed(), "array"),
@@ -210,9 +210,11 @@ class SilentPaymentBuilder {
210
210
  );
211
211
 
212
212
  const P_k = tweakAddPublic(B_spend, t_k);
213
- const length = outputsToCheck.length;
214
213
 
215
- for (var i = 0; i < length; i++) {
214
+ let i = 0;
215
+ let foundMatch = false;
216
+
217
+ while (i < outputsToCheck.length) {
216
218
  const output = outputsToCheck[i].script.slice(4);
217
219
  const outputPubkey = output.toString("hex");
218
220
  const outputAmount = Number(outputsToCheck[i].value);
@@ -235,10 +237,14 @@ class SilentPaymentBuilder {
235
237
 
236
238
  outputsToCheck.splice(i, 1);
237
239
  k++;
240
+ foundMatch = true;
238
241
  break;
239
242
  }
240
243
 
241
- if (precomputedLabels != null && precomputedLabels.isNotEmpty) {
244
+ if (
245
+ precomputedLabels != null &&
246
+ Object.keys(precomputedLabels).length > 0
247
+ ) {
242
248
  var m_G_sub = tweakAddPublic(
243
249
  ec.keyFromPublic(Buffer.from(output, "hex")).getPublic(),
244
250
  pubNegate(P_k)
@@ -277,17 +283,19 @@ class SilentPaymentBuilder {
277
283
 
278
284
  outputsToCheck.splice(i, 1);
279
285
  k++;
286
+ foundMatch = true;
280
287
  break;
281
288
  }
282
289
  }
283
290
 
284
- outputsToCheck.splice(i, 1);
291
+ i++;
292
+ }
285
293
 
286
- if (i + 1 >= outputsToCheck.length) {
287
- break;
288
- }
294
+ // If we went through all outputs without finding a match, we're done
295
+ if (!foundMatch) {
296
+ break;
289
297
  }
290
- } while (outputsToCheck.isNotEmpty);
298
+ }
291
299
 
292
300
  return matches;
293
301
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@shakesco/silent",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Bitcoin Silent Payments",
5
5
  "main": "index.js",
6
6
  "author": "Shawn Kimtai",
7
7
  "license": "MIT",
8
8
  "keywords": [
9
9
  "shakesco",
10
- "shakespay",
10
+ "payments",
11
11
  "private",
12
12
  "bitcoin",
13
13
  "silent payments",