@bsv/sdk 1.2.20 → 1.2.21

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.
Files changed (154) hide show
  1. package/dist/cjs/package.json +3 -3
  2. package/dist/cjs/src/auth/Peer.js +536 -0
  3. package/dist/cjs/src/auth/Peer.js.map +1 -0
  4. package/dist/cjs/src/auth/SessionManager.js +66 -0
  5. package/dist/cjs/src/auth/SessionManager.js.map +1 -0
  6. package/dist/cjs/src/auth/{Certificate.js → certificates/Certificate.js} +22 -26
  7. package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -0
  8. package/dist/cjs/src/auth/certificates/MasterCertificate.js +79 -0
  9. package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -0
  10. package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +49 -0
  11. package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -0
  12. package/dist/cjs/src/auth/certificates/index.js +25 -0
  13. package/dist/cjs/src/auth/certificates/index.js.map +1 -0
  14. package/dist/cjs/src/auth/clients/AuthFetch.js +411 -0
  15. package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -0
  16. package/dist/cjs/src/auth/clients/index.js +18 -0
  17. package/dist/cjs/src/auth/clients/index.js.map +1 -0
  18. package/dist/cjs/src/auth/index.js +20 -5
  19. package/dist/cjs/src/auth/index.js.map +1 -1
  20. package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +259 -0
  21. package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -0
  22. package/dist/cjs/src/auth/transports/index.js +18 -0
  23. package/dist/cjs/src/auth/transports/index.js.map +1 -0
  24. package/dist/cjs/src/auth/types.js +3 -0
  25. package/dist/cjs/src/auth/types.js.map +1 -0
  26. package/dist/cjs/src/auth/utils/certificateHelpers.js +51 -0
  27. package/dist/cjs/src/auth/utils/certificateHelpers.js.map +1 -0
  28. package/dist/cjs/src/auth/utils/createNonce.js +19 -0
  29. package/dist/cjs/src/auth/utils/createNonce.js.map +1 -0
  30. package/dist/cjs/src/auth/utils/getVerifiableCertificates.js +31 -0
  31. package/dist/cjs/src/auth/utils/getVerifiableCertificates.js.map +1 -0
  32. package/dist/cjs/src/auth/utils/index.js +21 -0
  33. package/dist/cjs/src/auth/utils/index.js.map +1 -0
  34. package/dist/cjs/src/auth/utils/validateCertificates.js +42 -0
  35. package/dist/cjs/src/auth/utils/validateCertificates.js.map +1 -0
  36. package/dist/cjs/src/auth/utils/verifyNonce.js +27 -0
  37. package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -0
  38. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +1 -1
  39. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  40. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +148 -148
  41. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  42. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  43. package/dist/esm/src/auth/Peer.js +533 -0
  44. package/dist/esm/src/auth/Peer.js.map +1 -0
  45. package/dist/esm/src/auth/SessionManager.js +63 -0
  46. package/dist/esm/src/auth/SessionManager.js.map +1 -0
  47. package/dist/esm/src/auth/{Certificate.js → certificates/Certificate.js} +1 -2
  48. package/dist/esm/src/auth/certificates/Certificate.js.map +1 -0
  49. package/dist/esm/src/auth/certificates/MasterCertificate.js +73 -0
  50. package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -0
  51. package/dist/esm/src/auth/certificates/VerifiableCertificate.js +44 -0
  52. package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -0
  53. package/dist/esm/src/auth/certificates/index.js +4 -0
  54. package/dist/esm/src/auth/certificates/index.js.map +1 -0
  55. package/dist/esm/src/auth/clients/AuthFetch.js +409 -0
  56. package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -0
  57. package/dist/esm/src/auth/clients/index.js +2 -0
  58. package/dist/esm/src/auth/clients/index.js.map +1 -0
  59. package/dist/esm/src/auth/index.js +7 -1
  60. package/dist/esm/src/auth/index.js.map +1 -1
  61. package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +258 -0
  62. package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -0
  63. package/dist/esm/src/auth/transports/index.js +2 -0
  64. package/dist/esm/src/auth/transports/index.js.map +1 -0
  65. package/dist/esm/src/auth/types.js +2 -0
  66. package/dist/esm/src/auth/types.js.map +1 -0
  67. package/dist/esm/src/auth/utils/certificateHelpers.js +47 -0
  68. package/dist/esm/src/auth/utils/certificateHelpers.js.map +1 -0
  69. package/dist/esm/src/auth/utils/createNonce.js +16 -0
  70. package/dist/esm/src/auth/utils/createNonce.js.map +1 -0
  71. package/dist/esm/src/auth/utils/getVerifiableCertificates.js +27 -0
  72. package/dist/esm/src/auth/utils/getVerifiableCertificates.js.map +1 -0
  73. package/dist/esm/src/auth/utils/index.js +5 -0
  74. package/dist/esm/src/auth/utils/index.js.map +1 -0
  75. package/dist/esm/src/auth/utils/validateCertificates.js +38 -0
  76. package/dist/esm/src/auth/utils/validateCertificates.js.map +1 -0
  77. package/dist/esm/src/auth/utils/verifyNonce.js +24 -0
  78. package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -0
  79. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1 -1
  80. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  81. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +1 -1
  82. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  83. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  84. package/dist/types/src/auth/Peer.d.ts +193 -0
  85. package/dist/types/src/auth/Peer.d.ts.map +1 -0
  86. package/dist/types/src/auth/SessionManager.d.ts +42 -0
  87. package/dist/types/src/auth/SessionManager.d.ts.map +1 -0
  88. package/dist/types/src/auth/{Certificate.d.ts → certificates/Certificate.d.ts} +1 -1
  89. package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -0
  90. package/dist/types/src/auth/certificates/MasterCertificate.d.ts +38 -0
  91. package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -0
  92. package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts +26 -0
  93. package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -0
  94. package/dist/types/src/auth/certificates/index.d.ts +4 -0
  95. package/dist/types/src/auth/certificates/index.d.ts.map +1 -0
  96. package/dist/types/src/auth/clients/AuthFetch.d.ts +87 -0
  97. package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -0
  98. package/dist/types/src/auth/clients/index.d.ts +2 -0
  99. package/dist/types/src/auth/clients/index.d.ts.map +1 -0
  100. package/dist/types/src/auth/index.d.ts +7 -1
  101. package/dist/types/src/auth/index.d.ts.map +1 -1
  102. package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts +51 -0
  103. package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts.map +1 -0
  104. package/dist/types/src/auth/transports/index.d.ts +2 -0
  105. package/dist/types/src/auth/transports/index.d.ts.map +1 -0
  106. package/dist/types/src/auth/types.d.ts +31 -0
  107. package/dist/types/src/auth/types.d.ts.map +1 -0
  108. package/dist/types/src/auth/utils/certificateHelpers.d.ts +26 -0
  109. package/dist/types/src/auth/utils/certificateHelpers.d.ts.map +1 -0
  110. package/dist/types/src/auth/utils/createNonce.d.ts +8 -0
  111. package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -0
  112. package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +13 -0
  113. package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -0
  114. package/dist/types/src/auth/utils/index.d.ts +5 -0
  115. package/dist/types/src/auth/utils/index.d.ts.map +1 -0
  116. package/dist/types/src/auth/utils/validateCertificates.d.ts +12 -0
  117. package/dist/types/src/auth/utils/validateCertificates.d.ts.map +1 -0
  118. package/dist/types/src/auth/utils/verifyNonce.d.ts +9 -0
  119. package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -0
  120. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  121. package/dist/umd/bundle.js +1 -1
  122. package/docs/README.md +1 -0
  123. package/docs/auth.md +1119 -0
  124. package/package.json +13 -3
  125. package/src/auth/Peer.ts +600 -0
  126. package/src/auth/SessionManager.ts +71 -0
  127. package/src/auth/__tests/Peer.test.ts +599 -0
  128. package/src/auth/__tests/SessionManager.test.ts +87 -0
  129. package/src/auth/{Certificate.ts → certificates/Certificate.ts} +15 -8
  130. package/src/auth/certificates/MasterCertificate.ts +106 -0
  131. package/src/auth/certificates/VerifiableCertificate.ts +73 -0
  132. package/src/auth/certificates/__tests/Certificate.test.ts +282 -0
  133. package/src/auth/certificates/index.ts +3 -0
  134. package/src/auth/clients/AuthFetch.ts +482 -0
  135. package/src/auth/clients/index.ts +1 -0
  136. package/src/auth/index.ts +7 -1
  137. package/src/auth/transports/SimplifiedFetchTransport.ts +288 -0
  138. package/src/auth/transports/index.ts +1 -0
  139. package/src/auth/types.ts +41 -0
  140. package/src/auth/utils/__tests/cryptononce.test.ts +84 -0
  141. package/src/auth/utils/__tests/getVerifiableCertificates.test.ts +126 -0
  142. package/src/auth/utils/__tests/validateCertificates.test.ts +142 -0
  143. package/src/auth/utils/certificateHelpers.ts +86 -0
  144. package/src/auth/utils/createNonce.ts +16 -0
  145. package/src/auth/utils/getVerifiableCertificates.ts +40 -0
  146. package/src/auth/utils/index.ts +4 -0
  147. package/src/auth/utils/validateCertificates.ts +54 -0
  148. package/src/auth/utils/verifyNonce.ts +27 -0
  149. package/src/wallet/substrates/WalletWireProcessor.ts +1 -1
  150. package/src/wallet/substrates/WalletWireTransceiver.ts +1 -1
  151. package/dist/cjs/src/auth/Certificate.js.map +0 -1
  152. package/dist/esm/src/auth/Certificate.js.map +0 -1
  153. package/dist/types/src/auth/Certificate.d.ts.map +0 -1
  154. package/src/auth/__tests/Certificate.test.ts +0 -282
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const Certificate_js_1 = __importDefault(require("../../auth/Certificate.js"));
7
- const index_js_1 = require("../../primitives/index.js");
6
+ const index_js_1 = require("../../auth/index.js");
7
+ const index_js_2 = require("../../primitives/index.js");
8
8
  const WalletWireCalls_js_1 = __importDefault(require("./WalletWireCalls.js"));
