trac-msb 0.0.41 → 0.0.43
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/package.json +2 -2
- package/src/index.js +5 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trac-msb",
|
|
3
3
|
"main": "msb.mjs",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.43",
|
|
5
5
|
"pear": {
|
|
6
6
|
"name": "trac-msb",
|
|
7
7
|
"type": "terminal"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"protomux-wakeup": "^2.2.1",
|
|
29
29
|
"ready-resource": "^1.0.0",
|
|
30
30
|
"safety-catch": "1.0.2",
|
|
31
|
-
"trac-wallet": "^0.0.
|
|
31
|
+
"trac-wallet": "^0.0.30",
|
|
32
32
|
"xache": "1.2.0",
|
|
33
33
|
"bare-assert": "^1.0.2",
|
|
34
34
|
"bare-buffer": "^3.1.2",
|
package/src/index.js
CHANGED
|
@@ -5,13 +5,12 @@ import ReadyResource from 'ready-resource';
|
|
|
5
5
|
import b4a from 'b4a';
|
|
6
6
|
import Hyperbee from 'hyperbee';
|
|
7
7
|
import readline from 'readline';
|
|
8
|
-
import
|
|
8
|
+
import hccrypto from 'hypercore-crypto';
|
|
9
9
|
import { sanitizeTransaction, addWriter } from './functions.js';
|
|
10
10
|
import w from 'protomux-wakeup';
|
|
11
11
|
import PeerWallet from "trac-wallet"
|
|
12
12
|
import Corestore from 'corestore';
|
|
13
13
|
import tty from 'tty'
|
|
14
|
-
import {Buffer} from 'buffer'
|
|
15
14
|
|
|
16
15
|
const wakeup = new w();
|
|
17
16
|
|
|
@@ -68,8 +67,8 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
68
67
|
if (null === await view.get(op.key) &&
|
|
69
68
|
sanitizeTransaction(postTx) &&
|
|
70
69
|
postTx.op === 'post-tx' &&
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
hccrypto.verify(Buffer.from(postTx.tx + postTx.in, 'utf-8'), Buffer.from(postTx.is, 'hex'), Buffer.from(postTx.ipk, 'hex')) &&// sender verification
|
|
71
|
+
hccrypto.verify(Buffer.from(postTx.tx + postTx.wn, 'utf-8'), Buffer.from(postTx.ws, 'hex'), Buffer.from(postTx.wp, 'hex')) &&// writer verification
|
|
73
72
|
Buffer.byteLength(JSON.stringify(postTx)) <= 4096
|
|
74
73
|
) {
|
|
75
74
|
await view.put(op.key, op.value);
|
|
@@ -157,12 +156,12 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
157
156
|
|
|
158
157
|
if (sanitizeTransaction(parsedPreTx) &&
|
|
159
158
|
parsedPreTx.op === 'pre-tx' &&
|
|
160
|
-
|
|
159
|
+
hccrypto.verify(Buffer.from(parsedPreTx.tx + parsedPreTx.in, 'utf-8'), Buffer.from(parsedPreTx.is, 'hex'), Buffer.from(parsedPreTx.ipk, 'hex')) &&
|
|
161
160
|
parsedPreTx.w === _this.writerLocalKey &&
|
|
162
161
|
null === await _this.base.view.get(parsedPreTx.tx)
|
|
163
162
|
) {
|
|
164
163
|
const nonce = Math.random() + '-' + Date.now();
|
|
165
|
-
const signature =
|
|
164
|
+
const signature = hccrypto.sign(Buffer.from(parsedPreTx.tx + nonce, 'utf-8'), Buffer.from(this.wallet.secretKey, 'hex'));
|
|
166
165
|
const append_tx = {
|
|
167
166
|
op: 'post-tx',
|
|
168
167
|
tx: parsedPreTx.tx,
|