@bsv/sdk 1.3.35 → 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.
- package/dist/cjs/mod.js +1 -0
- package/dist/cjs/mod.js.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/auth/Peer.js +42 -14
- package/dist/cjs/src/auth/Peer.js.map +1 -1
- package/dist/cjs/src/auth/certificates/Certificate.js +50 -22
- package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js +35 -10
- package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +28 -4
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +5 -2
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js +83 -27
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +70 -34
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/cjs/src/auth/utils/createNonce.js +31 -4
- package/dist/cjs/src/auth/utils/createNonce.js.map +1 -1
- package/dist/cjs/src/auth/utils/verifyNonce.js +26 -3
- package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/cjs/src/overlay-tools/LookupResolver.js +2 -2
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/src/primitives/utils.js.map +1 -1
- package/dist/cjs/src/storage/StorageUploader.js +93 -0
- package/dist/cjs/src/storage/StorageUploader.js.map +1 -0
- package/dist/cjs/src/storage/StorageUtils.js +73 -0
- package/dist/cjs/src/storage/StorageUtils.js.map +1 -0
- package/dist/cjs/src/storage/__test/StorageUploader.test.js +92 -0
- package/dist/cjs/src/storage/__test/StorageUploader.test.js.map +1 -0
- package/dist/cjs/src/storage/__test/StorageUtils.test.js +97 -0
- package/dist/cjs/src/storage/__test/StorageUtils.test.js.map +1 -0
- package/dist/cjs/src/storage/index.js +30 -0
- package/dist/cjs/src/storage/index.js.map +1 -0
- package/dist/cjs/src/wallet/WalletClient.js +4 -4
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js +26 -3
- package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +178 -155
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +171 -148
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/XDM.js +29 -2
- package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/mod.js +1 -0
- package/dist/esm/mod.js.map +1 -1
- package/dist/esm/src/auth/Peer.js +7 -5
- package/dist/esm/src/auth/Peer.js.map +1 -1
- package/dist/esm/src/auth/certificates/Certificate.js +3 -1
- package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js +3 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js +2 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +38 -8
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +31 -18
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/esm/src/auth/utils/createNonce.js +2 -1
- package/dist/esm/src/auth/utils/createNonce.js.map +1 -1
- package/dist/esm/src/auth/utils/verifyNonce.js +1 -1
- package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/esm/src/overlay-tools/LookupResolver.js +2 -2
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/src/primitives/utils.js.map +1 -1
- package/dist/esm/src/storage/StorageUploader.js +68 -0
- package/dist/esm/src/storage/StorageUploader.js.map +1 -0
- package/dist/esm/src/storage/StorageUtils.js +65 -0
- package/dist/esm/src/storage/StorageUtils.js.map +1 -0
- package/dist/esm/src/storage/__test/StorageUploader.test.js +64 -0
- package/dist/esm/src/storage/__test/StorageUploader.test.js.map +1 -0
- package/dist/esm/src/storage/__test/StorageUtils.test.js +72 -0
- package/dist/esm/src/storage/__test/StorageUtils.test.js.map +1 -0
- package/dist/esm/src/storage/index.js +3 -0
- package/dist/esm/src/storage/index.js.map +1 -0
- package/dist/esm/src/wallet/WalletClient.js +4 -4
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletWire.js +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +2 -2
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/esm/src/wallet/substrates/XDM.js +2 -1
- package/dist/esm/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +1 -0
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/types/src/auth/Peer.d.ts +1 -1
- package/dist/types/src/auth/Peer.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/Certificate.d.ts +2 -1
- package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts +2 -1
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts +2 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts +1 -1
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts.map +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts +10 -9
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts.map +1 -1
- package/dist/types/src/auth/utils/createNonce.d.ts +1 -1
- package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -1
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +1 -1
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -1
- package/dist/types/src/primitives/utils.d.ts +4 -1
- package/dist/types/src/primitives/utils.d.ts.map +1 -1
- package/dist/types/src/storage/StorageUploader.d.ts +40 -0
- package/dist/types/src/storage/StorageUploader.d.ts.map +1 -0
- package/dist/types/src/storage/StorageUtils.d.ts +31 -0
- package/dist/types/src/storage/StorageUtils.d.ts.map +1 -0
- package/dist/types/src/storage/__test/StorageUploader.test.d.ts +2 -0
- package/dist/types/src/storage/__test/StorageUploader.test.d.ts.map +1 -0
- package/dist/types/src/storage/__test/StorageUtils.test.d.ts +2 -0
- package/dist/types/src/storage/__test/StorageUtils.test.d.ts.map +1 -0
- package/dist/types/src/storage/index.d.ts +3 -0
- package/dist/types/src/storage/index.d.ts.map +1 -0
- package/dist/types/src/wallet/substrates/XDM.d.ts +1 -1
- package/dist/types/src/wallet/substrates/XDM.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/primitives.md +4 -1
- package/docs/storage.md +210 -0
- package/docs/wallet-substrates.md +0 -225
- package/mod.ts +1 -0
- package/package.json +12 -2
- package/src/auth/Peer.ts +8 -5
- package/src/auth/__tests/Peer.test.ts +43 -48
- package/src/auth/certificates/Certificate.ts +5 -5
- package/src/auth/certificates/MasterCertificate.ts +5 -5
- package/src/auth/certificates/VerifiableCertificate.ts +6 -6
- package/src/auth/certificates/__tests/CompletedProtoWallet.ts +1 -15
- package/src/auth/clients/AuthFetch.ts +59 -18
- package/src/auth/transports/SimplifiedFetchTransport.ts +31 -19
- package/src/auth/utils/__tests/cryptononce.test.ts +0 -2
- package/src/auth/utils/createNonce.ts +3 -3
- package/src/auth/utils/getVerifiableCertificates.ts +1 -1
- package/src/auth/utils/verifyNonce.ts +2 -1
- package/src/overlay-tools/LookupResolver.ts +2 -2
- package/src/primitives/utils.ts +1 -1
- package/src/storage/StorageUploader.ts +108 -0
- package/src/storage/StorageUtils.ts +66 -0
- package/src/storage/__test/StorageUploader.test.ts +80 -0
- package/src/storage/__test/StorageUtils.test.ts +86 -0
- package/src/storage/index.ts +2 -0
- package/src/transaction/__tests/Transaction.benchmarks.test.ts +1 -16
- package/src/wallet/WalletClient.ts +4 -4
- package/src/wallet/substrates/HTTPWalletWire.ts +1 -1
- package/src/wallet/substrates/WalletWireProcessor.ts +1 -1
- package/src/wallet/substrates/WalletWireTransceiver.ts +2 -2
- package/src/wallet/substrates/XDM.ts +3 -2
|
@@ -1,9 +1,32 @@
|
|
|
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
|
-
const
|
|
29
|
+
const Utils = __importStar(require("../../primitives/utils.js"));
|
|
7
30
|
const WalletWireCalls_js_1 = __importDefault(require("./WalletWireCalls.js"));
|
|
8
31
|
const Certificate_js_1 = __importDefault(require("../../auth/certificates/Certificate.js"));
|
|
9
32
|
/**
|
|
@@ -15,19 +38,19 @@ class WalletWireProcessor {
|
|
|
15
38
|
}
|
|
16
39
|
decodeOutpoint(reader) {
|
|
17
40
|
const txidBytes = reader.read(32);
|
|
18
|
-
const txid =
|
|
41
|
+
const txid = Utils.toHex(txidBytes);
|
|
19
42
|
const index = reader.readVarIntNum();
|
|
20
43
|
return `${txid}.${index}`;
|
|
21
44
|
}
|
|
22
45
|
encodeOutpoint(outpoint) {
|
|
23
|
-
const writer = new
|
|
46
|
+
const writer = new Utils.Writer();
|
|
24
47
|
const [txid, index] = outpoint.split('.');
|
|
25
|
-
writer.write(
|
|
48
|
+
writer.write(Utils.toArray(txid, 'hex'));
|
|
26
49
|
writer.writeVarIntNum(Number(index));
|
|
27
50
|
return writer.toArray();
|
|
28
51
|
}
|
|
29
52
|
async transmitToWallet(message) {
|
|
30
|
-
const messageReader = new
|
|
53
|
+
const messageReader = new Utils.Reader(message);
|
|
31
54
|
try {
|
|
32
55
|
// Read call code
|
|
33
56
|
const callCode = messageReader.readUInt8();
|
|
@@ -40,7 +63,7 @@ class WalletWireProcessor {
|
|
|
40
63
|
// Read originator length
|
|
41
64
|
const originatorLength = messageReader.readUInt8();
|
|
42
65
|
const originatorBytes = messageReader.read(originatorLength);
|
|
43
|
-
const originator =
|
|
66
|
+
const originator = Utils.toUTF8(originatorBytes);
|
|
44
67
|
// Read parameters
|
|
45
68
|
const paramsReader = messageReader; // Remaining bytes
|
|
46
69
|
switch (callName) {
|
|
@@ -50,7 +73,7 @@ class WalletWireProcessor {
|
|
|
50
73
|
// Read description
|
|
51
74
|
const descriptionLength = paramsReader.readVarIntNum();
|
|
52
75
|
const descriptionBytes = paramsReader.read(descriptionLength);
|
|
53
|
-
args.description =
|
|
76
|
+
args.description = Utils.toUTF8(descriptionBytes);
|
|
54
77
|
// tx
|
|
55
78
|
const inputBeefLength = paramsReader.readVarIntNum();
|
|
56
79
|
if (inputBeefLength >= 0) {
|
|
@@ -71,7 +94,7 @@ class WalletWireProcessor {
|
|
|
71
94
|
const unlockingScriptLength = paramsReader.readVarIntNum();
|
|
72
95
|
if (unlockingScriptLength >= 0) {
|
|
73
96
|
const unlockingScriptBytes = paramsReader.read(unlockingScriptLength);
|
|
74
|
-
input.unlockingScript =
|
|
97
|
+
input.unlockingScript = Utils.toHex(unlockingScriptBytes);
|
|
75
98
|
}
|
|
76
99
|
else {
|
|
77
100
|
input.unlockingScript = undefined;
|
|
@@ -81,7 +104,7 @@ class WalletWireProcessor {
|
|
|
81
104
|
// inputDescription
|
|
82
105
|
const inputDescriptionLength = paramsReader.readVarIntNum();
|
|
83
106
|
const inputDescriptionBytes = paramsReader.read(inputDescriptionLength);
|
|
84
|
-
input.inputDescription =
|
|
107
|
+
input.inputDescription = Utils.toUTF8(inputDescriptionBytes);
|
|
85
108
|
// sequenceNumber
|
|
86
109
|
const sequenceNumber = paramsReader.readVarIntNum();
|
|
87
110
|
if (sequenceNumber >= 0) {
|
|
@@ -105,18 +128,18 @@ class WalletWireProcessor {
|
|
|
105
128
|
// lockingScript
|
|
106
129
|
const lockingScriptLength = paramsReader.readVarIntNum();
|
|
107
130
|
const lockingScriptBytes = paramsReader.read(lockingScriptLength);
|
|
108
|
-
output.lockingScript =
|
|
131
|
+
output.lockingScript = Utils.toHex(lockingScriptBytes);
|
|
109
132
|
// satoshis
|
|
110
133
|
output.satoshis = paramsReader.readVarIntNum();
|
|
111
134
|
// outputDescription
|
|
112
135
|
const outputDescriptionLength = paramsReader.readVarIntNum();
|
|
113
136
|
const outputDescriptionBytes = paramsReader.read(outputDescriptionLength);
|
|
114
|
-
output.outputDescription =
|
|
137
|
+
output.outputDescription = Utils.toUTF8(outputDescriptionBytes);
|
|
115
138
|
// basket
|
|
116
139
|
const basketLength = paramsReader.readVarIntNum();
|
|
117
140
|
if (basketLength >= 0) {
|
|
118
141
|
const basketBytes = paramsReader.read(basketLength);
|
|
119
|
-
output.basket =
|
|
142
|
+
output.basket = Utils.toUTF8(basketBytes);
|
|
120
143
|
}
|
|
121
144
|
else {
|
|
122
145
|
output.basket = undefined;
|
|
@@ -125,7 +148,7 @@ class WalletWireProcessor {
|
|
|
125
148
|
const customInstructionsLength = paramsReader.readVarIntNum();
|
|
126
149
|
if (customInstructionsLength >= 0) {
|
|
127
150
|
const customInstructionsBytes = paramsReader.read(customInstructionsLength);
|
|
128
|
-
output.customInstructions =
|
|
151
|
+
output.customInstructions = Utils.toUTF8(customInstructionsBytes);
|
|
129
152
|
}
|
|
130
153
|
else {
|
|
131
154
|
output.customInstructions = undefined;
|
|
@@ -137,7 +160,7 @@ class WalletWireProcessor {
|
|
|
137
160
|
for (let j = 0; j < tagsLength; j++) {
|
|
138
161
|
const tagLength = paramsReader.readVarIntNum();
|
|
139
162
|
const tagBytes = paramsReader.read(tagLength);
|
|
140
|
-
const tag =
|
|
163
|
+
const tag = Utils.toUTF8(tagBytes);
|
|
141
164
|
output.tags.push(tag);
|
|
142
165
|
}
|
|
143
166
|
}
|
|
@@ -173,7 +196,7 @@ class WalletWireProcessor {
|
|
|
173
196
|
for (let i = 0; i < labelsLength; i++) {
|
|
174
197
|
const labelLength = paramsReader.readVarIntNum();
|
|
175
198
|
const labelBytes = paramsReader.read(labelLength);
|
|
176
|
-
const label =
|
|
199
|
+
const label = Utils.toUTF8(labelBytes);
|
|
177
200
|
args.labels.push(label);
|
|
178
201
|
}
|
|
179
202
|
}
|
|
@@ -215,7 +238,7 @@ class WalletWireProcessor {
|
|
|
215
238
|
args.options.knownTxids = [];
|
|
216
239
|
for (let i = 0; i < knownTxidsLength; i++) {
|
|
217
240
|
const txidBytes = paramsReader.read(32);
|
|
218
|
-
const txid =
|
|
241
|
+
const txid = Utils.toHex(txidBytes);
|
|
219
242
|
args.options.knownTxids.push(txid);
|
|
220
243
|
}
|
|
221
244
|
}
|
|
@@ -256,7 +279,7 @@ class WalletWireProcessor {
|
|
|
256
279
|
args.options.sendWith = [];
|
|
257
280
|
for (let i = 0; i < sendWithLength; i++) {
|
|
258
281
|
const txidBytes = paramsReader.read(32);
|
|
259
|
-
const txid =
|
|
282
|
+
const txid = Utils.toHex(txidBytes);
|
|
260
283
|
args.options.sendWith.push(txid);
|
|
261
284
|
}
|
|
262
285
|
}
|
|
@@ -278,11 +301,11 @@ class WalletWireProcessor {
|
|
|
278
301
|
// Call the method
|
|
279
302
|
const createActionResult = await this.wallet.createAction(args, originator);
|
|
280
303
|
// Serialize the result
|
|
281
|
-
const resultWriter = new
|
|
304
|
+
const resultWriter = new Utils.Writer();
|
|
282
305
|
// txid
|
|
283
306
|
if (createActionResult.txid != null && createActionResult.txid !== '') {
|
|
284
307
|
resultWriter.writeInt8(1);
|
|
285
|
-
resultWriter.write(
|
|
308
|
+
resultWriter.write(Utils.toArray(createActionResult.txid, 'hex'));
|
|
286
309
|
}
|
|
287
310
|
else {
|
|
288
311
|
resultWriter.writeInt8(0);
|
|
@@ -310,7 +333,7 @@ class WalletWireProcessor {
|
|
|
310
333
|
if (createActionResult.sendWithResults != null) {
|
|
311
334
|
resultWriter.writeVarIntNum(createActionResult.sendWithResults.length);
|
|
312
335
|
for (const result of createActionResult.sendWithResults) {
|
|
313
|
-
resultWriter.write(
|
|
336
|
+
resultWriter.write(Utils.toArray(result.txid, 'hex'));
|
|
314
337
|
let statusCode;
|
|
315
338
|
if (result.status === 'unproven')
|
|
316
339
|
statusCode = 1;
|
|
@@ -329,7 +352,7 @@ class WalletWireProcessor {
|
|
|
329
352
|
resultWriter.writeInt8(1);
|
|
330
353
|
resultWriter.writeVarIntNum(createActionResult.signableTransaction.tx.length);
|
|
331
354
|
resultWriter.write(createActionResult.signableTransaction.tx);
|
|
332
|
-
const referenceBytes =
|
|
355
|
+
const referenceBytes = Utils.toArray(createActionResult.signableTransaction.reference, 'base64');
|
|
333
356
|
resultWriter.writeVarIntNum(referenceBytes.length);
|
|
334
357
|
resultWriter.write(referenceBytes);
|
|
335
358
|
}
|
|
@@ -337,7 +360,7 @@ class WalletWireProcessor {
|
|
|
337
360
|
resultWriter.writeInt8(0);
|
|
338
361
|
}
|
|
339
362
|
// Return success code and result
|
|
340
|
-
const responseWriter = new
|
|
363
|
+
const responseWriter = new Utils.Writer();
|
|
341
364
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
342
365
|
responseWriter.write(resultWriter.toArray());
|
|
343
366
|
return responseWriter.toArray();
|
|
@@ -353,7 +376,7 @@ class WalletWireProcessor {
|
|
|
353
376
|
// unlockingScript
|
|
354
377
|
const unlockingScriptLength = paramsReader.readVarIntNum();
|
|
355
378
|
const unlockingScriptBytes = paramsReader.read(unlockingScriptLength);
|
|
356
|
-
spend.unlockingScript =
|
|
379
|
+
spend.unlockingScript = Utils.toHex(unlockingScriptBytes);
|
|
357
380
|
// sequenceNumber
|
|
358
381
|
const sequenceNumber = paramsReader.readVarIntNum();
|
|
359
382
|
if (sequenceNumber >= 0) {
|
|
@@ -367,7 +390,7 @@ class WalletWireProcessor {
|
|
|
367
390
|
// Deserialize reference
|
|
368
391
|
const referenceLength = paramsReader.readVarIntNum();
|
|
369
392
|
const referenceBytes = paramsReader.read(referenceLength);
|
|
370
|
-
args.reference =
|
|
393
|
+
args.reference = Utils.toBase64(referenceBytes);
|
|
371
394
|
// Deserialize options
|
|
372
395
|
const optionsPresent = paramsReader.readInt8();
|
|
373
396
|
if (optionsPresent === 1) {
|
|
@@ -403,7 +426,7 @@ class WalletWireProcessor {
|
|
|
403
426
|
args.options.sendWith = [];
|
|
404
427
|
for (let i = 0; i < sendWithLength; i++) {
|
|
405
428
|
const txidBytes = paramsReader.read(32);
|
|
406
|
-
const txid =
|
|
429
|
+
const txid = Utils.toHex(txidBytes);
|
|
407
430
|
args.options.sendWith.push(txid);
|
|
408
431
|
}
|
|
409
432
|
}
|
|
@@ -417,11 +440,11 @@ class WalletWireProcessor {
|
|
|
417
440
|
// Call the method
|
|
418
441
|
const signActionResult = await this.wallet.signAction(args, originator);
|
|
419
442
|
// Serialize the result
|
|
420
|
-
const resultWriter = new
|
|
443
|
+
const resultWriter = new Utils.Writer();
|
|
421
444
|
// txid
|
|
422
445
|
if (signActionResult.txid != null && signActionResult.txid !== '') {
|
|
423
446
|
resultWriter.writeInt8(1);
|
|
424
|
-
resultWriter.write(
|
|
447
|
+
resultWriter.write(Utils.toArray(signActionResult.txid, 'hex'));
|
|
425
448
|
}
|
|
426
449
|
else {
|
|
427
450
|
resultWriter.writeInt8(0);
|
|
@@ -439,7 +462,7 @@ class WalletWireProcessor {
|
|
|
439
462
|
if (signActionResult.sendWithResults != null) {
|
|
440
463
|
resultWriter.writeVarIntNum(signActionResult.sendWithResults.length);
|
|
441
464
|
for (const result of signActionResult.sendWithResults) {
|
|
442
|
-
resultWriter.write(
|
|
465
|
+
resultWriter.write(Utils.toArray(result.txid, 'hex'));
|
|
443
466
|
let statusCode;
|
|
444
467
|
if (result.status === 'unproven')
|
|
445
468
|
statusCode = 1;
|
|
@@ -454,7 +477,7 @@ class WalletWireProcessor {
|
|
|
454
477
|
resultWriter.writeVarIntNum(-1);
|
|
455
478
|
}
|
|
456
479
|
// Return success code and result
|
|
457
|
-
const responseWriter = new
|
|
480
|
+
const responseWriter = new Utils.Writer();
|
|
458
481
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
459
482
|
responseWriter.write(resultWriter.toArray());
|
|
460
483
|
return responseWriter.toArray();
|
|
@@ -462,11 +485,11 @@ class WalletWireProcessor {
|
|
|
462
485
|
case 'abortAction': {
|
|
463
486
|
// Deserialize reference
|
|
464
487
|
const referenceBytes = paramsReader.read();
|
|
465
|
-
const reference =
|
|
488
|
+
const reference = Utils.toBase64(referenceBytes);
|
|
466
489
|
// Call the method
|
|
467
490
|
await this.wallet.abortAction({ reference }, originator);
|
|
468
491
|
// Return success code and result
|
|
469
|
-
const responseWriter = new
|
|
492
|
+
const responseWriter = new Utils.Writer();
|
|
470
493
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
471
494
|
return responseWriter.toArray();
|
|
472
495
|
}
|
|
@@ -478,7 +501,7 @@ class WalletWireProcessor {
|
|
|
478
501
|
for (let i = 0; i < labelsLength; i++) {
|
|
479
502
|
const labelLength = paramsReader.readVarIntNum();
|
|
480
503
|
const labelBytes = paramsReader.read(labelLength);
|
|
481
|
-
args.labels.push(
|
|
504
|
+
args.labels.push(Utils.toUTF8(labelBytes));
|
|
482
505
|
}
|
|
483
506
|
// Deserialize labelQueryMode
|
|
484
507
|
const labelQueryModeFlag = paramsReader.readInt8();
|
|
@@ -536,13 +559,13 @@ class WalletWireProcessor {
|
|
|
536
559
|
// Call the method
|
|
537
560
|
const listActionsResult = await this.wallet.listActions(args, originator);
|
|
538
561
|
// Serialize the result
|
|
539
|
-
const resultWriter = new
|
|
562
|
+
const resultWriter = new Utils.Writer();
|
|
540
563
|
// totalActions
|
|
541
564
|
resultWriter.writeVarIntNum(listActionsResult.totalActions);
|
|
542
565
|
// actions
|
|
543
566
|
for (const action of listActionsResult.actions) {
|
|
544
567
|
// txid
|
|
545
|
-
resultWriter.write(
|
|
568
|
+
resultWriter.write(Utils.toArray(action.txid, 'hex'));
|
|
546
569
|
// satoshis
|
|
547
570
|
resultWriter.writeVarIntNum(action.satoshis);
|
|
548
571
|
// status
|
|
@@ -577,14 +600,14 @@ class WalletWireProcessor {
|
|
|
577
600
|
// isOutgoing
|
|
578
601
|
resultWriter.writeInt8(action.isOutgoing ? 1 : 0);
|
|
579
602
|
// description
|
|
580
|
-
const descriptionBytes =
|
|
603
|
+
const descriptionBytes = Utils.toArray(action.description, 'utf8');
|
|
581
604
|
resultWriter.writeVarIntNum(descriptionBytes.length);
|
|
582
605
|
resultWriter.write(descriptionBytes);
|
|
583
606
|
// labels
|
|
584
607
|
if (action.labels !== undefined) {
|
|
585
608
|
resultWriter.writeVarIntNum(action.labels.length);
|
|
586
609
|
for (const label of action.labels) {
|
|
587
|
-
const labelBytes =
|
|
610
|
+
const labelBytes = Utils.toArray(label, 'utf8');
|
|
588
611
|
resultWriter.writeVarIntNum(labelBytes.length);
|
|
589
612
|
resultWriter.write(labelBytes);
|
|
590
613
|
}
|
|
@@ -606,7 +629,7 @@ class WalletWireProcessor {
|
|
|
606
629
|
resultWriter.writeVarIntNum(input.sourceSatoshis);
|
|
607
630
|
// sourceLockingScript
|
|
608
631
|
if (input.sourceLockingScript !== undefined) {
|
|
609
|
-
const sourceLockingScriptBytes =
|
|
632
|
+
const sourceLockingScriptBytes = Utils.toArray(input.sourceLockingScript, 'hex');
|
|
610
633
|
resultWriter.writeVarIntNum(sourceLockingScriptBytes.length);
|
|
611
634
|
resultWriter.write(sourceLockingScriptBytes);
|
|
612
635
|
}
|
|
@@ -615,7 +638,7 @@ class WalletWireProcessor {
|
|
|
615
638
|
}
|
|
616
639
|
// unlockingScript
|
|
617
640
|
if (input.unlockingScript !== undefined) {
|
|
618
|
-
const unlockingScriptBytes =
|
|
641
|
+
const unlockingScriptBytes = Utils.toArray(input.unlockingScript, 'hex');
|
|
619
642
|
resultWriter.writeVarIntNum(unlockingScriptBytes.length);
|
|
620
643
|
resultWriter.write(unlockingScriptBytes);
|
|
621
644
|
}
|
|
@@ -623,7 +646,7 @@ class WalletWireProcessor {
|
|
|
623
646
|
resultWriter.writeVarIntNum(-1);
|
|
624
647
|
}
|
|
625
648
|
// inputDescription
|
|
626
|
-
const inputDescriptionBytes =
|
|
649
|
+
const inputDescriptionBytes = Utils.toArray(input.inputDescription, 'utf8');
|
|
627
650
|
resultWriter.writeVarIntNum(inputDescriptionBytes.length);
|
|
628
651
|
resultWriter.write(inputDescriptionBytes);
|
|
629
652
|
// sequenceNumber
|
|
@@ -643,7 +666,7 @@ class WalletWireProcessor {
|
|
|
643
666
|
resultWriter.writeVarIntNum(output.satoshis);
|
|
644
667
|
// lockingScript
|
|
645
668
|
if (output.lockingScript !== undefined) {
|
|
646
|
-
const lockingScriptBytes =
|
|
669
|
+
const lockingScriptBytes = Utils.toArray(output.lockingScript, 'hex');
|
|
647
670
|
resultWriter.writeVarIntNum(lockingScriptBytes.length);
|
|
648
671
|
resultWriter.write(lockingScriptBytes);
|
|
649
672
|
}
|
|
@@ -653,12 +676,12 @@ class WalletWireProcessor {
|
|
|
653
676
|
// spendable
|
|
654
677
|
resultWriter.writeInt8(output.spendable ? 1 : 0);
|
|
655
678
|
// outputDescription
|
|
656
|
-
const outputDescriptionBytes =
|
|
679
|
+
const outputDescriptionBytes = Utils.toArray(output.outputDescription, 'utf8');
|
|
657
680
|
resultWriter.writeVarIntNum(outputDescriptionBytes.length);
|
|
658
681
|
resultWriter.write(outputDescriptionBytes);
|
|
659
682
|
// basket
|
|
660
683
|
if (output.basket !== undefined) {
|
|
661
|
-
const basketBytes =
|
|
684
|
+
const basketBytes = Utils.toArray(output.basket, 'utf8');
|
|
662
685
|
resultWriter.writeVarIntNum(basketBytes.length);
|
|
663
686
|
resultWriter.write(basketBytes);
|
|
664
687
|
}
|
|
@@ -669,7 +692,7 @@ class WalletWireProcessor {
|
|
|
669
692
|
if (output.tags !== undefined) {
|
|
670
693
|
resultWriter.writeVarIntNum(output.tags.length);
|
|
671
694
|
for (const tag of output.tags) {
|
|
672
|
-
const tagBytes =
|
|
695
|
+
const tagBytes = Utils.toArray(tag, 'utf8');
|
|
673
696
|
resultWriter.writeVarIntNum(tagBytes.length);
|
|
674
697
|
resultWriter.write(tagBytes);
|
|
675
698
|
}
|
|
@@ -679,7 +702,7 @@ class WalletWireProcessor {
|
|
|
679
702
|
}
|
|
680
703
|
// customInstructions
|
|
681
704
|
if (output.customInstructions !== undefined) {
|
|
682
|
-
const customInstructionsBytes =
|
|
705
|
+
const customInstructionsBytes = Utils.toArray(output.customInstructions, 'utf8');
|
|
683
706
|
resultWriter.writeVarIntNum(customInstructionsBytes.length);
|
|
684
707
|
resultWriter.write(customInstructionsBytes);
|
|
685
708
|
}
|
|
@@ -692,7 +715,7 @@ class WalletWireProcessor {
|
|
|
692
715
|
resultWriter.writeVarIntNum(-1);
|
|
693
716
|
}
|
|
694
717
|
}
|
|
695
|
-
const responseWriter = new
|
|
718
|
+
const responseWriter = new Utils.Writer();
|
|
696
719
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
697
720
|
responseWriter.write(resultWriter.toArray());
|
|
698
721
|
return responseWriter.toArray();
|
|
@@ -716,15 +739,15 @@ class WalletWireProcessor {
|
|
|
716
739
|
output.paymentRemittance = {};
|
|
717
740
|
// senderIdentityKey
|
|
718
741
|
const senderIdentityKeyBytes = paramsReader.read(33);
|
|
719
|
-
output.paymentRemittance.senderIdentityKey =
|
|
742
|
+
output.paymentRemittance.senderIdentityKey = Utils.toHex(senderIdentityKeyBytes);
|
|
720
743
|
// derivationPrefix
|
|
721
744
|
const derivationPrefixLength = paramsReader.readVarIntNum();
|
|
722
745
|
const derivationPrefixBytes = paramsReader.read(derivationPrefixLength);
|
|
723
|
-
output.paymentRemittance.derivationPrefix =
|
|
746
|
+
output.paymentRemittance.derivationPrefix = Utils.toBase64(derivationPrefixBytes);
|
|
724
747
|
// derivationSuffix
|
|
725
748
|
const derivationSuffixLength = paramsReader.readVarIntNum();
|
|
726
749
|
const derivationSuffixBytes = paramsReader.read(derivationSuffixLength);
|
|
727
|
-
output.paymentRemittance.derivationSuffix =
|
|
750
|
+
output.paymentRemittance.derivationSuffix = Utils.toBase64(derivationSuffixBytes);
|
|
728
751
|
}
|
|
729
752
|
else if (protocolFlag === 2) {
|
|
730
753
|
output.protocol = 'basket insertion';
|
|
@@ -732,12 +755,12 @@ class WalletWireProcessor {
|
|
|
732
755
|
// basket
|
|
733
756
|
const basketLength = paramsReader.readVarIntNum();
|
|
734
757
|
const basketBytes = paramsReader.read(basketLength);
|
|
735
|
-
output.insertionRemittance.basket =
|
|
758
|
+
output.insertionRemittance.basket = Utils.toUTF8(basketBytes);
|
|
736
759
|
// customInstructions
|
|
737
760
|
const customInstructionsLength = paramsReader.readVarIntNum();
|
|
738
761
|
if (customInstructionsLength >= 0) {
|
|
739
762
|
const customInstructionsBytes = paramsReader.read(customInstructionsLength);
|
|
740
|
-
output.insertionRemittance.customInstructions =
|
|
763
|
+
output.insertionRemittance.customInstructions = Utils.toUTF8(customInstructionsBytes);
|
|
741
764
|
}
|
|
742
765
|
// tags
|
|
743
766
|
const tagsLength = paramsReader.readVarIntNum();
|
|
@@ -746,7 +769,7 @@ class WalletWireProcessor {
|
|
|
746
769
|
for (let j = 0; j < tagsLength; j++) {
|
|
747
770
|
const tagLength = paramsReader.readVarIntNum();
|
|
748
771
|
const tagBytes = paramsReader.read(tagLength);
|
|
749
|
-
output.insertionRemittance.tags.push(
|
|
772
|
+
output.insertionRemittance.tags.push(Utils.toUTF8(tagBytes));
|
|
750
773
|
}
|
|
751
774
|
}
|
|
752
775
|
else {
|
|
@@ -760,11 +783,11 @@ class WalletWireProcessor {
|
|
|
760
783
|
args.labels = [];
|
|
761
784
|
for (let i = 0; i < numberOfLabels; i++) {
|
|
762
785
|
const labelLength = paramsReader.readVarIntNum();
|
|
763
|
-
args.labels.push(
|
|
786
|
+
args.labels.push(Utils.toUTF8(paramsReader.read(labelLength)));
|
|
764
787
|
}
|
|
765
788
|
}
|
|
766
789
|
const descriptionLength = paramsReader.readVarIntNum();
|
|
767
|
-
args.description =
|
|
790
|
+
args.description = Utils.toUTF8(paramsReader.read(descriptionLength));
|
|
768
791
|
// Deserialize seekPermission
|
|
769
792
|
const seekPermission = paramsReader.readInt8();
|
|
770
793
|
if (seekPermission >= 0) {
|
|
@@ -776,7 +799,7 @@ class WalletWireProcessor {
|
|
|
776
799
|
// Call the method
|
|
777
800
|
await this.wallet.internalizeAction(args, originator);
|
|
778
801
|
// Return success code and result
|
|
779
|
-
const responseWriter = new
|
|
802
|
+
const responseWriter = new Utils.Writer();
|
|
780
803
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
781
804
|
return responseWriter.toArray();
|
|
782
805
|
}
|
|
@@ -785,7 +808,7 @@ class WalletWireProcessor {
|
|
|
785
808
|
// Deserialize basket
|
|
786
809
|
const basketLength = paramsReader.readVarIntNum();
|
|
787
810
|
const basketBytes = paramsReader.read(basketLength);
|
|
788
|
-
args.basket =
|
|
811
|
+
args.basket = Utils.toUTF8(basketBytes);
|
|
789
812
|
// Deserialize tags
|
|
790
813
|
const tagsLength = paramsReader.readVarIntNum();
|
|
791
814
|
if (tagsLength > 0) {
|
|
@@ -793,7 +816,7 @@ class WalletWireProcessor {
|
|
|
793
816
|
for (let i = 0; i < tagsLength; i++) {
|
|
794
817
|
const tagLength = paramsReader.readVarIntNum();
|
|
795
818
|
const tagBytes = paramsReader.read(tagLength);
|
|
796
|
-
args.tags.push(
|
|
819
|
+
args.tags.push(Utils.toUTF8(tagBytes));
|
|
797
820
|
}
|
|
798
821
|
}
|
|
799
822
|
else {
|
|
@@ -873,7 +896,7 @@ class WalletWireProcessor {
|
|
|
873
896
|
// Call the method
|
|
874
897
|
const listOutputsResult = await this.wallet.listOutputs(args, originator);
|
|
875
898
|
// Serialize the result
|
|
876
|
-
const resultWriter = new
|
|
899
|
+
const resultWriter = new Utils.Writer();
|
|
877
900
|
// totalOutputs
|
|
878
901
|
resultWriter.writeVarIntNum(listOutputsResult.totalOutputs);
|
|
879
902
|
// BEEF length and BEEF or -1
|
|
@@ -892,7 +915,7 @@ class WalletWireProcessor {
|
|
|
892
915
|
resultWriter.writeVarIntNum(output.satoshis);
|
|
893
916
|
// lockingScript
|
|
894
917
|
if (output.lockingScript !== undefined) {
|
|
895
|
-
const lockingScriptBytes =
|
|
918
|
+
const lockingScriptBytes = Utils.toArray(output.lockingScript, 'hex');
|
|
896
919
|
resultWriter.writeVarIntNum(lockingScriptBytes.length);
|
|
897
920
|
resultWriter.write(lockingScriptBytes);
|
|
898
921
|
}
|
|
@@ -901,7 +924,7 @@ class WalletWireProcessor {
|
|
|
901
924
|
}
|
|
902
925
|
// customInstructions
|
|
903
926
|
if (output.customInstructions !== undefined) {
|
|
904
|
-
const customInstructionsBytes =
|
|
927
|
+
const customInstructionsBytes = Utils.toArray(output.customInstructions, 'utf8');
|
|
905
928
|
resultWriter.writeVarIntNum(customInstructionsBytes.length);
|
|
906
929
|
resultWriter.write(customInstructionsBytes);
|
|
907
930
|
}
|
|
@@ -912,7 +935,7 @@ class WalletWireProcessor {
|
|
|
912
935
|
if (output.tags !== undefined) {
|
|
913
936
|
resultWriter.writeVarIntNum(output.tags.length);
|
|
914
937
|
for (const tag of output.tags) {
|
|
915
|
-
const tagBytes =
|
|
938
|
+
const tagBytes = Utils.toArray(tag, 'utf8');
|
|
916
939
|
resultWriter.writeVarIntNum(tagBytes.length);
|
|
917
940
|
resultWriter.write(tagBytes);
|
|
918
941
|
}
|
|
@@ -924,7 +947,7 @@ class WalletWireProcessor {
|
|
|
924
947
|
if (output.labels !== undefined) {
|
|
925
948
|
resultWriter.writeVarIntNum(output.labels.length);
|
|
926
949
|
for (const label of output.labels) {
|
|
927
|
-
const labelBytes =
|
|
950
|
+
const labelBytes = Utils.toArray(label, 'utf8');
|
|
928
951
|
resultWriter.writeVarIntNum(labelBytes.length);
|
|
929
952
|
resultWriter.write(labelBytes);
|
|
930
953
|
}
|
|
@@ -934,7 +957,7 @@ class WalletWireProcessor {
|
|
|
934
957
|
}
|
|
935
958
|
}
|
|
936
959
|
// Return success code and result
|
|
937
|
-
const responseWriter = new
|
|
960
|
+
const responseWriter = new Utils.Writer();
|
|
938
961
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
939
962
|
responseWriter.write(resultWriter.toArray());
|
|
940
963
|
return responseWriter.toArray();
|
|
@@ -944,13 +967,13 @@ class WalletWireProcessor {
|
|
|
944
967
|
// Deserialize basket
|
|
945
968
|
const basketLength = paramsReader.readVarIntNum();
|
|
946
969
|
const basketBytes = paramsReader.read(basketLength);
|
|
947
|
-
args.basket =
|
|
970
|
+
args.basket = Utils.toUTF8(basketBytes);
|
|
948
971
|
// Deserialize outpoint
|
|
949
972
|
args.output = this.decodeOutpoint(paramsReader);
|
|
950
973
|
// Call the method
|
|
951
974
|
await this.wallet.relinquishOutput(args, originator);
|
|
952
975
|
// Return success code and result
|
|
953
|
-
const responseWriter = new
|
|
976
|
+
const responseWriter = new Utils.Writer();
|
|
954
977
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
955
978
|
return responseWriter.toArray();
|
|
956
979
|
}
|
|
@@ -977,7 +1000,7 @@ class WalletWireProcessor {
|
|
|
977
1000
|
const privilegedReasonLength = paramsReader.readInt8();
|
|
978
1001
|
if (privilegedReasonLength !== -1) {
|
|
979
1002
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
980
|
-
args.privilegedReason =
|
|
1003
|
+
args.privilegedReason = Utils.toUTF8(privilegedReasonBytes);
|
|
981
1004
|
}
|
|
982
1005
|
else {
|
|
983
1006
|
args.privilegedReason = undefined;
|
|
@@ -1003,7 +1026,7 @@ class WalletWireProcessor {
|
|
|
1003
1026
|
const privilegedReasonLength = paramsReader.readInt8();
|
|
1004
1027
|
if (privilegedReasonLength !== -1) {
|
|
1005
1028
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1006
|
-
args.privilegedReason =
|
|
1029
|
+
args.privilegedReason = Utils.toUTF8(privilegedReasonBytes);
|
|
1007
1030
|
}
|
|
1008
1031
|
else {
|
|
1009
1032
|
args.privilegedReason = undefined;
|
|
@@ -1020,9 +1043,9 @@ class WalletWireProcessor {
|
|
|
1020
1043
|
// Call the method
|
|
1021
1044
|
const getPublicKeyResult = await this.wallet.getPublicKey(args, originator);
|
|
1022
1045
|
// Serialize the result
|
|
1023
|
-
const responseWriter = new
|
|
1046
|
+
const responseWriter = new Utils.Writer();
|
|
1024
1047
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1025
|
-
const publicKeyBytes =
|
|
1048
|
+
const publicKeyBytes = Utils.toArray(getPublicKeyResult.publicKey, 'hex');
|
|
1026
1049
|
responseWriter.write(publicKeyBytes);
|
|
1027
1050
|
return responseWriter.toArray();
|
|
1028
1051
|
}
|
|
@@ -1042,7 +1065,7 @@ class WalletWireProcessor {
|
|
|
1042
1065
|
// Call the method
|
|
1043
1066
|
const encryptResult = await this.wallet.encrypt(args, originator);
|
|
1044
1067
|
// Serialize the result
|
|
1045
|
-
const responseWriter = new
|
|
1068
|
+
const responseWriter = new Utils.Writer();
|
|
1046
1069
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1047
1070
|
responseWriter.write(encryptResult.ciphertext);
|
|
1048
1071
|
return responseWriter.toArray();
|
|
@@ -1063,7 +1086,7 @@ class WalletWireProcessor {
|
|
|
1063
1086
|
// Call the method
|
|
1064
1087
|
const decryptResult = await this.wallet.decrypt(args, originator);
|
|
1065
1088
|
// Serialize the result
|
|
1066
|
-
const responseWriter = new
|
|
1089
|
+
const responseWriter = new Utils.Writer();
|
|
1067
1090
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1068
1091
|
responseWriter.write(decryptResult.plaintext);
|
|
1069
1092
|
return responseWriter.toArray();
|
|
@@ -1084,7 +1107,7 @@ class WalletWireProcessor {
|
|
|
1084
1107
|
// Call the method
|
|
1085
1108
|
const createHmacResult = await this.wallet.createHmac(args, originator);
|
|
1086
1109
|
// Serialize the result
|
|
1087
|
-
const responseWriter = new
|
|
1110
|
+
const responseWriter = new Utils.Writer();
|
|
1088
1111
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1089
1112
|
responseWriter.write(createHmacResult.hmac);
|
|
1090
1113
|
return responseWriter.toArray();
|
|
@@ -1107,7 +1130,7 @@ class WalletWireProcessor {
|
|
|
1107
1130
|
// Call the method
|
|
1108
1131
|
await this.wallet.verifyHmac(args, originator);
|
|
1109
1132
|
// Serialize the result (no data to return)
|
|
1110
|
-
const responseWriter = new
|
|
1133
|
+
const responseWriter = new Utils.Writer();
|
|
1111
1134
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1112
1135
|
return responseWriter.toArray();
|
|
1113
1136
|
}
|
|
@@ -1133,7 +1156,7 @@ class WalletWireProcessor {
|
|
|
1133
1156
|
// Call the method
|
|
1134
1157
|
const createSignatureResult = await this.wallet.createSignature(args, originator);
|
|
1135
1158
|
// Serialize the result
|
|
1136
|
-
const responseWriter = new
|
|
1159
|
+
const responseWriter = new Utils.Writer();
|
|
1137
1160
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1138
1161
|
responseWriter.write(createSignatureResult.signature);
|
|
1139
1162
|
return responseWriter.toArray();
|
|
@@ -1171,7 +1194,7 @@ class WalletWireProcessor {
|
|
|
1171
1194
|
// Call the method
|
|
1172
1195
|
await this.wallet.verifySignature(args, originator);
|
|
1173
1196
|
// Serialize the result (no data to return)
|
|
1174
|
-
const responseWriter = new
|
|
1197
|
+
const responseWriter = new Utils.Writer();
|
|
1175
1198
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1176
1199
|
return responseWriter.toArray();
|
|
1177
1200
|
}
|
|
@@ -1180,7 +1203,7 @@ class WalletWireProcessor {
|
|
|
1180
1203
|
// Call the method
|
|
1181
1204
|
const isAuthenticatedResult = await this.wallet.isAuthenticated({}, originator);
|
|
1182
1205
|
// Serialize the result
|
|
1183
|
-
const responseWriter = new
|
|
1206
|
+
const responseWriter = new Utils.Writer();
|
|
1184
1207
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1185
1208
|
responseWriter.writeUInt8(isAuthenticatedResult.authenticated ? 1 : 0);
|
|
1186
1209
|
return responseWriter.toArray();
|
|
@@ -1190,7 +1213,7 @@ class WalletWireProcessor {
|
|
|
1190
1213
|
// Call the method
|
|
1191
1214
|
await this.wallet.waitForAuthentication({}, originator);
|
|
1192
1215
|
// Serialize the result (authenticated is always true)
|
|
1193
|
-
const responseWriter = new
|
|
1216
|
+
const responseWriter = new Utils.Writer();
|
|
1194
1217
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1195
1218
|
return responseWriter.toArray();
|
|
1196
1219
|
}
|
|
@@ -1199,7 +1222,7 @@ class WalletWireProcessor {
|
|
|
1199
1222
|
// Call the method
|
|
1200
1223
|
const getHeightResult = await this.wallet.getHeight({}, originator);
|
|
1201
1224
|
// Serialize the result
|
|
1202
|
-
const responseWriter = new
|
|
1225
|
+
const responseWriter = new Utils.Writer();
|
|
1203
1226
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1204
1227
|
responseWriter.writeVarIntNum(getHeightResult.height);
|
|
1205
1228
|
return responseWriter.toArray();
|
|
@@ -1211,9 +1234,9 @@ class WalletWireProcessor {
|
|
|
1211
1234
|
// Call the method
|
|
1212
1235
|
const getHeaderResult = await this.wallet.getHeaderForHeight(args, originator);
|
|
1213
1236
|
// Serialize the result
|
|
1214
|
-
const responseWriter = new
|
|
1237
|
+
const responseWriter = new Utils.Writer();
|
|
1215
1238
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1216
|
-
const headerBytes =
|
|
1239
|
+
const headerBytes = Utils.toArray(getHeaderResult.header, 'hex');
|
|
1217
1240
|
responseWriter.write(headerBytes);
|
|
1218
1241
|
return responseWriter.toArray();
|
|
1219
1242
|
}
|
|
@@ -1222,7 +1245,7 @@ class WalletWireProcessor {
|
|
|
1222
1245
|
// Call the method
|
|
1223
1246
|
const getNetworkResult = await this.wallet.getNetwork({}, originator);
|
|
1224
1247
|
// Serialize the result
|
|
1225
|
-
const responseWriter = new
|
|
1248
|
+
const responseWriter = new Utils.Writer();
|
|
1226
1249
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1227
1250
|
responseWriter.writeUInt8(getNetworkResult.network === 'mainnet' ? 0 : 1);
|
|
1228
1251
|
return responseWriter.toArray();
|
|
@@ -1232,9 +1255,9 @@ class WalletWireProcessor {
|
|
|
1232
1255
|
// Call the method
|
|
1233
1256
|
const getVersionResult = await this.wallet.getVersion({}, originator);
|
|
1234
1257
|
// Serialize the result
|
|
1235
|
-
const responseWriter = new
|
|
1258
|
+
const responseWriter = new Utils.Writer();
|
|
1236
1259
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1237
|
-
const versionBytes =
|
|
1260
|
+
const versionBytes = Utils.toArray(getVersionResult.version, 'utf8');
|
|
1238
1261
|
responseWriter.write(versionBytes);
|
|
1239
1262
|
return responseWriter.toArray();
|
|
1240
1263
|
}
|
|
@@ -1254,26 +1277,26 @@ class WalletWireProcessor {
|
|
|
1254
1277
|
}
|
|
1255
1278
|
else {
|
|
1256
1279
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1257
|
-
args.privilegedReason =
|
|
1280
|
+
args.privilegedReason = Utils.toUTF8(privilegedReasonBytes);
|
|
1258
1281
|
}
|
|
1259
1282
|
// Read counterparty public key
|
|
1260
1283
|
const counterpartyBytes = paramsReader.read(33);
|
|
1261
|
-
args.counterparty =
|
|
1284
|
+
args.counterparty = Utils.toHex(counterpartyBytes);
|
|
1262
1285
|
// Read verifier public key
|
|
1263
1286
|
const verifierBytes = paramsReader.read(33);
|
|
1264
|
-
args.verifier =
|
|
1287
|
+
args.verifier = Utils.toHex(verifierBytes);
|
|
1265
1288
|
// Call the method
|
|
1266
1289
|
const revealResult = await this.wallet.revealCounterpartyKeyLinkage(args, originator);
|
|
1267
1290
|
// Serialize the result
|
|
1268
|
-
const resultWriter = new
|
|
1291
|
+
const resultWriter = new Utils.Writer();
|
|
1269
1292
|
// Write prover
|
|
1270
|
-
resultWriter.write(
|
|
1293
|
+
resultWriter.write(Utils.toArray(revealResult.prover, 'hex'));
|
|
1271
1294
|
// Write verifier
|
|
1272
|
-
resultWriter.write(
|
|
1295
|
+
resultWriter.write(Utils.toArray(revealResult.verifier, 'hex'));
|
|
1273
1296
|
// Write counterparty
|
|
1274
|
-
resultWriter.write(
|
|
1297
|
+
resultWriter.write(Utils.toArray(revealResult.counterparty, 'hex'));
|
|
1275
1298
|
// Write revelationTime
|
|
1276
|
-
const revelationTimeBytes =
|
|
1299
|
+
const revelationTimeBytes = Utils.toArray(revealResult.revelationTime, 'utf8');
|
|
1277
1300
|
resultWriter.writeVarIntNum(revelationTimeBytes.length);
|
|
1278
1301
|
resultWriter.write(revelationTimeBytes);
|
|
1279
1302
|
// Write encryptedLinkage
|
|
@@ -1283,7 +1306,7 @@ class WalletWireProcessor {
|
|
|
1283
1306
|
resultWriter.writeVarIntNum(revealResult.encryptedLinkageProof.length);
|
|
1284
1307
|
resultWriter.write(revealResult.encryptedLinkageProof);
|
|
1285
1308
|
// Return success code and result
|
|
1286
|
-
const responseWriter = new
|
|
1309
|
+
const responseWriter = new Utils.Writer();
|
|
1287
1310
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1288
1311
|
responseWriter.write(resultWriter.toArray());
|
|
1289
1312
|
return responseWriter.toArray();
|
|
@@ -1293,25 +1316,25 @@ class WalletWireProcessor {
|
|
|
1293
1316
|
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1294
1317
|
// Read verifier public key
|
|
1295
1318
|
const verifierBytes = paramsReader.read(33);
|
|
1296
|
-
args.verifier =
|
|
1319
|
+
args.verifier = Utils.toHex(verifierBytes);
|
|
1297
1320
|
// Call the method
|
|
1298
1321
|
const revealResult = await this.wallet.revealSpecificKeyLinkage(args, originator);
|
|
1299
1322
|
// Serialize the result
|
|
1300
|
-
const resultWriter = new
|
|
1323
|
+
const resultWriter = new Utils.Writer();
|
|
1301
1324
|
// Write prover
|
|
1302
|
-
resultWriter.write(
|
|
1325
|
+
resultWriter.write(Utils.toArray(revealResult.prover, 'hex'));
|
|
1303
1326
|
// Write verifier
|
|
1304
|
-
resultWriter.write(
|
|
1327
|
+
resultWriter.write(Utils.toArray(revealResult.verifier, 'hex'));
|
|
1305
1328
|
// Write counterparty
|
|
1306
|
-
resultWriter.write(
|
|
1329
|
+
resultWriter.write(Utils.toArray(revealResult.counterparty, 'hex'));
|
|
1307
1330
|
// Write securityLevel
|
|
1308
1331
|
resultWriter.writeUInt8(revealResult.protocolID[0]);
|
|
1309
1332
|
// Write protocol string
|
|
1310
|
-
const protocolBytesOut =
|
|
1333
|
+
const protocolBytesOut = Utils.toArray(revealResult.protocolID[1], 'utf8');
|
|
1311
1334
|
resultWriter.writeVarIntNum(protocolBytesOut.length);
|
|
1312
1335
|
resultWriter.write(protocolBytesOut);
|
|
1313
1336
|
// Write keyID
|
|
1314
|
-
const keyIDBytesOut =
|
|
1337
|
+
const keyIDBytesOut = Utils.toArray(revealResult.keyID, 'utf8');
|
|
1315
1338
|
resultWriter.writeVarIntNum(keyIDBytesOut.length);
|
|
1316
1339
|
resultWriter.write(keyIDBytesOut);
|
|
1317
1340
|
// Write encryptedLinkage
|
|
@@ -1323,7 +1346,7 @@ class WalletWireProcessor {
|
|
|
1323
1346
|
// Write proofType
|
|
1324
1347
|
resultWriter.writeUInt8(revealResult.proofType);
|
|
1325
1348
|
// Return success code and result
|
|
1326
|
-
const responseWriter = new
|
|
1349
|
+
const responseWriter = new Utils.Writer();
|
|
1327
1350
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1328
1351
|
responseWriter.write(resultWriter.toArray());
|
|
1329
1352
|
return responseWriter.toArray();
|
|
@@ -1332,20 +1355,20 @@ class WalletWireProcessor {
|
|
|
1332
1355
|
const args = {};
|
|
1333
1356
|
// Read args.type
|
|
1334
1357
|
const typeBytes = paramsReader.read(32);
|
|
1335
|
-
args.type =
|
|
1358
|
+
args.type = Utils.toBase64(typeBytes);
|
|
1336
1359
|
// args.certifier
|
|
1337
1360
|
const certifierBytes = paramsReader.read(33);
|
|
1338
|
-
args.certifier =
|
|
1361
|
+
args.certifier = Utils.toHex(certifierBytes);
|
|
1339
1362
|
// Read fields
|
|
1340
1363
|
const fieldsLength = paramsReader.readVarIntNum();
|
|
1341
1364
|
args.fields = {};
|
|
1342
1365
|
for (let i = 0; i < fieldsLength; i++) {
|
|
1343
1366
|
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1344
1367
|
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1345
|
-
const fieldName =
|
|
1368
|
+
const fieldName = Utils.toUTF8(fieldNameBytes);
|
|
1346
1369
|
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1347
1370
|
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1348
|
-
const fieldValue =
|
|
1371
|
+
const fieldValue = Utils.toUTF8(fieldValueBytes);
|
|
1349
1372
|
args.fields[fieldName] = fieldValue;
|
|
1350
1373
|
}
|
|
1351
1374
|
// Read privileged parameters
|
|
@@ -1362,7 +1385,7 @@ class WalletWireProcessor {
|
|
|
1362
1385
|
}
|
|
1363
1386
|
else {
|
|
1364
1387
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1365
|
-
args.privilegedReason =
|
|
1388
|
+
args.privilegedReason = Utils.toUTF8(privilegedReasonBytes);
|
|
1366
1389
|
}
|
|
1367
1390
|
// Read acquisitionProtocol
|
|
1368
1391
|
const acquisitionProtocolFlag = paramsReader.readUInt8();
|
|
@@ -1371,13 +1394,13 @@ class WalletWireProcessor {
|
|
|
1371
1394
|
if (args.acquisitionProtocol === 'direct') {
|
|
1372
1395
|
// args.serialNumber
|
|
1373
1396
|
const serialNumberBytes = paramsReader.read(32);
|
|
1374
|
-
args.serialNumber =
|
|
1397
|
+
args.serialNumber = Utils.toBase64(serialNumberBytes);
|
|
1375
1398
|
// args.revocationOutpoint
|
|
1376
1399
|
args.revocationOutpoint = this.decodeOutpoint(paramsReader);
|
|
1377
1400
|
// args.signature
|
|
1378
1401
|
const signatureLength = paramsReader.readVarIntNum();
|
|
1379
1402
|
const signatureBytes = paramsReader.read(signatureLength);
|
|
1380
|
-
args.signature =
|
|
1403
|
+
args.signature = Utils.toHex(signatureBytes);
|
|
1381
1404
|
// args.keyringRevealer
|
|
1382
1405
|
const keyringRevealerIdentifier = paramsReader.readUInt8();
|
|
1383
1406
|
if (keyringRevealerIdentifier === 11) {
|
|
@@ -1385,7 +1408,7 @@ class WalletWireProcessor {
|
|
|
1385
1408
|
}
|
|
1386
1409
|
else {
|
|
1387
1410
|
const keyringRevealerBytes = [keyringRevealerIdentifier].concat(paramsReader.read(32));
|
|
1388
|
-
args.keyringRevealer =
|
|
1411
|
+
args.keyringRevealer = Utils.toHex(keyringRevealerBytes);
|
|
1389
1412
|
}
|
|
1390
1413
|
// args.keyringForSubject
|
|
1391
1414
|
const keyringEntriesLength = paramsReader.readVarIntNum();
|
|
@@ -1393,10 +1416,10 @@ class WalletWireProcessor {
|
|
|
1393
1416
|
for (let i = 0; i < keyringEntriesLength; i++) {
|
|
1394
1417
|
const fieldKeyLength = paramsReader.readVarIntNum();
|
|
1395
1418
|
const fieldKeyBytes = paramsReader.read(fieldKeyLength);
|
|
1396
|
-
const fieldKey =
|
|
1419
|
+
const fieldKey = Utils.toUTF8(fieldKeyBytes);
|
|
1397
1420
|
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1398
1421
|
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1399
|
-
const fieldValue =
|
|
1422
|
+
const fieldValue = Utils.toBase64(fieldValueBytes);
|
|
1400
1423
|
args.keyringForSubject[fieldKey] = fieldValue;
|
|
1401
1424
|
}
|
|
1402
1425
|
}
|
|
@@ -1404,7 +1427,7 @@ class WalletWireProcessor {
|
|
|
1404
1427
|
// args.certifierUrl
|
|
1405
1428
|
const certifierUrlLength = paramsReader.readVarIntNum();
|
|
1406
1429
|
const certifierUrlBytes = paramsReader.read(certifierUrlLength);
|
|
1407
|
-
args.certifierUrl =
|
|
1430
|
+
args.certifierUrl = Utils.toUTF8(certifierUrlBytes);
|
|
1408
1431
|
}
|
|
1409
1432
|
// Call the method
|
|
1410
1433
|
const acquireResult = await this.wallet.acquireCertificate(args, originator);
|
|
@@ -1412,7 +1435,7 @@ class WalletWireProcessor {
|
|
|
1412
1435
|
const cert = new Certificate_js_1.default(acquireResult.type, acquireResult.serialNumber, acquireResult.subject, acquireResult.certifier, acquireResult.revocationOutpoint, acquireResult.fields, acquireResult.signature);
|
|
1413
1436
|
const certBin = cert.toBinary();
|
|
1414
1437
|
// Return success code and certificate binary
|
|
1415
|
-
const responseWriter = new
|
|
1438
|
+
const responseWriter = new Utils.Writer();
|
|
1416
1439
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1417
1440
|
responseWriter.write(certBin);
|
|
1418
1441
|
return responseWriter.toArray();
|
|
@@ -1424,14 +1447,14 @@ class WalletWireProcessor {
|
|
|
1424
1447
|
args.certifiers = [];
|
|
1425
1448
|
for (let i = 0; i < certifiersLength; i++) {
|
|
1426
1449
|
const certifierBytes = paramsReader.read(33);
|
|
1427
|
-
args.certifiers.push(
|
|
1450
|
+
args.certifiers.push(Utils.toHex(certifierBytes));
|
|
1428
1451
|
}
|
|
1429
1452
|
// Read types
|
|
1430
1453
|
const typesLength = paramsReader.readVarIntNum();
|
|
1431
1454
|
args.types = [];
|
|
1432
1455
|
for (let i = 0; i < typesLength; i++) {
|
|
1433
1456
|
const typeBytes = paramsReader.read(32);
|
|
1434
|
-
args.types.push(
|
|
1457
|
+
args.types.push(Utils.toBase64(typeBytes));
|
|
1435
1458
|
}
|
|
1436
1459
|
// Read limit and offset
|
|
1437
1460
|
const limit = paramsReader.readVarIntNum();
|
|
@@ -1462,12 +1485,12 @@ class WalletWireProcessor {
|
|
|
1462
1485
|
}
|
|
1463
1486
|
else {
|
|
1464
1487
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1465
|
-
args.privilegedReason =
|
|
1488
|
+
args.privilegedReason = Utils.toUTF8(privilegedReasonBytes);
|
|
1466
1489
|
}
|
|
1467
1490
|
// Call the method
|
|
1468
1491
|
const listResult = await this.wallet.listCertificates(args, originator);
|
|
1469
1492
|
// Serialize the result
|
|
1470
|
-
const resultWriter = new
|
|
1493
|
+
const resultWriter = new Utils.Writer();
|
|
1471
1494
|
// totalCertificates
|
|
1472
1495
|
resultWriter.writeVarIntNum(listResult.totalCertificates);
|
|
1473
1496
|
// certificates
|
|
@@ -1479,7 +1502,7 @@ class WalletWireProcessor {
|
|
|
1479
1502
|
resultWriter.write(certBin);
|
|
1480
1503
|
}
|
|
1481
1504
|
// Return the response
|
|
1482
|
-
const responseWriter = new
|
|
1505
|
+
const responseWriter = new Utils.Writer();
|
|
1483
1506
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1484
1507
|
responseWriter.write(resultWriter.toArray());
|
|
1485
1508
|
return responseWriter.toArray();
|
|
@@ -1490,32 +1513,32 @@ class WalletWireProcessor {
|
|
|
1490
1513
|
const cert = {};
|
|
1491
1514
|
// Read type
|
|
1492
1515
|
const typeBytes = paramsReader.read(32);
|
|
1493
|
-
cert.type =
|
|
1516
|
+
cert.type = Utils.toBase64(typeBytes);
|
|
1494
1517
|
// Read subject
|
|
1495
1518
|
const subjectBytes = paramsReader.read(33);
|
|
1496
|
-
cert.subject =
|
|
1519
|
+
cert.subject = Utils.toHex(subjectBytes);
|
|
1497
1520
|
// Read serialNumber
|
|
1498
1521
|
const serialNumberBytes = paramsReader.read(32);
|
|
1499
|
-
cert.serialNumber =
|
|
1522
|
+
cert.serialNumber = Utils.toBase64(serialNumberBytes);
|
|
1500
1523
|
// Read certifier
|
|
1501
1524
|
const certifierBytes = paramsReader.read(33);
|
|
1502
|
-
cert.certifier =
|
|
1525
|
+
cert.certifier = Utils.toHex(certifierBytes);
|
|
1503
1526
|
// Read revocationOutpoint
|
|
1504
1527
|
cert.revocationOutpoint = this.decodeOutpoint(paramsReader);
|
|
1505
1528
|
// Read signature
|
|
1506
1529
|
const signatureLength = paramsReader.readVarIntNum();
|
|
1507
1530
|
const signatureBytes = paramsReader.read(signatureLength);
|
|
1508
|
-
cert.signature =
|
|
1531
|
+
cert.signature = Utils.toHex(signatureBytes);
|
|
1509
1532
|
// Read fields
|
|
1510
1533
|
const fieldsLength = paramsReader.readVarIntNum();
|
|
1511
1534
|
cert.fields = {};
|
|
1512
1535
|
for (let i = 0; i < fieldsLength; i++) {
|
|
1513
1536
|
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1514
1537
|
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1515
|
-
const fieldName =
|
|
1538
|
+
const fieldName = Utils.toUTF8(fieldNameBytes);
|
|
1516
1539
|
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1517
1540
|
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1518
|
-
const fieldValue =
|
|
1541
|
+
const fieldValue = Utils.toUTF8(fieldValueBytes);
|
|
1519
1542
|
cert.fields[fieldName] = fieldValue;
|
|
1520
1543
|
}
|
|
1521
1544
|
args.certificate = cert;
|
|
@@ -1525,12 +1548,12 @@ class WalletWireProcessor {
|
|
|
1525
1548
|
for (let i = 0; i < fieldsToRevealLength; i++) {
|
|
1526
1549
|
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1527
1550
|
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1528
|
-
const fieldName =
|
|
1551
|
+
const fieldName = Utils.toUTF8(fieldNameBytes);
|
|
1529
1552
|
args.fieldsToReveal.push(fieldName);
|
|
1530
1553
|
}
|
|
1531
1554
|
// Read verifier
|
|
1532
1555
|
const verifierBytes = paramsReader.read(33);
|
|
1533
|
-
args.verifier =
|
|
1556
|
+
args.verifier = Utils.toHex(verifierBytes);
|
|
1534
1557
|
// Read privileged parameters
|
|
1535
1558
|
const privilegedFlag = paramsReader.readInt8();
|
|
1536
1559
|
if (privilegedFlag === -1) {
|
|
@@ -1545,24 +1568,24 @@ class WalletWireProcessor {
|
|
|
1545
1568
|
}
|
|
1546
1569
|
else {
|
|
1547
1570
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1548
|
-
args.privilegedReason =
|
|
1571
|
+
args.privilegedReason = Utils.toUTF8(privilegedReasonBytes);
|
|
1549
1572
|
}
|
|
1550
1573
|
// Call the method
|
|
1551
1574
|
const proveResult = await this.wallet.proveCertificate(args, originator);
|
|
1552
1575
|
// Serialize keyringForVerifier
|
|
1553
|
-
const resultWriter = new
|
|
1576
|
+
const resultWriter = new Utils.Writer();
|
|
1554
1577
|
const keyringEntries = Object.entries(proveResult.keyringForVerifier);
|
|
1555
1578
|
resultWriter.writeVarIntNum(keyringEntries.length);
|
|
1556
1579
|
for (const [fieldName, fieldValue] of keyringEntries) {
|
|
1557
|
-
const fieldNameBytes =
|
|
1580
|
+
const fieldNameBytes = Utils.toArray(fieldName, 'utf8');
|
|
1558
1581
|
resultWriter.writeVarIntNum(fieldNameBytes.length);
|
|
1559
1582
|
resultWriter.write(fieldNameBytes);
|
|
1560
|
-
const fieldValueBytes =
|
|
1583
|
+
const fieldValueBytes = Utils.toArray(fieldValue, 'base64');
|
|
1561
1584
|
resultWriter.writeVarIntNum(fieldValueBytes.length);
|
|
1562
1585
|
resultWriter.write(fieldValueBytes);
|
|
1563
1586
|
}
|
|
1564
1587
|
// Return the response
|
|
1565
|
-
const responseWriter = new
|
|
1588
|
+
const responseWriter = new Utils.Writer();
|
|
1566
1589
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1567
1590
|
responseWriter.write(resultWriter.toArray());
|
|
1568
1591
|
return responseWriter.toArray();
|
|
@@ -1571,17 +1594,17 @@ class WalletWireProcessor {
|
|
|
1571
1594
|
const args = {};
|
|
1572
1595
|
// Read type
|
|
1573
1596
|
const typeBytes = paramsReader.read(32);
|
|
1574
|
-
args.type =
|
|
1597
|
+
args.type = Utils.toBase64(typeBytes);
|
|
1575
1598
|
// Read serialNumber
|
|
1576
1599
|
const serialNumberBytes = paramsReader.read(32);
|
|
1577
|
-
args.serialNumber =
|
|
1600
|
+
args.serialNumber = Utils.toBase64(serialNumberBytes);
|
|
1578
1601
|
// Read certifier
|
|
1579
1602
|
const certifierBytes = paramsReader.read(33);
|
|
1580
|
-
args.certifier =
|
|
1603
|
+
args.certifier = Utils.toHex(certifierBytes);
|
|
1581
1604
|
// Call the method
|
|
1582
1605
|
await this.wallet.relinquishCertificate(args, originator);
|
|
1583
1606
|
// Return success code
|
|
1584
|
-
const responseWriter = new
|
|
1607
|
+
const responseWriter = new Utils.Writer();
|
|
1585
1608
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1586
1609
|
return responseWriter.toArray();
|
|
1587
1610
|
}
|
|
@@ -1589,7 +1612,7 @@ class WalletWireProcessor {
|
|
|
1589
1612
|
const args = {};
|
|
1590
1613
|
// Read identityKey
|
|
1591
1614
|
const identityKeyBytes = paramsReader.read(33);
|
|
1592
|
-
args.identityKey =
|
|
1615
|
+
args.identityKey = Utils.toHex(identityKeyBytes);
|
|
1593
1616
|
// Read limit and offset
|
|
1594
1617
|
const limit = paramsReader.readVarIntNum();
|
|
1595
1618
|
if (limit >= 0) {
|
|
@@ -1618,7 +1641,7 @@ class WalletWireProcessor {
|
|
|
1618
1641
|
// Serialize the result
|
|
1619
1642
|
const result = this.serializeDiscoveryResult(discoverResult);
|
|
1620
1643
|
// Return the response
|
|
1621
|
-
const responseWriter = new
|
|
1644
|
+
const responseWriter = new Utils.Writer();
|
|
1622
1645
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1623
1646
|
responseWriter.write(result);
|
|
1624
1647
|
return responseWriter.toArray();
|
|
@@ -1631,10 +1654,10 @@ class WalletWireProcessor {
|
|
|
1631
1654
|
for (let i = 0; i < attributesLength; i++) {
|
|
1632
1655
|
const fieldKeyLength = paramsReader.readVarIntNum();
|
|
1633
1656
|
const fieldKeyBytes = paramsReader.read(fieldKeyLength);
|
|
1634
|
-
const fieldKey =
|
|
1657
|
+
const fieldKey = Utils.toUTF8(fieldKeyBytes);
|
|
1635
1658
|
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1636
1659
|
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1637
|
-
const fieldValue =
|
|
1660
|
+
const fieldValue = Utils.toUTF8(fieldValueBytes);
|
|
1638
1661
|
args.attributes[fieldKey] = fieldValue;
|
|
1639
1662
|
}
|
|
1640
1663
|
// Read limit and offset
|
|
@@ -1665,7 +1688,7 @@ class WalletWireProcessor {
|
|
|
1665
1688
|
// Serialize the result
|
|
1666
1689
|
const result = this.serializeDiscoveryResult(discoverResult);
|
|
1667
1690
|
// Return the response
|
|
1668
|
-
const responseWriter = new
|
|
1691
|
+
const responseWriter = new Utils.Writer();
|
|
1669
1692
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1670
1693
|
responseWriter.write(result);
|
|
1671
1694
|
return responseWriter.toArray();
|
|
@@ -1675,16 +1698,16 @@ class WalletWireProcessor {
|
|
|
1675
1698
|
}
|
|
1676
1699
|
}
|
|
1677
1700
|
catch (err) {
|
|
1678
|
-
const responseWriter = new
|
|
1701
|
+
const responseWriter = new Utils.Writer();
|
|
1679
1702
|
responseWriter.writeUInt8(typeof err.code === 'number' ? err.code : 1); // errorCode = 1 (generic error)
|
|
1680
1703
|
// Serialize the error message
|
|
1681
1704
|
const errorMessage = typeof err.message === 'string' ? err.message : 'Unknown error';
|
|
1682
|
-
const errorMessageBytes =
|
|
1705
|
+
const errorMessageBytes = Utils.toArray(errorMessage, 'utf8');
|
|
1683
1706
|
responseWriter.writeVarIntNum(errorMessageBytes.length);
|
|
1684
1707
|
responseWriter.write(errorMessageBytes);
|
|
1685
1708
|
// Serialize the stack trace
|
|
1686
1709
|
const stackTrace = typeof err.stack === 'string' ? err.stack : '';
|
|
1687
|
-
const stackTraceBytes =
|
|
1710
|
+
const stackTraceBytes = Utils.toArray(stackTrace, 'utf8');
|
|
1688
1711
|
responseWriter.writeVarIntNum(stackTraceBytes.length);
|
|
1689
1712
|
responseWriter.write(stackTraceBytes);
|
|
1690
1713
|
return responseWriter.toArray();
|
|
@@ -1694,13 +1717,13 @@ class WalletWireProcessor {
|
|
|
1694
1717
|
const securityLevel = reader.readUInt8();
|
|
1695
1718
|
const protocolLength = reader.readVarIntNum();
|
|
1696
1719
|
const protocolBytes = reader.read(protocolLength);
|
|
1697
|
-
const protocolString =
|
|
1720
|
+
const protocolString = Utils.toUTF8(protocolBytes);
|
|
1698
1721
|
return [securityLevel, protocolString];
|
|
1699
1722
|
}
|
|
1700
1723
|
decodeString(reader) {
|
|
1701
1724
|
const length = reader.readVarIntNum();
|
|
1702
1725
|
const bytes = reader.read(length);
|
|
1703
|
-
return
|
|
1726
|
+
return Utils.toUTF8(bytes);
|
|
1704
1727
|
}
|
|
1705
1728
|
decodeCounterparty(reader) {
|
|
1706
1729
|
const counterpartyFlag = reader.readUInt8();
|
|
@@ -1715,11 +1738,11 @@ class WalletWireProcessor {
|
|
|
1715
1738
|
}
|
|
1716
1739
|
else {
|
|
1717
1740
|
const counterpartyRemainingBytes = reader.read(32);
|
|
1718
|
-
return
|
|
1741
|
+
return Utils.toHex([counterpartyFlag, ...counterpartyRemainingBytes]);
|
|
1719
1742
|
}
|
|
1720
1743
|
}
|
|
1721
1744
|
serializeDiscoveryResult(discoverResult) {
|
|
1722
|
-
const resultWriter = new
|
|
1745
|
+
const resultWriter = new Utils.Writer();
|
|
1723
1746
|
// totalCertificates
|
|
1724
1747
|
resultWriter.writeVarIntNum(discoverResult.totalCertificates);
|
|
1725
1748
|
// certificates
|
|
@@ -1731,13 +1754,13 @@ class WalletWireProcessor {
|
|
|
1731
1754
|
resultWriter.writeVarIntNum(certBin.length);
|
|
1732
1755
|
resultWriter.write(certBin);
|
|
1733
1756
|
// Serialize certifierInfo
|
|
1734
|
-
const nameBytes =
|
|
1757
|
+
const nameBytes = Utils.toArray(cert.certifierInfo.name, 'utf8');
|
|
1735
1758
|
resultWriter.writeVarIntNum(nameBytes.length);
|
|
1736
1759
|
resultWriter.write(nameBytes);
|
|
1737
|
-
const iconUrlBytes =
|
|
1760
|
+
const iconUrlBytes = Utils.toArray(cert.certifierInfo.iconUrl, 'utf8');
|
|
1738
1761
|
resultWriter.writeVarIntNum(iconUrlBytes.length);
|
|
1739
1762
|
resultWriter.write(iconUrlBytes);
|
|
1740
|
-
const descriptionBytes =
|
|
1763
|
+
const descriptionBytes = Utils.toArray(cert.certifierInfo.description, 'utf8');
|
|
1741
1764
|
resultWriter.writeVarIntNum(descriptionBytes.length);
|
|
1742
1765
|
resultWriter.write(descriptionBytes);
|
|
1743
1766
|
resultWriter.writeUInt8(cert.certifierInfo.trust);
|
|
@@ -1745,10 +1768,10 @@ class WalletWireProcessor {
|
|
|
1745
1768
|
const publicKeyringEntries = Object.entries(cert.publiclyRevealedKeyring);
|
|
1746
1769
|
resultWriter.writeVarIntNum(publicKeyringEntries.length);
|
|
1747
1770
|
for (const [fieldName, fieldValue] of publicKeyringEntries) {
|
|
1748
|
-
const fieldNameBytes =
|
|
1771
|
+
const fieldNameBytes = Utils.toArray(fieldName, 'utf8');
|
|
1749
1772
|
resultWriter.writeVarIntNum(fieldNameBytes.length);
|
|
1750
1773
|
resultWriter.write(fieldNameBytes);
|
|
1751
|
-
const fieldValueBytes =
|
|
1774
|
+
const fieldValueBytes = Utils.toArray(fieldValue, 'base64');
|
|
1752
1775
|
resultWriter.writeVarIntNum(fieldValueBytes.length);
|
|
1753
1776
|
resultWriter.write(fieldValueBytes);
|
|
1754
1777
|
}
|
|
@@ -1756,10 +1779,10 @@ class WalletWireProcessor {
|
|
|
1756
1779
|
const decryptedFieldEntries = Object.entries(cert.decryptedFields);
|
|
1757
1780
|
resultWriter.writeVarIntNum(decryptedFieldEntries.length);
|
|
1758
1781
|
for (const [fieldName, fieldValue] of decryptedFieldEntries) {
|
|
1759
|
-
const fieldNameBytes =
|
|
1782
|
+
const fieldNameBytes = Utils.toArray(fieldName, 'utf8');
|
|
1760
1783
|
resultWriter.writeVarIntNum(fieldNameBytes.length);
|
|
1761
1784
|
resultWriter.write(fieldNameBytes);
|
|
1762
|
-
const fieldValueBytes =
|
|
1785
|
+
const fieldValueBytes = Utils.toArray(fieldValue, 'utf8');
|
|
1763
1786
|
resultWriter.writeVarIntNum(fieldValueBytes.length);
|
|
1764
1787
|
resultWriter.write(fieldValueBytes);
|
|
1765
1788
|
}
|
|
@@ -1773,7 +1796,7 @@ class WalletWireProcessor {
|
|
|
1773
1796
|
// Read keyID
|
|
1774
1797
|
const keyIDLength = paramsReader.readVarIntNum();
|
|
1775
1798
|
const keyIDBytes = paramsReader.read(keyIDLength);
|
|
1776
|
-
args.keyID =
|
|
1799
|
+
args.keyID = Utils.toUTF8(keyIDBytes);
|
|
1777
1800
|
// Read counterparty
|
|
1778
1801
|
args.counterparty = this.decodeCounterparty(paramsReader);
|
|
1779
1802
|
// Read privileged parameters
|
|
@@ -1790,7 +1813,7 @@ class WalletWireProcessor {
|
|
|
1790
1813
|
}
|
|
1791
1814
|
else {
|
|
1792
1815
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1793
|
-
args.privilegedReason =
|
|
1816
|
+
args.privilegedReason = Utils.toUTF8(privilegedReasonBytes);
|
|
1794
1817
|
}
|
|
1795
1818
|
return args;
|
|
1796
1819
|
}
|