9
9
  const WalletError_js_1 = require("../WalletError.js");
10
10
  /**
@@ -15,9 +15,9 @@ class WalletWireTransceiver {
15
15
  this.wire = wire;
16
16
  }
17
17
  async transmit(call, originator = '', params = []) {
18
- const frameWriter = new index_js_1.Utils.Writer();
18
+ const frameWriter = new index_js_2.Utils.Writer();
19
19
  frameWriter.writeUInt8(WalletWireCalls_js_1.default[call]);
20
- const originatorArray = index_js_1.Utils.toArray(originator, 'utf8');
20
+ const originatorArray = index_js_2.Utils.toArray(originator, 'utf8');
21
21
  frameWriter.writeUInt8(originatorArray.length);
22
22
  frameWriter.write(originatorArray);
23
23
  if (params.length > 0) {
@@ -25,7 +25,7 @@ class WalletWireTransceiver {
25
25
  }
26
26
  const frame = frameWriter.toArray();
27
27
  const result = await this.wire.transmitToWallet(frame);
28
- const resultReader = new index_js_1.Utils.Reader(result);
28
+ const resultReader = new index_js_2.Utils.Reader(result);
29
29
  const errorByte = resultReader.readUInt8();
30
30
  if (errorByte === 0) {
31
31
  const resultFrame = resultReader.read();
@@ -35,20 +35,20 @@ class WalletWireTransceiver {
35
35
  // Deserialize the error message length
36
36
  const errorMessageLength = resultReader.readVarIntNum();
37
37
  const errorMessageBytes = resultReader.read(errorMessageLength);
38
- const errorMessage = index_js_1.Utils.toUTF8(errorMessageBytes);
38
+ const errorMessage = index_js_2.Utils.toUTF8(errorMessageBytes);
39
39
  // Deserialize the stack trace length
40
40
  const stackTraceLength = resultReader.readVarIntNum();
41
41
  const stackTraceBytes = resultReader.read(stackTraceLength);
42
- const stackTrace = index_js_1.Utils.toUTF8(stackTraceBytes);
42
+ const stackTrace = index_js_2.Utils.toUTF8(stackTraceBytes);
43
43
  // Construct a custom wallet error
44
44
  const e = new WalletError_js_1.WalletError(errorMessage, errorByte, stackTrace);
45
45
  throw e;
46
46
  }
47
47
  }
48
48
  async createAction(args, originator) {
49
- const paramWriter = new index_js_1.Utils.Writer();
49
+ const paramWriter = new index_js_2.Utils.Writer();
50
50
  // Serialize description
51
- const descriptionBytes = index_js_1.Utils.toArray(args.description, 'utf8');
51
+ const descriptionBytes = index_js_2.Utils.toArray(args.description, 'utf8');
52
52
  paramWriter.writeVarIntNum(descriptionBytes.length);
53
53
  paramWriter.write(descriptionBytes);
54
54
  // input BEEF
@@ -67,7 +67,7 @@ class WalletWireTransceiver {
67
67
  paramWriter.write(this.encodeOutpoint(input.outpoint));
68
68
  // unlockingScript / unlockingScriptLength
69
69
  if (input.unlockingScript) {
70
- const unlockingScriptBytes = index_js_1.Utils.toArray(input.unlockingScript, 'hex');
70
+ const unlockingScriptBytes = index_js_2.Utils.toArray(input.unlockingScript, 'hex');
71
71
  paramWriter.writeVarIntNum(unlockingScriptBytes.length);
72
72
  paramWriter.write(unlockingScriptBytes);
73
73
  }
@@ -76,7 +76,7 @@ class WalletWireTransceiver {
76
76
  paramWriter.writeVarIntNum(input.unlockingScriptLength);
77
77
  }
78
78
  // inputDescription
79
- const inputDescriptionBytes = index_js_1.Utils.toArray(input.inputDescription, 'utf8');
79
+ const inputDescriptionBytes = index_js_2.Utils.toArray(input.inputDescription, 'utf8');
80
80
  paramWriter.writeVarIntNum(inputDescriptionBytes.length);
81
81
  paramWriter.write(inputDescriptionBytes);
82
82
  // sequenceNumber
@@ -96,18 +96,18 @@ class WalletWireTransceiver {
96
96
  paramWriter.writeVarIntNum(args.outputs.length);
97
97
  for (const output of args.outputs) {
98
98
  // lockingScript
99
- const lockingScriptBytes = index_js_1.Utils.toArray(output.lockingScript, 'hex');
99
+ const lockingScriptBytes = index_js_2.Utils.toArray(output.lockingScript, 'hex');
100
100
  paramWriter.writeVarIntNum(lockingScriptBytes.length);
101
101
  paramWriter.write(lockingScriptBytes);
102
102
  // satoshis
103
103
  paramWriter.writeVarIntNum(output.satoshis);
104
104
  // outputDescription
105
- const outputDescriptionBytes = index_js_1.Utils.toArray(output.outputDescription, 'utf8');
105
+ const outputDescriptionBytes = index_js_2.Utils.toArray(output.outputDescription, 'utf8');
106
106
  paramWriter.writeVarIntNum(outputDescriptionBytes.length);
107
107
  paramWriter.write(outputDescriptionBytes);
108
108
  // basket
109
109
  if (output.basket) {
110
- const basketBytes = index_js_1.Utils.toArray(output.basket, 'utf8');
110
+ const basketBytes = index_js_2.Utils.toArray(output.basket, 'utf8');
111
111
  paramWriter.writeVarIntNum(basketBytes.length);
112
112
  paramWriter.write(basketBytes);
113
113
  }
@@ -116,7 +116,7 @@ class WalletWireTransceiver {
116
116
  }
117
117
  // customInstructions
118
118
  if (output.customInstructions) {
119
- const customInstructionsBytes = index_js_1.Utils.toArray(output.customInstructions, 'utf8');
119
+ const customInstructionsBytes = index_js_2.Utils.toArray(output.customInstructions, 'utf8');
120
120
  paramWriter.writeVarIntNum(customInstructionsBytes.length);
121
121
  paramWriter.write(customInstructionsBytes);
122
122
  }
@@ -127,7 +127,7 @@ class WalletWireTransceiver {
127
127
  if (output.tags) {
128
128
  paramWriter.writeVarIntNum(output.tags.length);
129
129
  for (const tag of output.tags) {
130
- const tagBytes = index_js_1.Utils.toArray(tag, 'utf8');
130
+ const tagBytes = index_js_2.Utils.toArray(tag, 'utf8');
131
131
  paramWriter.writeVarIntNum(tagBytes.length);
132
132
  paramWriter.write(tagBytes);
133
133
  }
@@ -158,7 +158,7 @@ class WalletWireTransceiver {
158
158
  if (args.labels) {
159
159
  paramWriter.writeVarIntNum(args.labels.length);
160
160
  for (const label of args.labels) {
161
- const labelBytes = index_js_1.Utils.toArray(label, 'utf8');
161
+ const labelBytes = index_js_2.Utils.toArray(label, 'utf8');
162
162
  paramWriter.writeVarIntNum(labelBytes.length);
163
163
  paramWriter.write(labelBytes);
164
164
  }
@@ -194,7 +194,7 @@ class WalletWireTransceiver {
194
194
  if (args.options.knownTxids) {
195
195
  paramWriter.writeVarIntNum(args.options.knownTxids.length);
196
196
  for (const txid of args.options.knownTxids) {
197
- const txidBytes = index_js_1.Utils.toArray(txid, 'hex');
197
+ const txidBytes = index_js_2.Utils.toArray(txid, 'hex');
198
198
  paramWriter.write(txidBytes);
199
199
  }
200
200
  }
@@ -229,7 +229,7 @@ class WalletWireTransceiver {
229
229
  if (args.options.sendWith) {
230
230
  paramWriter.writeVarIntNum(args.options.sendWith.length);
231
231
  for (const txid of args.options.sendWith) {
232
- const txidBytes = index_js_1.Utils.toArray(txid, 'hex');
232
+ const txidBytes = index_js_2.Utils.toArray(txid, 'hex');
233
233
  paramWriter.write(txidBytes);
234
234
  }
235
235
  }
@@ -249,13 +249,13 @@ class WalletWireTransceiver {
249
249
  }
250
250
  // Transmit and parse response
251
251
  const result = await this.transmit('createAction', originator, paramWriter.toArray());
252
- const resultReader = new index_js_1.Utils.Reader(result);
252
+ const resultReader = new index_js_2.Utils.Reader(result);
253
253
  const response = {};
254
254
  // Parse txid
255
255
  const txidFlag = resultReader.readInt8();
256
256
  if (txidFlag === 1) {
257
257
  const txidBytes = resultReader.read(32);
258
- response.txid = index_js_1.Utils.toHex(txidBytes);
258
+ response.txid = index_js_2.Utils.toHex(txidBytes);
259
259
  }
260
260
  // Parse tx
261
261
  const txFlag = resultReader.readInt8();
@@ -278,7 +278,7 @@ class WalletWireTransceiver {
278
278
  response.sendWithResults = [];
279
279
  for (let i = 0; i < sendWithResultsLength; i++) {
280
280
  const txidBytes = resultReader.read(32);
281
- const txid = index_js_1.Utils.toHex(txidBytes);
281
+ const txid = index_js_2.Utils.toHex(txidBytes);
282
282
  const statusCode = resultReader.readInt8();
283
283
  let status;
284
284
  if (statusCode === 1)
@@ -299,13 +299,13 @@ class WalletWireTransceiver {
299
299
  const referenceBytes = resultReader.read(referenceLength);
300
300
  response.signableTransaction = {
301
301
  tx,
302
- reference: index_js_1.Utils.toBase64(referenceBytes)
302
+ reference: index_js_2.Utils.toBase64(referenceBytes)
303
303
  };
304
304
  }
305
305
  return response;
306
306
  }
307
307
  async signAction(args, originator) {
308
- const paramWriter = new index_js_1.Utils.Writer();
308
+ const paramWriter = new index_js_2.Utils.Writer();
309
309
  // Serialize spends
310
310
  const spendIndexes = Object.keys(args.spends);
311
311
  paramWriter.writeVarIntNum(spendIndexes.length);
@@ -313,7 +313,7 @@ class WalletWireTransceiver {
313
313
  paramWriter.writeVarIntNum(Number(index));
314
314
  const spend = args.spends[Number(index)];
315
315
  // unlockingScript
316
- const unlockingScriptBytes = index_js_1.Utils.toArray(spend.unlockingScript, 'hex');
316
+ const unlockingScriptBytes = index_js_2.Utils.toArray(spend.unlockingScript, 'hex');
317
317
  paramWriter.writeVarIntNum(unlockingScriptBytes.length);
318
318
  paramWriter.write(unlockingScriptBytes);
319
319
  // sequenceNumber
@@ -325,7 +325,7 @@ class WalletWireTransceiver {
325
325
  }
326
326
  }
327
327
  // Serialize reference
328
- const referenceBytes = index_js_1.Utils.toArray(args.reference, 'base64');
328
+ const referenceBytes = index_js_2.Utils.toArray(args.reference, 'base64');
329
329
  paramWriter.writeVarIntNum(referenceBytes.length);
330
330
  paramWriter.write(referenceBytes);
331
331
  // Serialize options
@@ -356,7 +356,7 @@ class WalletWireTransceiver {
356
356
  if (args.options.sendWith) {
357
357
  paramWriter.writeVarIntNum(args.options.sendWith.length);
358
358
  for (const txid of args.options.sendWith) {
359
- const txidBytes = index_js_1.Utils.toArray(txid, 'hex');
359
+ const txidBytes = index_js_2.Utils.toArray(txid, 'hex');
360
360
  paramWriter.write(txidBytes);
361
361
  }
362
362
  }
@@ -369,13 +369,13 @@ class WalletWireTransceiver {
369
369
  }
370
370
  // Transmit and parse response
371
371
  const result = await this.transmit('signAction', originator, paramWriter.toArray());
372
- const resultReader = new index_js_1.Utils.Reader(result);
372
+ const resultReader = new index_js_2.Utils.Reader(result);
373
373
  const response = {};
374
374
  // Parse txid
375
375
  const txidFlag = resultReader.readInt8();
376
376
  if (txidFlag === 1) {
377
377
  const txidBytes = resultReader.read(32);
378
- response.txid = index_js_1.Utils.toHex(txidBytes);
378
+ response.txid = index_js_2.Utils.toHex(txidBytes);
379
379
  }
380
380
  // Parse tx
381
381
  const txFlag = resultReader.readInt8();
@@ -389,7 +389,7 @@ class WalletWireTransceiver {
389
389
  response.sendWithResults = [];
390
390
  for (let i = 0; i < sendWithResultsLength; i++) {
391
391
  const txidBytes = resultReader.read(32);
392
- const txid = index_js_1.Utils.toHex(txidBytes);
392
+ const txid = index_js_2.Utils.toHex(txidBytes);
393
393
  const statusCode = resultReader.readInt8();
394
394
  let status;
395
395
  if (statusCode === 1)
@@ -404,15 +404,15 @@ class WalletWireTransceiver {
404
404
  return response;
405
405
  }
406
406
  async abortAction(args, originator) {
407
- await this.transmit('abortAction', originator, index_js_1.Utils.toArray(args.reference, 'base64'));
407
+ await this.transmit('abortAction', originator, index_js_2.Utils.toArray(args.reference, 'base64'));
408
408
  return { aborted: true };
409
409
  }
410
410
  async listActions(args, originator) {
411
- const paramWriter = new index_js_1.Utils.Writer();
411
+ const paramWriter = new index_js_2.Utils.Writer();
412
412
  // Serialize labels
413
413
  paramWriter.writeVarIntNum(args.labels.length);
414
414
  for (const label of args.labels) {
415
- const labelBytes = index_js_1.Utils.toArray(label, 'utf8');
415
+ const labelBytes = index_js_2.Utils.toArray(label, 'utf8');
416
416
  paramWriter.writeVarIntNum(labelBytes.length);
417
417
  paramWriter.write(labelBytes);
418
418
  }
@@ -460,13 +460,13 @@ class WalletWireTransceiver {
460
460
  paramWriter.writeInt8(typeof args.seekPermission === 'boolean' ? args.seekPermission ? 1 : 0 : -1);
461
461
  // Transmit and parse response
462
462
  const result = await this.transmit('listActions', originator, paramWriter.toArray());
463
- const resultReader = new index_js_1.Utils.Reader(result);
463
+ const resultReader = new index_js_2.Utils.Reader(result);
464
464
  const totalActions = resultReader.readVarIntNum();
465
465
  const actions = [];
466
466
  for (let i = 0; i < totalActions; i++) {
467
467
  // Parse action fields
468
468
  const txidBytes = resultReader.read(32);
469
- const txid = index_js_1.Utils.toHex(txidBytes);
469
+ const txid = index_js_2.Utils.toHex(txidBytes);
470
470
  const satoshis = resultReader.readVarIntNum();
471
471
  const statusCode = resultReader.readInt8();
472
472
  let status;
@@ -498,7 +498,7 @@ class WalletWireTransceiver {
498
498
  const isOutgoing = resultReader.readInt8() === 1;
499
499
  const descriptionLength = resultReader.readVarIntNum();
500
500
  const descriptionBytes = resultReader.read(descriptionLength);
501
- const description = index_js_1.Utils.toUTF8(descriptionBytes);
501
+ const description = index_js_2.Utils.toUTF8(descriptionBytes);
502
502
  const action = {
503
503
  txid,
504
504
  satoshis,
@@ -515,7 +515,7 @@ class WalletWireTransceiver {
515
515
  for (let j = 0; j < labelsLength; j++) {
516
516
  const labelLength = resultReader.readVarIntNum();
517
517
  const labelBytes = resultReader.read(labelLength);
518
- action.labels.push(index_js_1.Utils.toUTF8(labelBytes));
518
+ action.labels.push(index_js_2.Utils.toUTF8(labelBytes));
519
519
  }
520
520
  }
521
521
  // Parse version and lockTime
@@ -533,19 +533,19 @@ class WalletWireTransceiver {
533
533
  let sourceLockingScript;
534
534
  if (sourceLockingScriptLength >= 0) {
535
535
  const sourceLockingScriptBytes = resultReader.read(sourceLockingScriptLength);
536
- sourceLockingScript = index_js_1.Utils.toHex(sourceLockingScriptBytes);
536
+ sourceLockingScript = index_js_2.Utils.toHex(sourceLockingScriptBytes);
537
537
  }
538
538
  // unlockingScript
539
539
  const unlockingScriptLength = resultReader.readVarIntNum();
540
540
  let unlockingScript;
541
541
  if (unlockingScriptLength >= 0) {
542
542
  const unlockingScriptBytes = resultReader.read(unlockingScriptLength);
543
- unlockingScript = index_js_1.Utils.toHex(unlockingScriptBytes);
543
+ unlockingScript = index_js_2.Utils.toHex(unlockingScriptBytes);
544
544
  }
545
545
  // inputDescription
546
546
  const inputDescriptionLength = resultReader.readVarIntNum();
547
547
  const inputDescriptionBytes = resultReader.read(inputDescriptionLength);
548
- const inputDescription = index_js_1.Utils.toUTF8(inputDescriptionBytes);
548
+ const inputDescription = index_js_2.Utils.toUTF8(inputDescriptionBytes);
549
549
  // sequenceNumber
550
550
  const sequenceNumber = resultReader.readVarIntNum();
551
551
  action.inputs.push({
@@ -570,19 +570,19 @@ class WalletWireTransceiver {
570
570
  let lockingScript;
571
571
  if (lockingScriptLength >= 0) {
572
572
  const lockingScriptBytes = resultReader.read(lockingScriptLength);
573
- lockingScript = index_js_1.Utils.toHex(lockingScriptBytes);
573
+ lockingScript = index_js_2.Utils.toHex(lockingScriptBytes);
574
574
  }
575
575
  const spendable = resultReader.readInt8() === 1;
576
576
  // outputDescription
577
577
  const outputDescriptionLength = resultReader.readVarIntNum();
578
578
  const outputDescriptionBytes = resultReader.read(outputDescriptionLength);
579
- const outputDescription = index_js_1.Utils.toUTF8(outputDescriptionBytes);
579
+ const outputDescription = index_js_2.Utils.toUTF8(outputDescriptionBytes);
580
580
  // basket
581
581
  const basketLength = resultReader.readVarIntNum();
582
582
  let basket;
583
583
  if (basketLength >= 0) {
584
584
  const basketBytes = resultReader.read(basketLength);
585
- basket = index_js_1.Utils.toUTF8(basketBytes);
585
+ basket = index_js_2.Utils.toUTF8(basketBytes);
586
586
  }
587
587
  // tags
588
588
  const tagsLength = resultReader.readVarIntNum();
@@ -591,7 +591,7 @@ class WalletWireTransceiver {
591
591
  for (let m = 0; m < tagsLength; m++) {
592
592
  const tagLength = resultReader.readVarIntNum();
593
593
  const tagBytes = resultReader.read(tagLength);
594
- tags.push(index_js_1.Utils.toUTF8(tagBytes));
594
+ tags.push(index_js_2.Utils.toUTF8(tagBytes));
595
595
  }
596
596
  }
597
597
  // customInstructions
@@ -599,7 +599,7 @@ class WalletWireTransceiver {
599
599
  let customInstructions;
600
600
  if (customInstructionsLength >= 0) {
601
601
  const customInstructionsBytes = resultReader.read(customInstructionsLength);
602
- customInstructions = index_js_1.Utils.toUTF8(customInstructionsBytes);
602
+ customInstructions = index_js_2.Utils.toUTF8(customInstructionsBytes);
603
603
  }
604
604
  action.outputs.push({
605
605
  outputIndex,
@@ -621,7 +621,7 @@ class WalletWireTransceiver {
621
621
  };
622
622
  }
623
623
  async internalizeAction(args, originator) {
624
- const paramWriter = new index_js_1.Utils.Writer();
624
+ const paramWriter = new index_js_2.Utils.Writer();
625
625
  paramWriter.writeVarIntNum(args.tx.length);
626
626
  paramWriter.write(args.tx);
627
627
  paramWriter.writeVarIntNum(args.outputs.length);
@@ -629,21 +629,21 @@ class WalletWireTransceiver {
629
629
  paramWriter.writeVarIntNum(out.outputIndex);
630
630
  if (out.protocol === 'wallet payment') {
631
631
  paramWriter.writeUInt8(1);
632
- paramWriter.write(index_js_1.Utils.toArray(out.paymentRemittance.senderIdentityKey, 'hex'));
633
- const derivationPrefixAsArray = index_js_1.Utils.toArray(out.paymentRemittance.derivationPrefix, 'base64');
632
+ paramWriter.write(index_js_2.Utils.toArray(out.paymentRemittance.senderIdentityKey, 'hex'));
633
+ const derivationPrefixAsArray = index_js_2.Utils.toArray(out.paymentRemittance.derivationPrefix, 'base64');
634
634
  paramWriter.writeVarIntNum(derivationPrefixAsArray.length);
635
635
  paramWriter.write(derivationPrefixAsArray);
636
- const derivationSuffixAsArray = index_js_1.Utils.toArray(out.paymentRemittance.derivationSuffix, 'base64');
636
+ const derivationSuffixAsArray = index_js_2.Utils.toArray(out.paymentRemittance.derivationSuffix, 'base64');
637
637
  paramWriter.writeVarIntNum(derivationSuffixAsArray.length);
638
638
  paramWriter.write(derivationSuffixAsArray);
639
639
  }
640
640
  else {
641
641
  paramWriter.writeUInt8(2);
642
- const basketAsArray = index_js_1.Utils.toArray(out.insertionRemittance.basket, 'utf8');
642
+ const basketAsArray = index_js_2.Utils.toArray(out.insertionRemittance.basket, 'utf8');
643
643
  paramWriter.writeVarIntNum(basketAsArray.length);
644
644
  paramWriter.write(basketAsArray);
645
645
  if (typeof out.insertionRemittance.customInstructions) {
646
- const customInstructionsAsArray = index_js_1.Utils.toArray(out.insertionRemittance.customInstructions, 'utf8');
646
+ const customInstructionsAsArray = index_js_2.Utils.toArray(out.insertionRemittance.customInstructions, 'utf8');
647
647
  paramWriter.writeVarIntNum(customInstructionsAsArray.length);
648
648
  paramWriter.write(customInstructionsAsArray);
649
649
  }
@@ -653,7 +653,7 @@ class WalletWireTransceiver {
653
653
  if (typeof out.insertionRemittance.tags === 'object') {
654
654
  paramWriter.writeVarIntNum(out.insertionRemittance.tags.length);
655
655
  for (const tag of out.insertionRemittance.tags) {
656
- const tagAsArray = index_js_1.Utils.toArray(tag, 'utf8');
656
+ const tagAsArray = index_js_2.Utils.toArray(tag, 'utf8');
657
657
  paramWriter.writeVarIntNum(tagAsArray.length);
658
658
  paramWriter.write(tagAsArray);
659
659
  }
@@ -666,7 +666,7 @@ class WalletWireTransceiver {
666
666
  if (typeof args.labels === 'object') {
667
667
  paramWriter.writeVarIntNum(args.labels.length);
668
668
  for (const l of args.labels) {
669
- const labelAsArray = index_js_1.Utils.toArray(l, 'utf8');
669
+ const labelAsArray = index_js_2.Utils.toArray(l, 'utf8');
670
670
  paramWriter.writeVarIntNum(labelAsArray.length);
671
671
  paramWriter.write(labelAsArray);
672
672
  }
@@ -674,7 +674,7 @@ class WalletWireTransceiver {
674
674
  else {
675
675
  paramWriter.writeVarIntNum(-1);
676
676
  }
677
- const descriptionAsArray = index_js_1.Utils.toArray(args.description);
677
+ const descriptionAsArray = index_js_2.Utils.toArray(args.description);
678
678
  paramWriter.writeVarIntNum(descriptionAsArray.length);
679
679
  paramWriter.write(descriptionAsArray);
680
680
  // Serialize seekPermission
@@ -683,14 +683,14 @@ class WalletWireTransceiver {
683
683
  return { accepted: true };
684
684
  }
685
685
  async listOutputs(args, originator) {
686
- const paramWriter = new index_js_1.Utils.Writer();
687
- const basketAsArray = index_js_1.Utils.toArray(args.basket, 'utf8');
686
+ const paramWriter = new index_js_2.Utils.Writer();
687
+ const basketAsArray = index_js_2.Utils.toArray(args.basket, 'utf8');
688
688
  paramWriter.writeVarIntNum(basketAsArray.length);
689
689
  paramWriter.write(basketAsArray);
690
690
  if (typeof args.tags === 'object') {
691
691
  paramWriter.writeVarIntNum(args.tags.length);
692
692
  for (const tag of args.tags) {
693
- const tagAsArray = index_js_1.Utils.toArray(tag, 'utf8');
693
+ const tagAsArray = index_js_2.Utils.toArray(tag, 'utf8');
694
694
  paramWriter.writeVarIntNum(tagAsArray.length);
695
695
  paramWriter.write(tagAsArray);
696
696
  }
@@ -749,7 +749,7 @@ class WalletWireTransceiver {
749
749
  // Serialize seekPermission
750
750
  paramWriter.writeInt8(typeof args.seekPermission === 'boolean' ? args.seekPermission ? 1 : 0 : -1);
751
751
  const result = await this.transmit('listOutputs', originator, paramWriter.toArray());
752
- const resultReader = new index_js_1.Utils.Reader(result);
752
+ const resultReader = new index_js_2.Utils.Reader(result);
753
753
  const totalOutputs = resultReader.readVarIntNum();
754
754
  const beefLength = resultReader.readVarIntNum();
755
755
  let BEEF = undefined;
@@ -767,18 +767,18 @@ class WalletWireTransceiver {
767
767
  };
768
768
  const scriptLength = resultReader.readVarIntNum();
769
769
  if (scriptLength >= 0) {
770
- output.lockingScript = index_js_1.Utils.toHex(resultReader.read(scriptLength));
770
+ output.lockingScript = index_js_2.Utils.toHex(resultReader.read(scriptLength));
771
771
  }
772
772
  const customInstructionsLength = resultReader.readVarIntNum();
773
773
  if (customInstructionsLength >= 0) {
774
- output.customInstructions = index_js_1.Utils.toUTF8(resultReader.read(customInstructionsLength));
774
+ output.customInstructions = index_js_2.Utils.toUTF8(resultReader.read(customInstructionsLength));
775
775
  }
776
776
  const tagsLength = resultReader.readVarIntNum();
777
777
  if (tagsLength !== -1) {
778
778
  const tags = [];
779
779
  for (let i = 0; i < tagsLength; i++) {
780
780
  const tagLength = resultReader.readVarIntNum();
781
- tags.push(index_js_1.Utils.toUTF8(resultReader.read(tagLength)));
781
+ tags.push(index_js_2.Utils.toUTF8(resultReader.read(tagLength)));
782
782
  }
783
783
  output.tags = tags;
784
784
  }
@@ -787,7 +787,7 @@ class WalletWireTransceiver {
787
787
  const labels = [];
788
788
  for (let i = 0; i < labelsLength; i++) {
789
789
  const labelLength = resultReader.readVarIntNum();
790
- labels.push(index_js_1.Utils.toUTF8(resultReader.read(labelLength)));
790
+ labels.push(index_js_2.Utils.toUTF8(resultReader.read(labelLength)));
791
791
  }
792
792
  output.labels = labels;
793
793
  }
@@ -800,8 +800,8 @@ class WalletWireTransceiver {
800
800
  };
801
801
  }
802
802
  async relinquishOutput(args, originator) {
803
- const paramWriter = new index_js_1.Utils.Writer();
804
- const basketAsArray = index_js_1.Utils.toArray(args.basket, 'utf8');
803
+ const paramWriter = new index_js_2.Utils.Writer();
804
+ const basketAsArray = index_js_2.Utils.toArray(args.basket, 'utf8');
805
805
  paramWriter.writeVarIntNum(basketAsArray.length);
806
806
  paramWriter.write(basketAsArray);
807
807
  paramWriter.write(this.encodeOutpoint(args.output));
@@ -809,19 +809,19 @@ class WalletWireTransceiver {
809
809
  return { relinquished: true };
810
810
  }
811
811
  encodeOutpoint(outpoint) {
812
- const writer = new index_js_1.Utils.Writer();
812
+ const writer = new index_js_2.Utils.Writer();
813
813
  const [txid, index] = outpoint.split('.');
814
- writer.write(index_js_1.Utils.toArray(txid, 'hex'));
814
+ writer.write(index_js_2.Utils.toArray(txid, 'hex'));
815
815
  writer.writeVarIntNum(Number(index));
816
816
  return writer.toArray();
817
817
  }
818
818
  readOutpoint(reader) {
819
- const txid = index_js_1.Utils.toHex(reader.read(32));
819
+ const txid = index_js_2.Utils.toHex(reader.read(32));
820
820
  const index = reader.readVarIntNum();
821
821
  return `${txid}.${index}`;
822
822
  }
823
823
  async getPublicKey(args, originator) {
824
- const paramWriter = new index_js_1.Utils.Writer();
824
+ const paramWriter = new index_js_2.Utils.Writer();
825
825
  paramWriter.writeUInt8(args.identityKey ? 1 : 0);
826
826
  if (!args.identityKey) {
827
827
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
@@ -839,21 +839,21 @@ class WalletWireTransceiver {
839
839
  paramWriter.writeInt8(typeof args.seekPermission === 'boolean' ? args.seekPermission ? 1 : 0 : -1);
840
840
  const result = await this.transmit('getPublicKey', originator, paramWriter.toArray());
841
841
  return {
842
- publicKey: index_js_1.Utils.toHex(result)
842
+ publicKey: index_js_2.Utils.toHex(result)
843
843
  };
844
844
  }
845
845
  async revealCounterpartyKeyLinkage(args, originator) {
846
- const paramWriter = new index_js_1.Utils.Writer();
846
+ const paramWriter = new index_js_2.Utils.Writer();
847
847
  paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
848
- paramWriter.write(index_js_1.Utils.toArray(args.counterparty, 'hex'));
849
- paramWriter.write(index_js_1.Utils.toArray(args.verifier, 'hex'));
848
+ paramWriter.write(index_js_2.Utils.toArray(args.counterparty, 'hex'));
849
+ paramWriter.write(index_js_2.Utils.toArray(args.verifier, 'hex'));
850
850
  const result = await this.transmit('revealCounterpartyKeyLinkage', originator, paramWriter.toArray());
851
- const resultReader = new index_js_1.Utils.Reader(result);
852
- const prover = index_js_1.Utils.toHex(resultReader.read(33));
853
- const verifier = index_js_1.Utils.toHex(resultReader.read(33));
854
- const counterparty = index_js_1.Utils.toHex(resultReader.read(33));
851
+ const resultReader = new index_js_2.Utils.Reader(result);
852
+ const prover = index_js_2.Utils.toHex(resultReader.read(33));
853
+ const verifier = index_js_2.Utils.toHex(resultReader.read(33));
854
+ const counterparty = index_js_2.Utils.toHex(resultReader.read(33));
855
855
  const revelationTimeLength = resultReader.readVarIntNum();
856
- const revelationTime = index_js_1.Utils.toUTF8(resultReader.read(revelationTimeLength));
856
+ const revelationTime = index_js_2.Utils.toUTF8(resultReader.read(revelationTimeLength));
857
857
  const encryptedLinkageLength = resultReader.readVarIntNum();
858
858
  const encryptedLinkage = resultReader.read(encryptedLinkageLength);
859
859
  const encryptedLinkageProofLength = resultReader.readVarIntNum();
@@ -868,19 +868,19 @@ class WalletWireTransceiver {
868
868
  };
869
869
  }
870
870
  async revealSpecificKeyLinkage(args, originator) {
871
- const paramWriter = new index_js_1.Utils.Writer();
871
+ const paramWriter = new index_js_2.Utils.Writer();
872
872
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
873
- paramWriter.write(index_js_1.Utils.toArray(args.verifier, 'hex'));
873
+ paramWriter.write(index_js_2.Utils.toArray(args.verifier, 'hex'));
874
874
  const result = await this.transmit('revealSpecificKeyLinkage', originator, paramWriter.toArray());
875
- const resultReader = new index_js_1.Utils.Reader(result);
876
- const prover = index_js_1.Utils.toHex(resultReader.read(33));
877
- const verifier = index_js_1.Utils.toHex(resultReader.read(33));
878
- const counterparty = index_js_1.Utils.toHex(resultReader.read(33));
875
+ const resultReader = new index_js_2.Utils.Reader(result);
876
+ const prover = index_js_2.Utils.toHex(resultReader.read(33));
877
+ const verifier = index_js_2.Utils.toHex(resultReader.read(33));
878
+ const counterparty = index_js_2.Utils.toHex(resultReader.read(33));
879
879
  const securityLevel = resultReader.readUInt8();
880
880
  const protocolLength = resultReader.readVarIntNum();
881
- const protocol = index_js_1.Utils.toUTF8(resultReader.read(protocolLength));
881
+ const protocol = index_js_2.Utils.toUTF8(resultReader.read(protocolLength));
882
882
  const keyIDLength = resultReader.readVarIntNum();
883
- const keyID = index_js_1.Utils.toUTF8(resultReader.read(keyIDLength));
883
+ const keyID = index_js_2.Utils.toUTF8(resultReader.read(keyIDLength));
884
884
  const encryptedLinkageLength = resultReader.readVarIntNum();
885
885
  const encryptedLinkage = resultReader.read(encryptedLinkageLength);
886
886
  const encryptedLinkageProofLength = resultReader.readVarIntNum();
@@ -898,7 +898,7 @@ class WalletWireTransceiver {
898
898
  };
899
899
  }
900
900
  async encrypt(args, originator) {
901
- const paramWriter = new index_js_1.Utils.Writer();
901
+ const paramWriter = new index_js_2.Utils.Writer();
902
902
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
903
903
  paramWriter.writeVarIntNum(args.plaintext.length);
904
904
  paramWriter.write(args.plaintext);
@@ -909,7 +909,7 @@ class WalletWireTransceiver {
909
909
  };
910
910
  }
911
911
  async decrypt(args, originator) {
912
- const paramWriter = new index_js_1.Utils.Writer();
912
+ const paramWriter = new index_js_2.Utils.Writer();
913
913
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
914
914
  paramWriter.writeVarIntNum(args.ciphertext.length);
915
915
  paramWriter.write(args.ciphertext);
@@ -920,7 +920,7 @@ class WalletWireTransceiver {
920
920
  };
921
921
  }
922
922
  async createHmac(args, originator) {
923
- const paramWriter = new index_js_1.Utils.Writer();
923
+ const paramWriter = new index_js_2.Utils.Writer();
924
924
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
925
925
  paramWriter.writeVarIntNum(args.data.length);
926
926
  paramWriter.write(args.data);
@@ -931,7 +931,7 @@ class WalletWireTransceiver {
931
931
  };
932
932
  }
933
933
  async verifyHmac(args, originator) {
934
- const paramWriter = new index_js_1.Utils.Writer();
934
+ const paramWriter = new index_js_2.Utils.Writer();
935
935
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
936
936
  paramWriter.write(args.hmac);
937
937
  paramWriter.writeVarIntNum(args.data.length);
@@ -942,7 +942,7 @@ class WalletWireTransceiver {
942
942
  return { valid: true };
943
943
  }
944
944
  async createSignature(args, originator) {
945
- const paramWriter = new index_js_1.Utils.Writer();
945
+ const paramWriter = new index_js_2.Utils.Writer();
946
946
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
947
947
  if (typeof args.data === 'object') {
948
948
  paramWriter.writeUInt8(1);
@@ -960,7 +960,7 @@ class WalletWireTransceiver {
960
960
  };
961
961
  }
962
962
  async verifySignature(args, originator) {
963
- const paramWriter = new index_js_1.Utils.Writer();
963
+ const paramWriter = new index_js_2.Utils.Writer();
964
964
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
965
965
  if (typeof args.forSelf === 'boolean') {
966
966
  paramWriter.writeInt8(args.forSelf ? 1 : 0);
@@ -985,12 +985,12 @@ class WalletWireTransceiver {
985
985
  return { valid: true };
986
986
  }
987
987
  encodeKeyRelatedParams(protocolID, keyID, counterparty, privileged, privilegedReason) {
988
- const paramWriter = new index_js_1.Utils.Writer();
988
+ const paramWriter = new index_js_2.Utils.Writer();
989
989
  paramWriter.writeUInt8(protocolID[0]);
990
- const protocolAsArray = index_js_1.Utils.toArray(protocolID[1], 'utf8');
990
+ const protocolAsArray = index_js_2.Utils.toArray(protocolID[1], 'utf8');
991
991
  paramWriter.writeVarIntNum(protocolAsArray.length);
992
992
  paramWriter.write(protocolAsArray);
993
- const keyIDAsArray = index_js_1.Utils.toArray(keyID, 'utf8');
993
+ const keyIDAsArray = index_js_2.Utils.toArray(keyID, 'utf8');
994
994
  paramWriter.writeVarIntNum(keyIDAsArray.length);
995
995
  paramWriter.write(keyIDAsArray);
996
996
  if (typeof counterparty !== 'string') {
@@ -1003,20 +1003,20 @@ class WalletWireTransceiver {
1003
1003
  paramWriter.writeUInt8(12);
1004
1004
  }
1005
1005
  else {
1006
- paramWriter.write(index_js_1.Utils.toArray(counterparty, 'hex'));
1006
+ paramWriter.write(index_js_2.Utils.toArray(counterparty, 'hex'));
1007
1007
  }
1008
1008
  paramWriter.write(this.encodePrivilegedParams(privileged, privilegedReason));
1009
1009
  return paramWriter.toArray();
1010
1010
  }
1011
1011
  async acquireCertificate(args, originator) {
1012
- const paramWriter = new index_js_1.Utils.Writer();
1013
- paramWriter.write(index_js_1.Utils.toArray(args.type, 'base64'));
1014
- paramWriter.write(index_js_1.Utils.toArray(args.certifier, 'hex'));
1012
+ const paramWriter = new index_js_2.Utils.Writer();
1013
+ paramWriter.write(index_js_2.Utils.toArray(args.type, 'base64'));
1014
+ paramWriter.write(index_js_2.Utils.toArray(args.certifier, 'hex'));
1015
1015
  const fieldEntries = Object.entries(args.fields);
1016
1016
  paramWriter.writeVarIntNum(fieldEntries.length);
1017
1017
  for (const [key, value] of fieldEntries) {
1018
- const keyAsArray = index_js_1.Utils.toArray(key, 'utf8');
1019
- const valueAsArray = index_js_1.Utils.toArray(value, 'utf8');
1018
+ const keyAsArray = index_js_2.Utils.toArray(key, 'utf8');
1019
+ const valueAsArray = index_js_2.Utils.toArray(value, 'utf8');
1020
1020
  paramWriter.writeVarIntNum(keyAsArray.length);
1021
1021
  paramWriter.write(keyAsArray);
1022
1022
  paramWriter.writeVarIntNum(valueAsArray.length);
@@ -1025,40 +1025,40 @@ class WalletWireTransceiver {
1025
1025
  paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
1026
1026
  paramWriter.writeUInt8(args.acquisitionProtocol === 'direct' ? 1 : 2);
1027
1027
  if (args.acquisitionProtocol === 'direct') {
1028
- paramWriter.write(index_js_1.Utils.toArray(args.serialNumber, 'base64'));
1028
+ paramWriter.write(index_js_2.Utils.toArray(args.serialNumber, 'base64'));
1029
1029
  paramWriter.write(this.encodeOutpoint(args.revocationOutpoint));
1030
- const signatureAsArray = index_js_1.Utils.toArray(args.signature, 'hex');
1030
+ const signatureAsArray = index_js_2.Utils.toArray(args.signature, 'hex');
1031
1031
  paramWriter.writeVarIntNum(signatureAsArray.length);
1032
1032
  paramWriter.write(signatureAsArray);
1033
1033
  const keyringRevealerAsArray = args.keyringRevealer !== 'certifier'
1034
- ? index_js_1.Utils.toArray(args.keyringRevealer, 'hex')
1034
+ ? index_js_2.Utils.toArray(args.keyringRevealer, 'hex')
1035
1035
  : [11];
1036
1036
  paramWriter.write(keyringRevealerAsArray);
1037
1037
  const keyringKeys = Object.keys(args.keyringForSubject);
1038
1038
  paramWriter.writeVarIntNum(keyringKeys.length);
1039
1039
  for (let i = 0; i < keyringKeys.length; i++) {
1040
- const keyringKeysAsArray = index_js_1.Utils.toArray(keyringKeys[i], 'utf8');
1040
+ const keyringKeysAsArray = index_js_2.Utils.toArray(keyringKeys[i], 'utf8');
1041
1041
  paramWriter.writeVarIntNum(keyringKeysAsArray.length);
1042
1042
  paramWriter.write(keyringKeysAsArray);
1043
- const keyringForSubjectAsArray = index_js_1.Utils.toArray(args.keyringForSubject[keyringKeys[i]], 'base64');
1043
+ const keyringForSubjectAsArray = index_js_2.Utils.toArray(args.keyringForSubject[keyringKeys[i]], 'base64');
1044
1044
  paramWriter.writeVarIntNum(keyringForSubjectAsArray.length);
1045
1045
  paramWriter.write(keyringForSubjectAsArray);
1046
1046
  }
1047
1047
  }
1048
1048
  else {
1049
- const certifierUrlAsArray = index_js_1.Utils.toArray(args.certifierUrl, 'utf8');
1049
+ const certifierUrlAsArray = index_js_2.Utils.toArray(args.certifierUrl, 'utf8');
1050
1050
  paramWriter.writeVarIntNum(certifierUrlAsArray.length);
1051
1051
  paramWriter.write(certifierUrlAsArray);
1052
1052
  }
1053
1053
  const result = await this.transmit('acquireCertificate', originator, paramWriter.toArray());
1054
- const cert = Certificate_js_1.default.fromBin(result);
1054
+ const cert = index_js_1.Certificate.fromBin(result);
1055
1055
  return {
1056
1056
  ...cert,
1057
1057
  signature: cert.signature
1058
1058
  };
1059
1059
  }
1060
1060
  encodePrivilegedParams(privileged, privilegedReason) {
1061
- const paramWriter = new index_js_1.Utils.Writer();
1061
+ const paramWriter = new index_js_2.Utils.Writer();
1062
1062
  if (typeof privileged === 'boolean') {
1063
1063
  paramWriter.writeInt8(privileged ? 1 : 0);
1064
1064
  }
@@ -1066,7 +1066,7 @@ class WalletWireTransceiver {
1066
1066
  paramWriter.writeInt8(-1);
1067
1067
  }
1068
1068
  if (typeof privilegedReason === 'string') {
1069
- const privilegedReasonAsArray = index_js_1.Utils.toArray(privilegedReason, 'utf8');
1069
+ const privilegedReasonAsArray = index_js_2.Utils.toArray(privilegedReason, 'utf8');
1070
1070
  paramWriter.writeInt8(privilegedReasonAsArray.length);
1071
1071
  paramWriter.write(privilegedReasonAsArray);
1072
1072
  }
@@ -1076,14 +1076,14 @@ class WalletWireTransceiver {
1076
1076
  return paramWriter.toArray();
1077
1077
  }
1078
1078
  async listCertificates(args, originator) {
1079
- const paramWriter = new index_js_1.Utils.Writer();
1079
+ const paramWriter = new index_js_2.Utils.Writer();
1080
1080
  paramWriter.writeVarIntNum(args.certifiers.length);
1081
1081
  for (let i = 0; i < args.certifiers.length; i++) {
1082
- paramWriter.write(index_js_1.Utils.toArray(args.certifiers[i], 'hex'));
1082
+ paramWriter.write(index_js_2.Utils.toArray(args.certifiers[i], 'hex'));
1083
1083
  }
1084
1084
  paramWriter.writeVarIntNum(args.types.length);
1085
1085
  for (let i = 0; i < args.types.length; i++) {
1086
- paramWriter.write(index_js_1.Utils.toArray(args.types[i], 'base64'));
1086
+ paramWriter.write(index_js_2.Utils.toArray(args.types[i], 'base64'));
1087
1087
  }
1088
1088
  if (typeof args.limit === 'number') {
1089
1089
  paramWriter.writeVarIntNum(args.limit);
@@ -1099,13 +1099,13 @@ class WalletWireTransceiver {
1099
1099
  }
1100
1100
  paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
1101
1101
  const result = await this.transmit('listCertificates', originator, paramWriter.toArray());
1102
- const resultReader = new index_js_1.Utils.Reader(result);
1102
+ const resultReader = new index_js_2.Utils.Reader(result);
1103
1103
  const totalCertificates = resultReader.readVarIntNum();
1104
1104
  const certificates = [];
1105
1105
  for (let i = 0; i < totalCertificates; i++) {
1106
1106
  const certificateLength = resultReader.readVarIntNum();
1107
1107
  const certificateBin = resultReader.read(certificateLength);
1108
- const cert = Certificate_js_1.default.fromBin(certificateBin);
1108
+ const cert = index_js_1.Certificate.fromBin(certificateBin);
1109
1109
  certificates.push({
1110
1110
  ...cert,
1111
1111
  signature: cert.signature
@@ -1117,25 +1117,25 @@ class WalletWireTransceiver {
1117
1117
  };
1118
1118
  }
1119
1119
  async proveCertificate(args, originator) {
1120
- const paramWriter = new index_js_1.Utils.Writer();
1121
- const typeAsArray = index_js_1.Utils.toArray(args.certificate.type, 'base64');
1120
+ const paramWriter = new index_js_2.Utils.Writer();
1121
+ const typeAsArray = index_js_2.Utils.toArray(args.certificate.type, 'base64');
1122
1122
  paramWriter.write(typeAsArray);
1123
- const subjectAsArray = index_js_1.Utils.toArray(args.certificate.subject, 'hex');
1123
+ const subjectAsArray = index_js_2.Utils.toArray(args.certificate.subject, 'hex');
1124
1124
  paramWriter.write(subjectAsArray);
1125
- const serialNumberAsArray = index_js_1.Utils.toArray(args.certificate.serialNumber, 'base64');
1125
+ const serialNumberAsArray = index_js_2.Utils.toArray(args.certificate.serialNumber, 'base64');
1126
1126
  paramWriter.write(serialNumberAsArray);
1127
- const certifierAsArray = index_js_1.Utils.toArray(args.certificate.certifier, 'hex');
1127
+ const certifierAsArray = index_js_2.Utils.toArray(args.certificate.certifier, 'hex');
1128
1128
  paramWriter.write(certifierAsArray);
1129
1129
  const revocationOutpointAsArray = this.encodeOutpoint(args.certificate.revocationOutpoint);
1130
1130
  paramWriter.write(revocationOutpointAsArray);
1131
- const signatureAsArray = index_js_1.Utils.toArray(args.certificate.signature, 'hex');
1131
+ const signatureAsArray = index_js_2.Utils.toArray(args.certificate.signature, 'hex');
1132
1132
  paramWriter.writeVarIntNum(signatureAsArray.length);
1133
1133
  paramWriter.write(signatureAsArray);
1134
1134
  const fieldEntries = Object.entries(args.certificate.fields);
1135
1135
  paramWriter.writeVarIntNum(fieldEntries.length);
1136
1136
  for (const [key, value] of fieldEntries) {
1137
- const keyAsArray = index_js_1.Utils.toArray(key, 'utf8');
1138
- const valueAsArray = index_js_1.Utils.toArray(value, 'utf8');
1137
+ const keyAsArray = index_js_2.Utils.toArray(key, 'utf8');
1138
+ const valueAsArray = index_js_2.Utils.toArray(value, 'utf8');
1139
1139
  paramWriter.writeVarIntNum(keyAsArray.length);
1140
1140
  paramWriter.write(keyAsArray);
1141
1141
  paramWriter.writeVarIntNum(valueAsArray.length);
@@ -1143,57 +1143,57 @@ class WalletWireTransceiver {
1143
1143
  }
1144
1144
  paramWriter.writeVarIntNum(args.fieldsToReveal.length);
1145
1145
  for (const field of args.fieldsToReveal) {
1146
- const fieldAsArray = index_js_1.Utils.toArray(field, 'utf8');
1146
+ const fieldAsArray = index_js_2.Utils.toArray(field, 'utf8');
1147
1147
  paramWriter.writeVarIntNum(fieldAsArray.length);
1148
1148
  paramWriter.write(fieldAsArray);
1149
1149
  }
1150
- paramWriter.write(index_js_1.Utils.toArray(args.verifier, 'hex'));
1150
+ paramWriter.write(index_js_2.Utils.toArray(args.verifier, 'hex'));
1151
1151
  paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
1152
1152
  const result = await this.transmit('proveCertificate', originator, paramWriter.toArray());
1153
- const resultReader = new index_js_1.Utils.Reader(result);
1153
+ const resultReader = new index_js_2.Utils.Reader(result);
1154
1154
  const numFields = resultReader.readVarIntNum();
1155
1155
  const keyringForVerifier = {};
1156
1156
  for (let i = 0; i < numFields; i++) {
1157
1157
  const fieldKeyLength = resultReader.readVarIntNum();
1158
- const fieldKey = index_js_1.Utils.toUTF8(resultReader.read(fieldKeyLength));
1158
+ const fieldKey = index_js_2.Utils.toUTF8(resultReader.read(fieldKeyLength));
1159
1159
  const fieldValueLength = resultReader.readVarIntNum();
1160
- keyringForVerifier[fieldKey] = index_js_1.Utils.toBase64(resultReader.read(fieldValueLength));
1160
+ keyringForVerifier[fieldKey] = index_js_2.Utils.toBase64(resultReader.read(fieldValueLength));
1161
1161
  }
1162
1162
  return {
1163
1163
  keyringForVerifier
1164
1164
  };
1165
1165
  }
1166
1166
  async relinquishCertificate(args, originator) {
1167
- const paramWriter = new index_js_1.Utils.Writer();
1168
- const typeAsArray = index_js_1.Utils.toArray(args.type, 'base64');
1167
+ const paramWriter = new index_js_2.Utils.Writer();
1168
+ const typeAsArray = index_js_2.Utils.toArray(args.type, 'base64');
1169
1169
  paramWriter.write(typeAsArray);
1170
- const serialNumberAsArray = index_js_1.Utils.toArray(args.serialNumber, 'base64');
1170
+ const serialNumberAsArray = index_js_2.Utils.toArray(args.serialNumber, 'base64');
1171
1171
  paramWriter.write(serialNumberAsArray);
1172
- const certifierAsArray = index_js_1.Utils.toArray(args.certifier, 'hex');
1172
+ const certifierAsArray = index_js_2.Utils.toArray(args.certifier, 'hex');
1173
1173
  paramWriter.write(certifierAsArray);
1174
1174
  await this.transmit('relinquishCertificate', originator, paramWriter.toArray());
1175
1175
  return { relinquished: true };
1176
1176
  }
1177
1177
  parseDiscoveryResult(result) {
1178
- const resultReader = new index_js_1.Utils.Reader(result);
1178
+ const resultReader = new index_js_2.Utils.Reader(result);
1179
1179
  const totalCertificates = resultReader.readVarIntNum();
1180
1180
  const certificates = [];
1181
1181
  for (let i = 0; i < totalCertificates; i++) {
1182
1182
  const certBinLen = resultReader.readVarIntNum();
1183
1183
  const certBin = resultReader.read(certBinLen);
1184
- const cert = Certificate_js_1.default.fromBin(certBin);
1184
+ const cert = index_js_1.Certificate.fromBin(certBin);
1185
1185
  const nameLength = resultReader.readVarIntNum();
1186
- const name = index_js_1.Utils.toUTF8(resultReader.read(nameLength));
1186
+ const name = index_js_2.Utils.toUTF8(resultReader.read(nameLength));
1187
1187
  const iconUrlLength = resultReader.readVarIntNum();
1188
- const iconUrl = index_js_1.Utils.toUTF8(resultReader.read(iconUrlLength));
1188
+ const iconUrl = index_js_2.Utils.toUTF8(resultReader.read(iconUrlLength));
1189
1189
  const descriptionLength = resultReader.readVarIntNum();
1190
- const description = index_js_1.Utils.toUTF8(resultReader.read(descriptionLength));
1190
+ const description = index_js_2.Utils.toUTF8(resultReader.read(descriptionLength));
1191
1191
  const trust = resultReader.readUInt8();
1192
1192
  const publiclyRevealedKeyring = {};
1193
1193
  const numPublicKeyringEntries = resultReader.readVarIntNum();
1194
1194
  for (let j = 0; j < numPublicKeyringEntries; j++) {
1195
1195
  const fieldKeyLen = resultReader.readVarIntNum();
1196
- const fieldKey = index_js_1.Utils.toUTF8(resultReader.read(fieldKeyLen));
1196
+ const fieldKey = index_js_2.Utils.toUTF8(resultReader.read(fieldKeyLen));
1197
1197
  const fieldValueLen = resultReader.readVarIntNum();
1198
1198
  publiclyRevealedKeyring[fieldKey] = resultReader.read(fieldValueLen);
1199
1199
  }
@@ -1201,9 +1201,9 @@ class WalletWireTransceiver {
1201
1201
  const numDecryptedFields = resultReader.readVarIntNum();
1202
1202
  for (let k = 0; k < numDecryptedFields; k++) {
1203
1203
  const fieldKeyLen = resultReader.readVarIntNum();
1204
- const fieldKey = index_js_1.Utils.toUTF8(resultReader.read(fieldKeyLen));
1204
+ const fieldKey = index_js_2.Utils.toUTF8(resultReader.read(fieldKeyLen));
1205
1205
  const fieldValueLen = resultReader.readVarIntNum();
1206
- decryptedFields[fieldKey] = index_js_1.Utils.toUTF8(resultReader.read(fieldValueLen));
1206
+ decryptedFields[fieldKey] = index_js_2.Utils.toUTF8(resultReader.read(fieldValueLen));
1207
1207
  }
1208
1208
  certificates.push({
1209
1209
  ...cert,
@@ -1219,8 +1219,8 @@ class WalletWireTransceiver {
1219
1219
  };
1220
1220
  }
1221
1221
  async discoverByIdentityKey(args, originator) {
1222
- const paramWriter = new index_js_1.Utils.Writer();
1223
- paramWriter.write(index_js_1.Utils.toArray(args.identityKey, 'hex'));
1222
+ const paramWriter = new index_js_2.Utils.Writer();
1223
+ paramWriter.write(index_js_2.Utils.toArray(args.identityKey, 'hex'));
1224
1224
  if (typeof args.limit === 'number') {
1225
1225
  paramWriter.writeVarIntNum(args.limit);
1226
1226
  }
@@ -1239,14 +1239,14 @@ class WalletWireTransceiver {
1239
1239
  return this.parseDiscoveryResult(result);
1240
1240
  }
1241
1241
  async discoverByAttributes(args, originator) {
1242
- const paramWriter = new index_js_1.Utils.Writer();
1242
+ const paramWriter = new index_js_2.Utils.Writer();
1243
1243
  const attributeKeys = Object.keys(args.attributes);
1244
1244
  paramWriter.writeVarIntNum(attributeKeys.length);
1245
1245
  for (let i = 0; i < attributeKeys.length; i++) {
1246
1246
  paramWriter.writeVarIntNum(attributeKeys[i].length);
1247
- paramWriter.write(index_js_1.Utils.toArray(attributeKeys[i], 'utf8'));
1247
+ paramWriter.write(index_js_2.Utils.toArray(attributeKeys[i], 'utf8'));
1248
1248
  paramWriter.writeVarIntNum(args.attributes[attributeKeys[i]].length);
1249
- paramWriter.write(index_js_1.Utils.toArray(args.attributes[attributeKeys[i]], 'utf8'));
1249
+ paramWriter.write(index_js_2.Utils.toArray(args.attributes[attributeKeys[i]], 'utf8'));
1250
1250
  }
1251
1251
  if (typeof args.limit === 'number') {
1252
1252
  paramWriter.writeVarIntNum(args.limit);
@@ -1275,17 +1275,17 @@ class WalletWireTransceiver {
1275
1275
  }
1276
1276
  async getHeight(args, originator) {
1277
1277
  const result = await this.transmit('getHeight', originator);
1278
- const resultReader = new index_js_1.Utils.Reader(result);
1278
+ const resultReader = new index_js_2.Utils.Reader(result);
1279
1279
  return {
1280
1280
  height: resultReader.readVarIntNum()
1281
1281
  };
1282
1282
  }
1283
1283
  async getHeaderForHeight(args, originator) {
1284
- const paramWriter = new index_js_1.Utils.Writer();
1284
+ const paramWriter = new index_js_2.Utils.Writer();
1285
1285
  paramWriter.writeVarIntNum(args.height);
1286
1286
  const header = await this.transmit('getHeaderForHeight', originator, paramWriter.toArray());
1287
1287
  return {
1288
- header: index_js_1.Utils.toHex(header)
1288
+ header: index_js_2.Utils.toHex(header)
1289
1289
  };
1290
1290
  }
1291
1291
  async getNetwork(args, originator) {
@@ -1297,7 +1297,7 @@ class WalletWireTransceiver {
1297
1297
  async getVersion(args, originator) {
1298
1298
  const version = await this.transmit('getVersion', originator);
1299
1299
  return {
1300
- version: index_js_1.Utils.toUTF8(version)
1300
+ version: index_js_2.Utils.toUTF8(version)
1301
1301
  };
1302
1302
  }
1303
1303
  }