@bsv/sdk 1.3.36 → 1.4.0

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 (153) hide show
  1. package/dist/cjs/mod.js +1 -0
  2. package/dist/cjs/mod.js.map +1 -1
  3. package/dist/cjs/package.json +1 -1
  4. package/dist/cjs/src/auth/Peer.js +42 -14
  5. package/dist/cjs/src/auth/Peer.js.map +1 -1
  6. package/dist/cjs/src/auth/certificates/Certificate.js +50 -22
  7. package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
  8. package/dist/cjs/src/auth/certificates/MasterCertificate.js +35 -10
  9. package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
  10. package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +28 -4
  11. package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -1
  12. package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +5 -2
  13. package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
  14. package/dist/cjs/src/auth/clients/AuthFetch.js +50 -20
  15. package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
  16. package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +40 -17
  17. package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
  18. package/dist/cjs/src/auth/utils/createNonce.js +31 -4
  19. package/dist/cjs/src/auth/utils/createNonce.js.map +1 -1
  20. package/dist/cjs/src/auth/utils/verifyNonce.js +26 -3
  21. package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -1
  22. package/dist/cjs/src/overlay-tools/LookupResolver.js +2 -2
  23. package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
  24. package/dist/cjs/src/primitives/utils.js.map +1 -1
  25. package/dist/cjs/src/storage/StorageUploader.js +93 -0
  26. package/dist/cjs/src/storage/StorageUploader.js.map +1 -0
  27. package/dist/cjs/src/storage/StorageUtils.js +73 -0
  28. package/dist/cjs/src/storage/StorageUtils.js.map +1 -0
  29. package/dist/cjs/src/storage/__test/StorageUploader.test.js +92 -0
  30. package/dist/cjs/src/storage/__test/StorageUploader.test.js.map +1 -0
  31. package/dist/cjs/src/storage/__test/StorageUtils.test.js +97 -0
  32. package/dist/cjs/src/storage/__test/StorageUtils.test.js.map +1 -0
  33. package/dist/cjs/src/storage/index.js +30 -0
  34. package/dist/cjs/src/storage/index.js.map +1 -0
  35. package/dist/cjs/src/wallet/WalletClient.js +4 -4
  36. package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
  37. package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js +26 -3
  38. package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
  39. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +178 -155
  40. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  41. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +171 -148
  42. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  43. package/dist/cjs/src/wallet/substrates/XDM.js +29 -2
  44. package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -1
  45. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  46. package/dist/esm/mod.js +1 -0
  47. package/dist/esm/mod.js.map +1 -1
  48. package/dist/esm/src/auth/Peer.js +7 -5
  49. package/dist/esm/src/auth/Peer.js.map +1 -1
  50. package/dist/esm/src/auth/certificates/Certificate.js +3 -1
  51. package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
  52. package/dist/esm/src/auth/certificates/MasterCertificate.js +3 -1
  53. package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
  54. package/dist/esm/src/auth/certificates/VerifiableCertificate.js +2 -1
  55. package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -1
  56. package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +1 -1
  57. package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
  58. package/dist/esm/src/auth/clients/AuthFetch.js +5 -1
  59. package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
  60. package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +1 -1
  61. package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
  62. package/dist/esm/src/auth/utils/createNonce.js +2 -1
  63. package/dist/esm/src/auth/utils/createNonce.js.map +1 -1
  64. package/dist/esm/src/auth/utils/verifyNonce.js +1 -1
  65. package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -1
  66. package/dist/esm/src/overlay-tools/LookupResolver.js +2 -2
  67. package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
  68. package/dist/esm/src/primitives/utils.js.map +1 -1
  69. package/dist/esm/src/storage/StorageUploader.js +68 -0
  70. package/dist/esm/src/storage/StorageUploader.js.map +1 -0
  71. package/dist/esm/src/storage/StorageUtils.js +65 -0
  72. package/dist/esm/src/storage/StorageUtils.js.map +1 -0
  73. package/dist/esm/src/storage/__test/StorageUploader.test.js +64 -0
  74. package/dist/esm/src/storage/__test/StorageUploader.test.js.map +1 -0
  75. package/dist/esm/src/storage/__test/StorageUtils.test.js +72 -0
  76. package/dist/esm/src/storage/__test/StorageUtils.test.js.map +1 -0
  77. package/dist/esm/src/storage/index.js +3 -0
  78. package/dist/esm/src/storage/index.js.map +1 -0
  79. package/dist/esm/src/wallet/WalletClient.js +4 -4
  80. package/dist/esm/src/wallet/WalletClient.js.map +1 -1
  81. package/dist/esm/src/wallet/substrates/HTTPWalletWire.js +1 -1
  82. package/dist/esm/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
  83. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1 -1
  84. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  85. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +2 -2
  86. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  87. package/dist/esm/src/wallet/substrates/XDM.js +2 -1
  88. package/dist/esm/src/wallet/substrates/XDM.js.map +1 -1
  89. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  90. package/dist/types/mod.d.ts +1 -0
  91. package/dist/types/mod.d.ts.map +1 -1
  92. package/dist/types/src/auth/Peer.d.ts +1 -1
  93. package/dist/types/src/auth/Peer.d.ts.map +1 -1
  94. package/dist/types/src/auth/certificates/Certificate.d.ts +2 -1
  95. package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
  96. package/dist/types/src/auth/certificates/MasterCertificate.d.ts +2 -1
  97. package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -1
  98. package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts +2 -1
  99. package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -1
  100. package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts +1 -1
  101. package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts.map +1 -1
  102. package/dist/types/src/auth/clients/AuthFetch.d.ts +1 -1
  103. package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
  104. package/dist/types/src/auth/utils/createNonce.d.ts +1 -1
  105. package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -1
  106. package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +1 -1
  107. package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -1
  108. package/dist/types/src/auth/utils/verifyNonce.d.ts +1 -1
  109. package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -1
  110. package/dist/types/src/primitives/utils.d.ts +4 -1
  111. package/dist/types/src/primitives/utils.d.ts.map +1 -1
  112. package/dist/types/src/storage/StorageUploader.d.ts +40 -0
  113. package/dist/types/src/storage/StorageUploader.d.ts.map +1 -0
  114. package/dist/types/src/storage/StorageUtils.d.ts +31 -0
  115. package/dist/types/src/storage/StorageUtils.d.ts.map +1 -0
  116. package/dist/types/src/storage/__test/StorageUploader.test.d.ts +2 -0
  117. package/dist/types/src/storage/__test/StorageUploader.test.d.ts.map +1 -0
  118. package/dist/types/src/storage/__test/StorageUtils.test.d.ts +2 -0
  119. package/dist/types/src/storage/__test/StorageUtils.test.d.ts.map +1 -0
  120. package/dist/types/src/storage/index.d.ts +3 -0
  121. package/dist/types/src/storage/index.d.ts.map +1 -0
  122. package/dist/types/src/wallet/substrates/XDM.d.ts +1 -1
  123. package/dist/types/src/wallet/substrates/XDM.d.ts.map +1 -1
  124. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  125. package/dist/umd/bundle.js +1 -1
  126. package/docs/primitives.md +4 -1
  127. package/docs/storage.md +210 -0
  128. package/docs/wallet-substrates.md +0 -225
  129. package/mod.ts +1 -0
  130. package/package.json +12 -2
  131. package/src/auth/Peer.ts +8 -5
  132. package/src/auth/__tests/Peer.test.ts +31 -31
  133. package/src/auth/certificates/Certificate.ts +5 -5
  134. package/src/auth/certificates/MasterCertificate.ts +5 -5
  135. package/src/auth/certificates/VerifiableCertificate.ts +6 -6
  136. package/src/auth/certificates/__tests/CompletedProtoWallet.ts +1 -15
  137. package/src/auth/clients/AuthFetch.ts +6 -1
  138. package/src/auth/transports/SimplifiedFetchTransport.ts +1 -1
  139. package/src/auth/utils/createNonce.ts +3 -3
  140. package/src/auth/utils/getVerifiableCertificates.ts +1 -1
  141. package/src/auth/utils/verifyNonce.ts +2 -1
  142. package/src/overlay-tools/LookupResolver.ts +2 -2
  143. package/src/primitives/utils.ts +1 -1
  144. package/src/storage/StorageUploader.ts +108 -0
  145. package/src/storage/StorageUtils.ts +66 -0
  146. package/src/storage/__test/StorageUploader.test.ts +80 -0
  147. package/src/storage/__test/StorageUtils.test.ts +86 -0
  148. package/src/storage/index.ts +2 -0
  149. package/src/wallet/WalletClient.ts +4 -4
  150. package/src/wallet/substrates/HTTPWalletWire.ts +1 -1
  151. package/src/wallet/substrates/WalletWireProcessor.ts +1 -1
  152. package/src/wallet/substrates/WalletWireTransceiver.ts +2 -2
  153. package/src/wallet/substrates/XDM.ts +3 -2
@@ -1,11 +1,34 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  const Wallet_interfaces_js_1 = require("../Wallet.interfaces.js");
7
- const index_js_1 = require("../../auth/index.js");
8
- const index_js_2 = require("../../primitives/index.js");
30
+ const Certificate_js_1 = __importDefault(require("../../auth/certificates/Certificate.js"));
31
+ const Utils = __importStar(require("../../primitives/utils.js"));
9
32
  const WalletWireCalls_js_1 = __importDefault(require("./WalletWireCalls.js"));
10
33
  const WalletError_js_1 = require("../WalletError.js");
11
34
  /**
@@ -16,9 +39,9 @@ class WalletWireTransceiver {
16
39
  this.wire = wire;
17
40
  }
18
41
  async transmit(call, originator = '', params = []) {
19
- const frameWriter = new index_js_2.Utils.Writer();
42
+ const frameWriter = new Utils.Writer();
20
43
  frameWriter.writeUInt8(WalletWireCalls_js_1.default[call]);
21
- const originatorArray = index_js_2.Utils.toArray(originator, 'utf8');
44
+ const originatorArray = Utils.toArray(originator, 'utf8');
22
45
  frameWriter.writeUInt8(originatorArray.length);
23
46
  frameWriter.write(originatorArray);
24
47
  if (params.length > 0) {
@@ -26,7 +49,7 @@ class WalletWireTransceiver {
26
49
  }
27
50
  const frame = frameWriter.toArray();
28
51
  const result = await this.wire.transmitToWallet(frame);
29
- const resultReader = new index_js_2.Utils.Reader(result);
52
+ const resultReader = new Utils.Reader(result);
30
53
  const errorByte = resultReader.readUInt8();
31
54
  if (errorByte === 0) {
32
55
  const resultFrame = resultReader.read();
@@ -36,11 +59,11 @@ class WalletWireTransceiver {
36
59
  // Deserialize the error message length
37
60
  const errorMessageLength = resultReader.readVarIntNum();
38
61
  const errorMessageBytes = resultReader.read(errorMessageLength);
39
- const errorMessage = index_js_2.Utils.toUTF8(errorMessageBytes);
62
+ const errorMessage = Utils.toUTF8(errorMessageBytes);
40
63
  // Deserialize the stack trace length
41
64
  const stackTraceLength = resultReader.readVarIntNum();
42
65
  const stackTraceBytes = resultReader.read(stackTraceLength);
43
- const stackTrace = index_js_2.Utils.toUTF8(stackTraceBytes);
66
+ const stackTrace = Utils.toUTF8(stackTraceBytes);
44
67
  // Construct a custom wallet error
45
68
  const e = new WalletError_js_1.WalletError(errorMessage, errorByte, stackTrace);
46
69
  throw e;
@@ -48,9 +71,9 @@ class WalletWireTransceiver {
48
71
  }
49
72
  async createAction(args, originator) {
50
73
  var _a;
51
- const paramWriter = new index_js_2.Utils.Writer();
74
+ const paramWriter = new Utils.Writer();
52
75
  // Serialize description
53
- const descriptionBytes = index_js_2.Utils.toArray(args.description, 'utf8');
76
+ const descriptionBytes = Utils.toArray(args.description, 'utf8');
54
77
  paramWriter.writeVarIntNum(descriptionBytes.length);
55
78
  paramWriter.write(descriptionBytes);
56
79
  // input BEEF
@@ -69,7 +92,7 @@ class WalletWireTransceiver {
69
92
  paramWriter.write(this.encodeOutpoint(input.outpoint));
70
93
  // unlockingScript / unlockingScriptLength
71
94
  if (input.unlockingScript != null && input.unlockingScript !== '') {
72
- const unlockingScriptBytes = index_js_2.Utils.toArray(input.unlockingScript, 'hex');
95
+ const unlockingScriptBytes = Utils.toArray(input.unlockingScript, 'hex');
73
96
  paramWriter.writeVarIntNum(unlockingScriptBytes.length);
74
97
  paramWriter.write(unlockingScriptBytes);
75
98
  }
@@ -78,7 +101,7 @@ class WalletWireTransceiver {
78
101
  paramWriter.writeVarIntNum((_a = input.unlockingScriptLength) !== null && _a !== void 0 ? _a : 0);
79
102
  }
80
103
  // inputDescription
81
- const inputDescriptionBytes = index_js_2.Utils.toArray(input.inputDescription, 'utf8');
104
+ const inputDescriptionBytes = Utils.toArray(input.inputDescription, 'utf8');
82
105
  paramWriter.writeVarIntNum(inputDescriptionBytes.length);
83
106
  paramWriter.write(inputDescriptionBytes);
84
107
  // sequenceNumber
@@ -98,18 +121,18 @@ class WalletWireTransceiver {
98
121
  paramWriter.writeVarIntNum(args.outputs.length);
99
122
  for (const output of args.outputs) {
100
123
  // lockingScript
101
- const lockingScriptBytes = index_js_2.Utils.toArray(output.lockingScript, 'hex');
124
+ const lockingScriptBytes = Utils.toArray(output.lockingScript, 'hex');
102
125
  paramWriter.writeVarIntNum(lockingScriptBytes.length);
103
126
  paramWriter.write(lockingScriptBytes);
104
127
  // satoshis
105
128
  paramWriter.writeVarIntNum(output.satoshis);
106
129
  // outputDescription
107
- const outputDescriptionBytes = index_js_2.Utils.toArray(output.outputDescription, 'utf8');
130
+ const outputDescriptionBytes = Utils.toArray(output.outputDescription, 'utf8');
108
131
  paramWriter.writeVarIntNum(outputDescriptionBytes.length);
109
132
  paramWriter.write(outputDescriptionBytes);
110
133
  // basket
111
134
  if (output.basket != null && output.basket !== '') {
112
- const basketBytes = index_js_2.Utils.toArray(output.basket, 'utf8');
135
+ const basketBytes = Utils.toArray(output.basket, 'utf8');
113
136
  paramWriter.writeVarIntNum(basketBytes.length);
114
137
  paramWriter.write(basketBytes);
115
138
  }
@@ -118,7 +141,7 @@ class WalletWireTransceiver {
118
141
  }
119
142
  // customInstructions
120
143
  if (output.customInstructions != null && output.customInstructions !== '') {
121
- const customInstructionsBytes = index_js_2.Utils.toArray(output.customInstructions, 'utf8');
144
+ const customInstructionsBytes = Utils.toArray(output.customInstructions, 'utf8');
122
145
  paramWriter.writeVarIntNum(customInstructionsBytes.length);
123
146
  paramWriter.write(customInstructionsBytes);
124
147
  }
@@ -129,7 +152,7 @@ class WalletWireTransceiver {
129
152
  if (output.tags != null) {
130
153
  paramWriter.writeVarIntNum(output.tags.length);
131
154
  for (const tag of output.tags) {
132
- const tagBytes = index_js_2.Utils.toArray(tag, 'utf8');
155
+ const tagBytes = Utils.toArray(tag, 'utf8');
133
156
  paramWriter.writeVarIntNum(tagBytes.length);
134
157
  paramWriter.write(tagBytes);
135
158
  }
@@ -160,7 +183,7 @@ class WalletWireTransceiver {
160
183
  if (args.labels != null) {
161
184
  paramWriter.writeVarIntNum(args.labels.length);
162
185
  for (const label of args.labels) {
163
- const labelBytes = index_js_2.Utils.toArray(label, 'utf8');
186
+ const labelBytes = Utils.toArray(label, 'utf8');
164
187
  paramWriter.writeVarIntNum(labelBytes.length);
165
188
  paramWriter.write(labelBytes);
166
189
  }
@@ -196,7 +219,7 @@ class WalletWireTransceiver {
196
219
  if (args.options.knownTxids != null) {
197
220
  paramWriter.writeVarIntNum(args.options.knownTxids.length);
198
221
  for (const txid of args.options.knownTxids) {
199
- const txidBytes = index_js_2.Utils.toArray(txid, 'hex');
222
+ const txidBytes = Utils.toArray(txid, 'hex');
200
223
  paramWriter.write(txidBytes);
201
224
  }
202
225
  }
@@ -231,7 +254,7 @@ class WalletWireTransceiver {
231
254
  if (args.options.sendWith != null) {
232
255
  paramWriter.writeVarIntNum(args.options.sendWith.length);
233
256
  for (const txid of args.options.sendWith) {
234
- const txidBytes = index_js_2.Utils.toArray(txid, 'hex');
257
+ const txidBytes = Utils.toArray(txid, 'hex');
235
258
  paramWriter.write(txidBytes);
236
259
  }
237
260
  }
@@ -251,13 +274,13 @@ class WalletWireTransceiver {
251
274
  }
252
275
  // Transmit and parse response
253
276
  const result = await this.transmit('createAction', originator, paramWriter.toArray());
254
- const resultReader = new index_js_2.Utils.Reader(result);
277
+ const resultReader = new Utils.Reader(result);
255
278
  const response = {};
256
279
  // Parse txid
257
280
  const txidFlag = resultReader.readInt8();
258
281
  if (txidFlag === 1) {
259
282
  const txidBytes = resultReader.read(32);
260
- response.txid = index_js_2.Utils.toHex(txidBytes);
283
+ response.txid = Utils.toHex(txidBytes);
261
284
  }
262
285
  // Parse tx
263
286
  const txFlag = resultReader.readInt8();
@@ -280,7 +303,7 @@ class WalletWireTransceiver {
280
303
  response.sendWithResults = [];
281
304
  for (let i = 0; i < sendWithResultsLength; i++) {
282
305
  const txidBytes = resultReader.read(32);
283
- const txid = index_js_2.Utils.toHex(txidBytes);
306
+ const txid = Utils.toHex(txidBytes);
284
307
  const statusCode = resultReader.readInt8();
285
308
  let status = 'unproven';
286
309
  if (statusCode === 1)
@@ -301,13 +324,13 @@ class WalletWireTransceiver {
301
324
  const referenceBytes = resultReader.read(referenceLength);
302
325
  response.signableTransaction = {
303
326
  tx,
304
- reference: index_js_2.Utils.toBase64(referenceBytes)
327
+ reference: Utils.toBase64(referenceBytes)
305
328
  };
306
329
  }
307
330
  return response;
308
331
  }
309
332
  async signAction(args, originator) {
310
- const paramWriter = new index_js_2.Utils.Writer();
333
+ const paramWriter = new Utils.Writer();
311
334
  // Serialize spends
312
335
  const spendIndexes = Object.keys(args.spends);
313
336
  paramWriter.writeVarIntNum(spendIndexes.length);
@@ -315,7 +338,7 @@ class WalletWireTransceiver {
315
338
  paramWriter.writeVarIntNum(Number(index));
316
339
  const spend = args.spends[Number(index)];
317
340
  // unlockingScript
318
- const unlockingScriptBytes = index_js_2.Utils.toArray(spend.unlockingScript, 'hex');
341
+ const unlockingScriptBytes = Utils.toArray(spend.unlockingScript, 'hex');
319
342
  paramWriter.writeVarIntNum(unlockingScriptBytes.length);
320
343
  paramWriter.write(unlockingScriptBytes);
321
344
  // sequenceNumber
@@ -327,7 +350,7 @@ class WalletWireTransceiver {
327
350
  }
328
351
  }
329
352
  // Serialize reference
330
- const referenceBytes = index_js_2.Utils.toArray(args.reference, 'base64');
353
+ const referenceBytes = Utils.toArray(args.reference, 'base64');
331
354
  paramWriter.writeVarIntNum(referenceBytes.length);
332
355
  paramWriter.write(referenceBytes);
333
356
  // Serialize options
@@ -358,7 +381,7 @@ class WalletWireTransceiver {
358
381
  if (args.options.sendWith != null) {
359
382
  paramWriter.writeVarIntNum(args.options.sendWith.length);
360
383
  for (const txid of args.options.sendWith) {
361
- const txidBytes = index_js_2.Utils.toArray(txid, 'hex');
384
+ const txidBytes = Utils.toArray(txid, 'hex');
362
385
  paramWriter.write(txidBytes);
363
386
  }
364
387
  }
@@ -371,13 +394,13 @@ class WalletWireTransceiver {
371
394
  }
372
395
  // Transmit and parse response
373
396
  const result = await this.transmit('signAction', originator, paramWriter.toArray());
374
- const resultReader = new index_js_2.Utils.Reader(result);
397
+ const resultReader = new Utils.Reader(result);
375
398
  const response = {};
376
399
  // Parse txid
377
400
  const txidFlag = resultReader.readInt8();
378
401
  if (txidFlag === 1) {
379
402
  const txidBytes = resultReader.read(32);
380
- response.txid = index_js_2.Utils.toHex(txidBytes);
403
+ response.txid = Utils.toHex(txidBytes);
381
404
  }
382
405
  // Parse tx
383
406
  const txFlag = resultReader.readInt8();
@@ -391,7 +414,7 @@ class WalletWireTransceiver {
391
414
  response.sendWithResults = [];
392
415
  for (let i = 0; i < sendWithResultsLength; i++) {
393
416
  const txidBytes = resultReader.read(32);
394
- const txid = index_js_2.Utils.toHex(txidBytes);
417
+ const txid = Utils.toHex(txidBytes);
395
418
  const statusCode = resultReader.readInt8();
396
419
  let status = 'unproven';
397
420
  if (statusCode === 1)
@@ -406,15 +429,15 @@ class WalletWireTransceiver {
406
429
  return response;
407
430
  }
408
431
  async abortAction(args, originator) {
409
- await this.transmit('abortAction', originator, index_js_2.Utils.toArray(args.reference, 'base64'));
432
+ await this.transmit('abortAction', originator, Utils.toArray(args.reference, 'base64'));
410
433
  return { aborted: true };
411
434
  }
412
435
  async listActions(args, originator) {
413
- const paramWriter = new index_js_2.Utils.Writer();
436
+ const paramWriter = new Utils.Writer();
414
437
  // Serialize labels
415
438
  paramWriter.writeVarIntNum(args.labels.length);
416
439
  for (const label of args.labels) {
417
- const labelBytes = index_js_2.Utils.toArray(label, 'utf8');
440
+ const labelBytes = Utils.toArray(label, 'utf8');
418
441
  paramWriter.writeVarIntNum(labelBytes.length);
419
442
  paramWriter.write(labelBytes);
420
443
  }
@@ -466,13 +489,13 @@ class WalletWireTransceiver {
466
489
  : -1);
467
490
  // Transmit and parse response
468
491
  const result = await this.transmit('listActions', originator, paramWriter.toArray());
469
- const resultReader = new index_js_2.Utils.Reader(result);
492
+ const resultReader = new Utils.Reader(result);
470
493
  const totalActions = resultReader.readVarIntNum();
471
494
  const actions = [];
472
495
  for (let i = 0; i < totalActions; i++) {
473
496
  // Parse action fields
474
497
  const txidBytes = resultReader.read(32);
475
- const txid = index_js_2.Utils.toHex(txidBytes);
498
+ const txid = Utils.toHex(txidBytes);
476
499
  const satoshis = resultReader.readVarIntNum();
477
500
  const statusCode = resultReader.readInt8();
478
501
  let status;
@@ -504,7 +527,7 @@ class WalletWireTransceiver {
504
527
  const isOutgoing = resultReader.readInt8() === 1;
505
528
  const descriptionLength = resultReader.readVarIntNum();
506
529
  const descriptionBytes = resultReader.read(descriptionLength);
507
- const description = index_js_2.Utils.toUTF8(descriptionBytes);
530
+ const description = Utils.toUTF8(descriptionBytes);
508
531
  const action = {
509
532
  txid,
510
533
  satoshis,
@@ -521,7 +544,7 @@ class WalletWireTransceiver {
521
544
  for (let j = 0; j < labelsLength; j++) {
522
545
  const labelLength = resultReader.readVarIntNum();
523
546
  const labelBytes = resultReader.read(labelLength);
524
- action.labels.push(index_js_2.Utils.toUTF8(labelBytes));
547
+ action.labels.push(Utils.toUTF8(labelBytes));
525
548
  }
526
549
  }
527
550
  // Parse version and lockTime
@@ -539,19 +562,19 @@ class WalletWireTransceiver {
539
562
  let sourceLockingScript;
540
563
  if (sourceLockingScriptLength >= 0) {
541
564
  const sourceLockingScriptBytes = resultReader.read(sourceLockingScriptLength);
542
- sourceLockingScript = index_js_2.Utils.toHex(sourceLockingScriptBytes);
565
+ sourceLockingScript = Utils.toHex(sourceLockingScriptBytes);
543
566
  }
544
567
  // unlockingScript
545
568
  const unlockingScriptLength = resultReader.readVarIntNum();
546
569
  let unlockingScript;
547
570
  if (unlockingScriptLength >= 0) {
548
571
  const unlockingScriptBytes = resultReader.read(unlockingScriptLength);
549
- unlockingScript = index_js_2.Utils.toHex(unlockingScriptBytes);
572
+ unlockingScript = Utils.toHex(unlockingScriptBytes);
550
573
  }
551
574
  // inputDescription
552
575
  const inputDescriptionLength = resultReader.readVarIntNum();
553
576
  const inputDescriptionBytes = resultReader.read(inputDescriptionLength);
554
- const inputDescription = index_js_2.Utils.toUTF8(inputDescriptionBytes);
577
+ const inputDescription = Utils.toUTF8(inputDescriptionBytes);
555
578
  // sequenceNumber
556
579
  const sequenceNumber = resultReader.readVarIntNum();
557
580
  action.inputs.push({
@@ -576,19 +599,19 @@ class WalletWireTransceiver {
576
599
  let lockingScript;
577
600
  if (lockingScriptLength >= 0) {
578
601
  const lockingScriptBytes = resultReader.read(lockingScriptLength);
579
- lockingScript = index_js_2.Utils.toHex(lockingScriptBytes);
602
+ lockingScript = Utils.toHex(lockingScriptBytes);
580
603
  }
581
604
  const spendable = resultReader.readInt8() === 1;
582
605
  // outputDescription
583
606
  const outputDescriptionLength = resultReader.readVarIntNum();
584
607
  const outputDescriptionBytes = resultReader.read(outputDescriptionLength);
585
- const outputDescription = index_js_2.Utils.toUTF8(outputDescriptionBytes);
608
+ const outputDescription = Utils.toUTF8(outputDescriptionBytes);
586
609
  // basket
587
610
  const basketLength = resultReader.readVarIntNum();
588
611
  let basket;
589
612
  if (basketLength >= 0) {
590
613
  const basketBytes = resultReader.read(basketLength);
591
- basket = index_js_2.Utils.toUTF8(basketBytes);
614
+ basket = Utils.toUTF8(basketBytes);
592
615
  }
593
616
  // tags
594
617
  const tagsLength = resultReader.readVarIntNum();
@@ -597,7 +620,7 @@ class WalletWireTransceiver {
597
620
  for (let m = 0; m < tagsLength; m++) {
598
621
  const tagLength = resultReader.readVarIntNum();
599
622
  const tagBytes = resultReader.read(tagLength);
600
- tags.push(index_js_2.Utils.toUTF8(tagBytes));
623
+ tags.push(Utils.toUTF8(tagBytes));
601
624
  }
602
625
  }
603
626
  // customInstructions
@@ -605,7 +628,7 @@ class WalletWireTransceiver {
605
628
  let customInstructions;
606
629
  if (customInstructionsLength >= 0) {
607
630
  const customInstructionsBytes = resultReader.read(customInstructionsLength);
608
- customInstructions = index_js_2.Utils.toUTF8(customInstructionsBytes);
631
+ customInstructions = Utils.toUTF8(customInstructionsBytes);
609
632
  }
610
633
  action.outputs.push({
611
634
  outputIndex,
@@ -628,7 +651,7 @@ class WalletWireTransceiver {
628
651
  }
629
652
  async internalizeAction(args, originator) {
630
653
  var _a, _b, _c;
631
- const paramWriter = new index_js_2.Utils.Writer();
654
+ const paramWriter = new Utils.Writer();
632
655
  paramWriter.writeVarIntNum(args.tx.length);
633
656
  paramWriter.write(args.tx);
634
657
  paramWriter.writeVarIntNum(args.outputs.length);
@@ -639,21 +662,21 @@ class WalletWireTransceiver {
639
662
  throw new Error('Payment remittance is required for wallet payment');
640
663
  }
641
664
  paramWriter.writeUInt8(1);
642
- paramWriter.write(index_js_2.Utils.toArray(out.paymentRemittance.senderIdentityKey, 'hex'));
643
- const derivationPrefixAsArray = index_js_2.Utils.toArray(out.paymentRemittance.derivationPrefix, 'base64');
665
+ paramWriter.write(Utils.toArray(out.paymentRemittance.senderIdentityKey, 'hex'));
666
+ const derivationPrefixAsArray = Utils.toArray(out.paymentRemittance.derivationPrefix, 'base64');
644
667
  paramWriter.writeVarIntNum(derivationPrefixAsArray.length);
645
668
  paramWriter.write(derivationPrefixAsArray);
646
- const derivationSuffixAsArray = index_js_2.Utils.toArray(out.paymentRemittance.derivationSuffix, 'base64');
669
+ const derivationSuffixAsArray = Utils.toArray(out.paymentRemittance.derivationSuffix, 'base64');
647
670
  paramWriter.writeVarIntNum(derivationSuffixAsArray.length);
648
671
  paramWriter.write(derivationSuffixAsArray);
649
672
  }
650
673
  else {
651
674
  paramWriter.writeUInt8(2);
652
- const basketAsArray = index_js_2.Utils.toArray((_a = out.insertionRemittance) === null || _a === void 0 ? void 0 : _a.basket, 'utf8');
675
+ const basketAsArray = Utils.toArray((_a = out.insertionRemittance) === null || _a === void 0 ? void 0 : _a.basket, 'utf8');
653
676
  paramWriter.writeVarIntNum(basketAsArray.length);
654
677
  paramWriter.write(basketAsArray);
655
678
  if (typeof ((_b = out.insertionRemittance) === null || _b === void 0 ? void 0 : _b.customInstructions) === 'string' && out.insertionRemittance.customInstructions !== '') {
656
- const customInstructionsAsArray = index_js_2.Utils.toArray(out.insertionRemittance.customInstructions, 'utf8');
679
+ const customInstructionsAsArray = Utils.toArray(out.insertionRemittance.customInstructions, 'utf8');
657
680
  paramWriter.writeVarIntNum(customInstructionsAsArray.length);
658
681
  paramWriter.write(customInstructionsAsArray);
659
682
  }
@@ -663,7 +686,7 @@ class WalletWireTransceiver {
663
686
  if (typeof ((_c = out.insertionRemittance) === null || _c === void 0 ? void 0 : _c.tags) === 'object') {
664
687
  paramWriter.writeVarIntNum(out.insertionRemittance.tags.length);
665
688
  for (const tag of out.insertionRemittance.tags) {
666
- const tagAsArray = index_js_2.Utils.toArray(tag, 'utf8');
689
+ const tagAsArray = Utils.toArray(tag, 'utf8');
667
690
  paramWriter.writeVarIntNum(tagAsArray.length);
668
691
  paramWriter.write(tagAsArray);
669
692
  }
@@ -676,7 +699,7 @@ class WalletWireTransceiver {
676
699
  if (typeof args.labels === 'object') {
677
700
  paramWriter.writeVarIntNum(args.labels.length);
678
701
  for (const l of args.labels) {
679
- const labelAsArray = index_js_2.Utils.toArray(l, 'utf8');
702
+ const labelAsArray = Utils.toArray(l, 'utf8');
680
703
  paramWriter.writeVarIntNum(labelAsArray.length);
681
704
  paramWriter.write(labelAsArray);
682
705
  }
@@ -684,7 +707,7 @@ class WalletWireTransceiver {
684
707
  else {
685
708
  paramWriter.writeVarIntNum(-1);
686
709
  }
687
- const descriptionAsArray = index_js_2.Utils.toArray(args.description);
710
+ const descriptionAsArray = Utils.toArray(args.description);
688
711
  paramWriter.writeVarIntNum(descriptionAsArray.length);
689
712
  paramWriter.write(descriptionAsArray);
690
713
  // Serialize seekPermission
@@ -697,14 +720,14 @@ class WalletWireTransceiver {
697
720
  return { accepted: true };
698
721
  }
699
722
  async listOutputs(args, originator) {
700
- const paramWriter = new index_js_2.Utils.Writer();
701
- const basketAsArray = index_js_2.Utils.toArray(args.basket, 'utf8');
723
+ const paramWriter = new Utils.Writer();
724
+ const basketAsArray = Utils.toArray(args.basket, 'utf8');
702
725
  paramWriter.writeVarIntNum(basketAsArray.length);
703
726
  paramWriter.write(basketAsArray);
704
727
  if (typeof args.tags === 'object') {
705
728
  paramWriter.writeVarIntNum(args.tags.length);
706
729
  for (const tag of args.tags) {
707
- const tagAsArray = index_js_2.Utils.toArray(tag, 'utf8');
730
+ const tagAsArray = Utils.toArray(tag, 'utf8');
708
731
  paramWriter.writeVarIntNum(tagAsArray.length);
709
732
  paramWriter.write(tagAsArray);
710
733
  }
@@ -767,7 +790,7 @@ class WalletWireTransceiver {
767
790
  : 0
768
791
  : -1);
769
792
  const result = await this.transmit('listOutputs', originator, paramWriter.toArray());
770
- const resultReader = new index_js_2.Utils.Reader(result);
793
+ const resultReader = new Utils.Reader(result);
771
794
  const totalOutputs = resultReader.readVarIntNum();
772
795
  const beefLength = resultReader.readVarIntNum();
773
796
  let BEEF;
@@ -785,18 +808,18 @@ class WalletWireTransceiver {
785
808
  };
786
809
  const scriptLength = resultReader.readVarIntNum();
787
810
  if (scriptLength >= 0) {
788
- output.lockingScript = index_js_2.Utils.toHex(resultReader.read(scriptLength));
811
+ output.lockingScript = Utils.toHex(resultReader.read(scriptLength));
789
812
  }
790
813
  const customInstructionsLength = resultReader.readVarIntNum();
791
814
  if (customInstructionsLength >= 0) {
792
- output.customInstructions = index_js_2.Utils.toUTF8(resultReader.read(customInstructionsLength));
815
+ output.customInstructions = Utils.toUTF8(resultReader.read(customInstructionsLength));
793
816
  }
794
817
  const tagsLength = resultReader.readVarIntNum();
795
818
  if (tagsLength !== -1) {
796
819
  const tags = [];
797
820
  for (let i = 0; i < tagsLength; i++) {
798
821
  const tagLength = resultReader.readVarIntNum();
799
- tags.push(index_js_2.Utils.toUTF8(resultReader.read(tagLength)));
822
+ tags.push(Utils.toUTF8(resultReader.read(tagLength)));
800
823
  }
801
824
  output.tags = tags;
802
825
  }
@@ -805,7 +828,7 @@ class WalletWireTransceiver {
805
828
  const labels = [];
806
829
  for (let i = 0; i < labelsLength; i++) {
807
830
  const labelLength = resultReader.readVarIntNum();
808
- labels.push(index_js_2.Utils.toUTF8(resultReader.read(labelLength)));
831
+ labels.push(Utils.toUTF8(resultReader.read(labelLength)));
809
832
  }
810
833
  output.labels = labels;
811
834
  }
@@ -818,8 +841,8 @@ class WalletWireTransceiver {
818
841
  };
819
842
  }
820
843
  async relinquishOutput(args, originator) {
821
- const paramWriter = new index_js_2.Utils.Writer();
822
- const basketAsArray = index_js_2.Utils.toArray(args.basket, 'utf8');
844
+ const paramWriter = new Utils.Writer();
845
+ const basketAsArray = Utils.toArray(args.basket, 'utf8');
823
846
  paramWriter.writeVarIntNum(basketAsArray.length);
824
847
  paramWriter.write(basketAsArray);
825
848
  paramWriter.write(this.encodeOutpoint(args.output));
@@ -827,20 +850,20 @@ class WalletWireTransceiver {
827
850
  return { relinquished: true };
828
851
  }
829
852
  encodeOutpoint(outpoint) {
830
- const writer = new index_js_2.Utils.Writer();
853
+ const writer = new Utils.Writer();
831
854
  const [txid, index] = outpoint.split('.');
832
- writer.write(index_js_2.Utils.toArray(txid, 'hex'));
855
+ writer.write(Utils.toArray(txid, 'hex'));
833
856
  writer.writeVarIntNum(Number(index));
834
857
  return writer.toArray();
835
858
  }
836
859
  readOutpoint(reader) {
837
- const txid = index_js_2.Utils.toHex(reader.read(32));
860
+ const txid = Utils.toHex(reader.read(32));
838
861
  const index = reader.readVarIntNum();
839
862
  return `${txid}.${index}`;
840
863
  }
841
864
  async getPublicKey(args, originator) {
842
865
  var _a, _b;
843
- const paramWriter = new index_js_2.Utils.Writer();
866
+ const paramWriter = new Utils.Writer();
844
867
  paramWriter.writeUInt8(args.identityKey ? 1 : 0);
845
868
  if (!args.identityKey) {
846
869
  paramWriter.write(this.encodeKeyRelatedParams((_a = args.protocolID) !== null && _a !== void 0 ? _a : (args.protocolID = [Wallet_interfaces_js_1.SecurityLevels.Silent, 'default']), (_b = args.keyID) !== null && _b !== void 0 ? _b : (args.keyID = ''), args.counterparty, args.privileged, args.privilegedReason));
@@ -862,21 +885,21 @@ class WalletWireTransceiver {
862
885
  : -1);
863
886
  const result = await this.transmit('getPublicKey', originator, paramWriter.toArray());
864
887
  return {
865
- publicKey: index_js_2.Utils.toHex(result)
888
+ publicKey: Utils.toHex(result)
866
889
  };
867
890
  }
868
891
  async revealCounterpartyKeyLinkage(args, originator) {
869
- const paramWriter = new index_js_2.Utils.Writer();
892
+ const paramWriter = new Utils.Writer();
870
893
  paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
871
- paramWriter.write(index_js_2.Utils.toArray(args.counterparty, 'hex'));
872
- paramWriter.write(index_js_2.Utils.toArray(args.verifier, 'hex'));
894
+ paramWriter.write(Utils.toArray(args.counterparty, 'hex'));
895
+ paramWriter.write(Utils.toArray(args.verifier, 'hex'));
873
896
  const result = await this.transmit('revealCounterpartyKeyLinkage', originator, paramWriter.toArray());
874
- const resultReader = new index_js_2.Utils.Reader(result);
875
- const prover = index_js_2.Utils.toHex(resultReader.read(33));
876
- const verifier = index_js_2.Utils.toHex(resultReader.read(33));
877
- const counterparty = index_js_2.Utils.toHex(resultReader.read(33));
897
+ const resultReader = new Utils.Reader(result);
898
+ const prover = Utils.toHex(resultReader.read(33));
899
+ const verifier = Utils.toHex(resultReader.read(33));
900
+ const counterparty = Utils.toHex(resultReader.read(33));
878
901
  const revelationTimeLength = resultReader.readVarIntNum();
879
- const revelationTime = index_js_2.Utils.toUTF8(resultReader.read(revelationTimeLength));
902
+ const revelationTime = Utils.toUTF8(resultReader.read(revelationTimeLength));
880
903
  const encryptedLinkageLength = resultReader.readVarIntNum();
881
904
  const encryptedLinkage = resultReader.read(encryptedLinkageLength);
882
905
  const encryptedLinkageProofLength = resultReader.readVarIntNum();
@@ -891,19 +914,19 @@ class WalletWireTransceiver {
891
914
  };
892
915
  }
893
916
  async revealSpecificKeyLinkage(args, originator) {
894
- const paramWriter = new index_js_2.Utils.Writer();
917
+ const paramWriter = new Utils.Writer();
895
918
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
896
- paramWriter.write(index_js_2.Utils.toArray(args.verifier, 'hex'));
919
+ paramWriter.write(Utils.toArray(args.verifier, 'hex'));
897
920
  const result = await this.transmit('revealSpecificKeyLinkage', originator, paramWriter.toArray());
898
- const resultReader = new index_js_2.Utils.Reader(result);
899
- const prover = index_js_2.Utils.toHex(resultReader.read(33));
900
- const verifier = index_js_2.Utils.toHex(resultReader.read(33));
901
- const counterparty = index_js_2.Utils.toHex(resultReader.read(33));
921
+ const resultReader = new Utils.Reader(result);
922
+ const prover = Utils.toHex(resultReader.read(33));
923
+ const verifier = Utils.toHex(resultReader.read(33));
924
+ const counterparty = Utils.toHex(resultReader.read(33));
902
925
  const securityLevel = resultReader.readUInt8();
903
926
  const protocolLength = resultReader.readVarIntNum();
904
- const protocol = index_js_2.Utils.toUTF8(resultReader.read(protocolLength));
927
+ const protocol = Utils.toUTF8(resultReader.read(protocolLength));
905
928
  const keyIDLength = resultReader.readVarIntNum();
906
- const keyID = index_js_2.Utils.toUTF8(resultReader.read(keyIDLength));
929
+ const keyID = Utils.toUTF8(resultReader.read(keyIDLength));
907
930
  const encryptedLinkageLength = resultReader.readVarIntNum();
908
931
  const encryptedLinkage = resultReader.read(encryptedLinkageLength);
909
932
  const encryptedLinkageProofLength = resultReader.readVarIntNum();
@@ -921,7 +944,7 @@ class WalletWireTransceiver {
921
944
  };
922
945
  }
923
946
  async encrypt(args, originator) {
924
- const paramWriter = new index_js_2.Utils.Writer();
947
+ const paramWriter = new Utils.Writer();
925
948
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
926
949
  paramWriter.writeVarIntNum(args.plaintext.length);
927
950
  paramWriter.write(args.plaintext);
@@ -936,7 +959,7 @@ class WalletWireTransceiver {
936
959
  };
937
960
  }
938
961
  async decrypt(args, originator) {
939
- const paramWriter = new index_js_2.Utils.Writer();
962
+ const paramWriter = new Utils.Writer();
940
963
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
941
964
  paramWriter.writeVarIntNum(args.ciphertext.length);
942
965
  paramWriter.write(args.ciphertext);
@@ -951,7 +974,7 @@ class WalletWireTransceiver {
951
974
  };
952
975
  }
953
976
  async createHmac(args, originator) {
954
- const paramWriter = new index_js_2.Utils.Writer();
977
+ const paramWriter = new Utils.Writer();
955
978
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
956
979
  paramWriter.writeVarIntNum(args.data.length);
957
980
  paramWriter.write(args.data);
@@ -966,7 +989,7 @@ class WalletWireTransceiver {
966
989
  };
967
990
  }
968
991
  async verifyHmac(args, originator) {
969
- const paramWriter = new index_js_2.Utils.Writer();
992
+ const paramWriter = new Utils.Writer();
970
993
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
971
994
  paramWriter.write(args.hmac);
972
995
  paramWriter.writeVarIntNum(args.data.length);
@@ -982,7 +1005,7 @@ class WalletWireTransceiver {
982
1005
  }
983
1006
  async createSignature(args, originator) {
984
1007
  var _a;
985
- const paramWriter = new index_js_2.Utils.Writer();
1008
+ const paramWriter = new Utils.Writer();
986
1009
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
987
1010
  if (typeof args.data === 'object') {
988
1011
  paramWriter.writeUInt8(1);
@@ -1005,7 +1028,7 @@ class WalletWireTransceiver {
1005
1028
  }
1006
1029
  async verifySignature(args, originator) {
1007
1030
  var _a;
1008
- const paramWriter = new index_js_2.Utils.Writer();
1031
+ const paramWriter = new Utils.Writer();
1009
1032
  paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
1010
1033
  if (typeof args.forSelf === 'boolean') {
1011
1034
  paramWriter.writeInt8(args.forSelf ? 1 : 0);
@@ -1034,12 +1057,12 @@ class WalletWireTransceiver {
1034
1057
  return { valid: true };
1035
1058
  }
1036
1059
  encodeKeyRelatedParams(protocolID, keyID, counterparty, privileged, privilegedReason) {
1037
- const paramWriter = new index_js_2.Utils.Writer();
1060
+ const paramWriter = new Utils.Writer();
1038
1061
  paramWriter.writeUInt8(protocolID[0]);
1039
- const protocolAsArray = index_js_2.Utils.toArray(protocolID[1], 'utf8');
1062
+ const protocolAsArray = Utils.toArray(protocolID[1], 'utf8');
1040
1063
  paramWriter.writeVarIntNum(protocolAsArray.length);
1041
1064
  paramWriter.write(protocolAsArray);
1042
- const keyIDAsArray = index_js_2.Utils.toArray(keyID, 'utf8');
1065
+ const keyIDAsArray = Utils.toArray(keyID, 'utf8');
1043
1066
  paramWriter.writeVarIntNum(keyIDAsArray.length);
1044
1067
  paramWriter.write(keyIDAsArray);
1045
1068
  if (typeof counterparty !== 'string') {
@@ -1052,21 +1075,21 @@ class WalletWireTransceiver {
1052
1075
  paramWriter.writeUInt8(12);
1053
1076
  }
1054
1077
  else {
1055
- paramWriter.write(index_js_2.Utils.toArray(counterparty, 'hex'));
1078
+ paramWriter.write(Utils.toArray(counterparty, 'hex'));
1056
1079
  }
1057
1080
  paramWriter.write(this.encodePrivilegedParams(privileged, privilegedReason));
1058
1081
  return paramWriter.toArray();
1059
1082
  }
1060
1083
  async acquireCertificate(args, originator) {
1061
1084
  var _a, _b, _c;
1062
- const paramWriter = new index_js_2.Utils.Writer();
1063
- paramWriter.write(index_js_2.Utils.toArray(args.type, 'base64'));
1064
- paramWriter.write(index_js_2.Utils.toArray(args.certifier, 'hex'));
1085
+ const paramWriter = new Utils.Writer();
1086
+ paramWriter.write(Utils.toArray(args.type, 'base64'));
1087
+ paramWriter.write(Utils.toArray(args.certifier, 'hex'));
1065
1088
  const fieldEntries = Object.entries(args.fields);
1066
1089
  paramWriter.writeVarIntNum(fieldEntries.length);
1067
1090
  for (const [key, value] of fieldEntries) {
1068
- const keyAsArray = index_js_2.Utils.toArray(key, 'utf8');
1069
- const valueAsArray = index_js_2.Utils.toArray(value, 'utf8');
1091
+ const keyAsArray = Utils.toArray(key, 'utf8');
1092
+ const valueAsArray = Utils.toArray(value, 'utf8');
1070
1093
  paramWriter.writeVarIntNum(keyAsArray.length);
1071
1094
  paramWriter.write(keyAsArray);
1072
1095
  paramWriter.writeVarIntNum(valueAsArray.length);
@@ -1075,40 +1098,40 @@ class WalletWireTransceiver {
1075
1098
  paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
1076
1099
  paramWriter.writeUInt8(args.acquisitionProtocol === 'direct' ? 1 : 2);
1077
1100
  if (args.acquisitionProtocol === 'direct') {
1078
- paramWriter.write(index_js_2.Utils.toArray(args.serialNumber, 'base64'));
1101
+ paramWriter.write(Utils.toArray(args.serialNumber, 'base64'));
1079
1102
  paramWriter.write(this.encodeOutpoint((_a = args.revocationOutpoint) !== null && _a !== void 0 ? _a : ''));
1080
- const signatureAsArray = index_js_2.Utils.toArray(args.signature, 'hex');
1103
+ const signatureAsArray = Utils.toArray(args.signature, 'hex');
1081
1104
  paramWriter.writeVarIntNum(signatureAsArray.length);
1082
1105
  paramWriter.write(signatureAsArray);
1083
1106
  const keyringRevealerAsArray = args.keyringRevealer !== 'certifier'
1084
- ? index_js_2.Utils.toArray(args.keyringRevealer, 'hex')
1107
+ ? Utils.toArray(args.keyringRevealer, 'hex')
1085
1108
  : [11];
1086
1109
  paramWriter.write(keyringRevealerAsArray);
1087
1110
  const keyringKeys = Object.keys((_b = args.keyringForSubject) !== null && _b !== void 0 ? _b : {});
1088
1111
  paramWriter.writeVarIntNum(keyringKeys.length);
1089
1112
  for (let i = 0; i < keyringKeys.length; i++) {
1090
- const keyringKeysAsArray = index_js_2.Utils.toArray(keyringKeys[i], 'utf8');
1113
+ const keyringKeysAsArray = Utils.toArray(keyringKeys[i], 'utf8');
1091
1114
  paramWriter.writeVarIntNum(keyringKeysAsArray.length);
1092
1115
  paramWriter.write(keyringKeysAsArray);
1093
- const keyringForSubjectAsArray = index_js_2.Utils.toArray((_c = args.keyringForSubject) === null || _c === void 0 ? void 0 : _c[keyringKeys[i]], 'base64');
1116
+ const keyringForSubjectAsArray = Utils.toArray((_c = args.keyringForSubject) === null || _c === void 0 ? void 0 : _c[keyringKeys[i]], 'base64');
1094
1117
  paramWriter.writeVarIntNum(keyringForSubjectAsArray.length);
1095
1118
  paramWriter.write(keyringForSubjectAsArray);
1096
1119
  }
1097
1120
  }
1098
1121
  else {
1099
- const certifierUrlAsArray = index_js_2.Utils.toArray(args.certifierUrl, 'utf8');
1122
+ const certifierUrlAsArray = Utils.toArray(args.certifierUrl, 'utf8');
1100
1123
  paramWriter.writeVarIntNum(certifierUrlAsArray.length);
1101
1124
  paramWriter.write(certifierUrlAsArray);
1102
1125
  }
1103
1126
  const result = await this.transmit('acquireCertificate', originator, paramWriter.toArray());
1104
- const cert = index_js_1.Certificate.fromBinary(result);
1127
+ const cert = Certificate_js_1.default.fromBinary(result);
1105
1128
  return {
1106
1129
  ...cert,
1107
1130
  signature: cert.signature
1108
1131
  };
1109
1132
  }
1110
1133
  encodePrivilegedParams(privileged, privilegedReason) {
1111
- const paramWriter = new index_js_2.Utils.Writer();
1134
+ const paramWriter = new Utils.Writer();
1112
1135
  if (typeof privileged === 'boolean') {
1113
1136
  paramWriter.writeInt8(privileged ? 1 : 0);
1114
1137
  }
@@ -1116,7 +1139,7 @@ class WalletWireTransceiver {
1116
1139
  paramWriter.writeInt8(-1);
1117
1140
  }
1118
1141
  if (typeof privilegedReason === 'string') {
1119
- const privilegedReasonAsArray = index_js_2.Utils.toArray(privilegedReason, 'utf8');
1142
+ const privilegedReasonAsArray = Utils.toArray(privilegedReason, 'utf8');
1120
1143
  paramWriter.writeInt8(privilegedReasonAsArray.length);
1121
1144
  paramWriter.write(privilegedReasonAsArray);
1122
1145
  }
@@ -1126,14 +1149,14 @@ class WalletWireTransceiver {
1126
1149
  return paramWriter.toArray();
1127
1150
  }
1128
1151
  async listCertificates(args, originator) {
1129
- const paramWriter = new index_js_2.Utils.Writer();
1152
+ const paramWriter = new Utils.Writer();
1130
1153
  paramWriter.writeVarIntNum(args.certifiers.length);
1131
1154
  for (let i = 0; i < args.certifiers.length; i++) {
1132
- paramWriter.write(index_js_2.Utils.toArray(args.certifiers[i], 'hex'));
1155
+ paramWriter.write(Utils.toArray(args.certifiers[i], 'hex'));
1133
1156
  }
1134
1157
  paramWriter.writeVarIntNum(args.types.length);
1135
1158
  for (let i = 0; i < args.types.length; i++) {
1136
- paramWriter.write(index_js_2.Utils.toArray(args.types[i], 'base64'));
1159
+ paramWriter.write(Utils.toArray(args.types[i], 'base64'));
1137
1160
  }
1138
1161
  if (typeof args.limit === 'number') {
1139
1162
  paramWriter.writeVarIntNum(args.limit);
@@ -1149,13 +1172,13 @@ class WalletWireTransceiver {
1149
1172
  }
1150
1173
  paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
1151
1174
  const result = await this.transmit('listCertificates', originator, paramWriter.toArray());
1152
- const resultReader = new index_js_2.Utils.Reader(result);
1175
+ const resultReader = new Utils.Reader(result);
1153
1176
  const totalCertificates = resultReader.readVarIntNum();
1154
1177
  const certificates = [];
1155
1178
  for (let i = 0; i < totalCertificates; i++) {
1156
1179
  const certificateLength = resultReader.readVarIntNum();
1157
1180
  const certificateBin = resultReader.read(certificateLength);
1158
- const cert = index_js_1.Certificate.fromBinary(certificateBin);
1181
+ const cert = Certificate_js_1.default.fromBinary(certificateBin);
1159
1182
  certificates.push({
1160
1183
  ...cert,
1161
1184
  signature: cert.signature
@@ -1168,25 +1191,25 @@ class WalletWireTransceiver {
1168
1191
  }
1169
1192
  async proveCertificate(args, originator) {
1170
1193
  var _a, _b;
1171
- const paramWriter = new index_js_2.Utils.Writer();
1172
- const typeAsArray = index_js_2.Utils.toArray(args.certificate.type, 'base64');
1194
+ const paramWriter = new Utils.Writer();
1195
+ const typeAsArray = Utils.toArray(args.certificate.type, 'base64');
1173
1196
  paramWriter.write(typeAsArray);
1174
- const subjectAsArray = index_js_2.Utils.toArray(args.certificate.subject, 'hex');
1197
+ const subjectAsArray = Utils.toArray(args.certificate.subject, 'hex');
1175
1198
  paramWriter.write(subjectAsArray);
1176
- const serialNumberAsArray = index_js_2.Utils.toArray(args.certificate.serialNumber, 'base64');
1199
+ const serialNumberAsArray = Utils.toArray(args.certificate.serialNumber, 'base64');
1177
1200
  paramWriter.write(serialNumberAsArray);
1178
- const certifierAsArray = index_js_2.Utils.toArray(args.certificate.certifier, 'hex');
1201
+ const certifierAsArray = Utils.toArray(args.certificate.certifier, 'hex');
1179
1202
  paramWriter.write(certifierAsArray);
1180
1203
  const revocationOutpointAsArray = this.encodeOutpoint((_a = args.certificate.revocationOutpoint) !== null && _a !== void 0 ? _a : '');
1181
1204
  paramWriter.write(revocationOutpointAsArray);
1182
- const signatureAsArray = index_js_2.Utils.toArray(args.certificate.signature, 'hex');
1205
+ const signatureAsArray = Utils.toArray(args.certificate.signature, 'hex');
1183
1206
  paramWriter.writeVarIntNum(signatureAsArray.length);
1184
1207
  paramWriter.write(signatureAsArray);
1185
1208
  const fieldEntries = Object.entries((_b = args.certificate.fields) !== null && _b !== void 0 ? _b : {});
1186
1209
  paramWriter.writeVarIntNum(fieldEntries.length);
1187
1210
  for (const [key, value] of fieldEntries) {
1188
- const keyAsArray = index_js_2.Utils.toArray(key, 'utf8');
1189
- const valueAsArray = index_js_2.Utils.toArray(value, 'utf8');
1211
+ const keyAsArray = Utils.toArray(key, 'utf8');
1212
+ const valueAsArray = Utils.toArray(value, 'utf8');
1190
1213
  paramWriter.writeVarIntNum(keyAsArray.length);
1191
1214
  paramWriter.write(keyAsArray);
1192
1215
  paramWriter.writeVarIntNum(valueAsArray.length);
@@ -1194,57 +1217,57 @@ class WalletWireTransceiver {
1194
1217
  }
1195
1218
  paramWriter.writeVarIntNum(args.fieldsToReveal.length);
1196
1219
  for (const field of args.fieldsToReveal) {
1197
- const fieldAsArray = index_js_2.Utils.toArray(field, 'utf8');
1220
+ const fieldAsArray = Utils.toArray(field, 'utf8');
1198
1221
  paramWriter.writeVarIntNum(fieldAsArray.length);
1199
1222
  paramWriter.write(fieldAsArray);
1200
1223
  }
1201
- paramWriter.write(index_js_2.Utils.toArray(args.verifier, 'hex'));
1224
+ paramWriter.write(Utils.toArray(args.verifier, 'hex'));
1202
1225
  paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
1203
1226
  const result = await this.transmit('proveCertificate', originator, paramWriter.toArray());
1204
- const resultReader = new index_js_2.Utils.Reader(result);
1227
+ const resultReader = new Utils.Reader(result);
1205
1228
  const numFields = resultReader.readVarIntNum();
1206
1229
  const keyringForVerifier = {};
1207
1230
  for (let i = 0; i < numFields; i++) {
1208
1231
  const fieldKeyLength = resultReader.readVarIntNum();
1209
- const fieldKey = index_js_2.Utils.toUTF8(resultReader.read(fieldKeyLength));
1232
+ const fieldKey = Utils.toUTF8(resultReader.read(fieldKeyLength));
1210
1233
  const fieldValueLength = resultReader.readVarIntNum();
1211
- keyringForVerifier[fieldKey] = index_js_2.Utils.toBase64(resultReader.read(fieldValueLength));
1234
+ keyringForVerifier[fieldKey] = Utils.toBase64(resultReader.read(fieldValueLength));
1212
1235
  }
1213
1236
  return {
1214
1237
  keyringForVerifier
1215
1238
  };
1216
1239
  }
1217
1240
  async relinquishCertificate(args, originator) {
1218
- const paramWriter = new index_js_2.Utils.Writer();
1219
- const typeAsArray = index_js_2.Utils.toArray(args.type, 'base64');
1241
+ const paramWriter = new Utils.Writer();
1242
+ const typeAsArray = Utils.toArray(args.type, 'base64');
1220
1243
  paramWriter.write(typeAsArray);
1221
- const serialNumberAsArray = index_js_2.Utils.toArray(args.serialNumber, 'base64');
1244
+ const serialNumberAsArray = Utils.toArray(args.serialNumber, 'base64');
1222
1245
  paramWriter.write(serialNumberAsArray);
1223
- const certifierAsArray = index_js_2.Utils.toArray(args.certifier, 'hex');
1246
+ const certifierAsArray = Utils.toArray(args.certifier, 'hex');
1224
1247
  paramWriter.write(certifierAsArray);
1225
1248
  await this.transmit('relinquishCertificate', originator, paramWriter.toArray());
1226
1249
  return { relinquished: true };
1227
1250
  }
1228
1251
  parseDiscoveryResult(result) {
1229
- const resultReader = new index_js_2.Utils.Reader(result);
1252
+ const resultReader = new Utils.Reader(result);
1230
1253
  const totalCertificates = resultReader.readVarIntNum();
1231
1254
  const certificates = [];
1232
1255
  for (let i = 0; i < totalCertificates; i++) {
1233
1256
  const certBinLen = resultReader.readVarIntNum();
1234
1257
  const certBin = resultReader.read(certBinLen);
1235
- const cert = index_js_1.Certificate.fromBinary(certBin);
1258
+ const cert = Certificate_js_1.default.fromBinary(certBin);
1236
1259
  const nameLength = resultReader.readVarIntNum();
1237
- const name = index_js_2.Utils.toUTF8(resultReader.read(nameLength));
1260
+ const name = Utils.toUTF8(resultReader.read(nameLength));
1238
1261
  const iconUrlLength = resultReader.readVarIntNum();
1239
- const iconUrl = index_js_2.Utils.toUTF8(resultReader.read(iconUrlLength));
1262
+ const iconUrl = Utils.toUTF8(resultReader.read(iconUrlLength));
1240
1263
  const descriptionLength = resultReader.readVarIntNum();
1241
- const description = index_js_2.Utils.toUTF8(resultReader.read(descriptionLength));
1264
+ const description = Utils.toUTF8(resultReader.read(descriptionLength));
1242
1265
  const trust = resultReader.readUInt8();
1243
1266
  const publiclyRevealedKeyring = {};
1244
1267
  const numPublicKeyringEntries = resultReader.readVarIntNum();
1245
1268
  for (let j = 0; j < numPublicKeyringEntries; j++) {
1246
1269
  const fieldKeyLen = resultReader.readVarIntNum();
1247
- const fieldKey = index_js_2.Utils.toUTF8(resultReader.read(fieldKeyLen));
1270
+ const fieldKey = Utils.toUTF8(resultReader.read(fieldKeyLen));
1248
1271
  const fieldValueLen = resultReader.readVarIntNum();
1249
1272
  publiclyRevealedKeyring[fieldKey] = resultReader.read(fieldValueLen);
1250
1273
  }
@@ -1252,9 +1275,9 @@ class WalletWireTransceiver {
1252
1275
  const numDecryptedFields = resultReader.readVarIntNum();
1253
1276
  for (let k = 0; k < numDecryptedFields; k++) {
1254
1277
  const fieldKeyLen = resultReader.readVarIntNum();
1255
- const fieldKey = index_js_2.Utils.toUTF8(resultReader.read(fieldKeyLen));
1278
+ const fieldKey = Utils.toUTF8(resultReader.read(fieldKeyLen));
1256
1279
  const fieldValueLen = resultReader.readVarIntNum();
1257
- decryptedFields[fieldKey] = index_js_2.Utils.toUTF8(resultReader.read(fieldValueLen));
1280
+ decryptedFields[fieldKey] = Utils.toUTF8(resultReader.read(fieldValueLen));
1258
1281
  }
1259
1282
  certificates.push({
1260
1283
  ...cert,
@@ -1270,8 +1293,8 @@ class WalletWireTransceiver {
1270
1293
  };
1271
1294
  }
1272
1295
  async discoverByIdentityKey(args, originator) {
1273
- const paramWriter = new index_js_2.Utils.Writer();
1274
- paramWriter.write(index_js_2.Utils.toArray(args.identityKey, 'hex'));
1296
+ const paramWriter = new Utils.Writer();
1297
+ paramWriter.write(Utils.toArray(args.identityKey, 'hex'));
1275
1298
  if (typeof args.limit === 'number') {
1276
1299
  paramWriter.writeVarIntNum(args.limit);
1277
1300
  }
@@ -1294,14 +1317,14 @@ class WalletWireTransceiver {
1294
1317
  return this.parseDiscoveryResult(result);
1295
1318
  }
1296
1319
  async discoverByAttributes(args, originator) {
1297
- const paramWriter = new index_js_2.Utils.Writer();
1320
+ const paramWriter = new Utils.Writer();
1298
1321
  const attributeKeys = Object.keys(args.attributes);
1299
1322
  paramWriter.writeVarIntNum(attributeKeys.length);
1300
1323
  for (let i = 0; i < attributeKeys.length; i++) {
1301
1324
  paramWriter.writeVarIntNum(attributeKeys[i].length);
1302
- paramWriter.write(index_js_2.Utils.toArray(attributeKeys[i], 'utf8'));
1325
+ paramWriter.write(Utils.toArray(attributeKeys[i], 'utf8'));
1303
1326
  paramWriter.writeVarIntNum(args.attributes[attributeKeys[i]].length);
1304
- paramWriter.write(index_js_2.Utils.toArray(args.attributes[attributeKeys[i]], 'utf8'));
1327
+ paramWriter.write(Utils.toArray(args.attributes[attributeKeys[i]], 'utf8'));
1305
1328
  }
1306
1329
  if (typeof args.limit === 'number') {
1307
1330
  paramWriter.writeVarIntNum(args.limit);
@@ -1335,17 +1358,17 @@ class WalletWireTransceiver {
1335
1358
  }
1336
1359
  async getHeight(args, originator) {
1337
1360
  const result = await this.transmit('getHeight', originator);
1338
- const resultReader = new index_js_2.Utils.Reader(result);
1361
+ const resultReader = new Utils.Reader(result);
1339
1362
  return {
1340
1363
  height: resultReader.readVarIntNum()
1341
1364
  };
1342
1365
  }
1343
1366
  async getHeaderForHeight(args, originator) {
1344
- const paramWriter = new index_js_2.Utils.Writer();
1367
+ const paramWriter = new Utils.Writer();
1345
1368
  paramWriter.writeVarIntNum(args.height);
1346
1369
  const header = await this.transmit('getHeaderForHeight', originator, paramWriter.toArray());
1347
1370
  return {
1348
- header: index_js_2.Utils.toHex(header)
1371
+ header: Utils.toHex(header)
1349
1372
  };
1350
1373
  }
1351
1374
  async getNetwork(args, originator) {
@@ -1357,7 +1380,7 @@ class WalletWireTransceiver {
1357
1380
  async getVersion(args, originator) {
1358
1381
  const version = await this.transmit('getVersion', originator);
1359
1382
  return {
1360
- version: index_js_2.Utils.toUTF8(version)
1383
+ version: Utils.toUTF8(version)
1361
1384
  };
1362
1385
  }
1363
1386
  }