@dignetwork/dig-sdk 0.0.1-alpha.4 → 0.0.1-alpha.41
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/DataIntegrityTree/DataIntegrityTree.d.ts +160 -0
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +1 -0
- package/dist/DataIntegrityTree/DataIntegrityTree.js +672 -0
- package/dist/DataIntegrityTree/DataLayerError.d.ts +6 -0
- package/dist/DataIntegrityTree/DataLayerError.d.ts.map +1 -0
- package/dist/DataIntegrityTree/DataLayerError.js +17 -0
- package/dist/DataIntegrityTree/index.d.ts +2 -0
- package/dist/DataIntegrityTree/index.d.ts.map +1 -0
- package/dist/DataIntegrityTree/index.js +17 -0
- package/dist/DigNetwork/ContentServer.d.ts +5 -1
- package/dist/DigNetwork/ContentServer.d.ts.map +1 -1
- package/dist/DigNetwork/ContentServer.js +28 -13
- package/dist/DigNetwork/DigNetwork.d.ts +1 -0
- package/dist/DigNetwork/DigNetwork.d.ts.map +1 -1
- package/dist/DigNetwork/DigNetwork.js +74 -50
- package/dist/DigNetwork/DigPeer.d.ts +5 -1
- package/dist/DigNetwork/DigPeer.d.ts.map +1 -1
- package/dist/DigNetwork/DigPeer.js +51 -16
- package/dist/DigNetwork/PropagationServer.d.ts +7 -1
- package/dist/DigNetwork/PropagationServer.d.ts.map +1 -1
- package/dist/DigNetwork/PropagationServer.js +100 -68
- package/dist/blockchain/DataStore.d.ts +2 -2
- package/dist/blockchain/DataStore.d.ts.map +1 -1
- package/dist/blockchain/DataStore.js +9 -5
- package/dist/blockchain/DataStoreSerializer.d.ts +1 -1
- package/dist/blockchain/DataStoreSerializer.d.ts.map +1 -1
- package/dist/blockchain/FullNodePeer.d.ts +8 -1
- package/dist/blockchain/FullNodePeer.d.ts.map +1 -1
- package/dist/blockchain/FullNodePeer.js +39 -7
- package/dist/blockchain/ServerCoin.d.ts +11 -3
- package/dist/blockchain/ServerCoin.d.ts.map +1 -1
- package/dist/blockchain/ServerCoin.js +30 -17
- package/dist/blockchain/Wallet.d.ts +1 -1
- package/dist/blockchain/Wallet.d.ts.map +1 -1
- package/dist/blockchain/Wallet.js +1 -1
- package/dist/blockchain/coins.d.ts +1 -1
- package/dist/blockchain/coins.d.ts.map +1 -1
- package/dist/blockchain/coins.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +4 -9
- package/dist/utils/directoryUtils.d.ts +1 -7
- package/dist/utils/directoryUtils.d.ts.map +1 -1
- package/dist/utils/directoryUtils.js +30 -11
- package/package.json +3 -3
|
@@ -9,7 +9,6 @@ const https_1 = __importDefault(require("https"));
|
|
|
9
9
|
const url_1 = require("url");
|
|
10
10
|
const ssl_1 = require("../utils/ssl");
|
|
11
11
|
const credentialsUtils_1 = require("../utils/credentialsUtils");
|
|
12
|
-
const spinnerUtils_1 = require("../utils/spinnerUtils");
|
|
13
12
|
const blockchain_1 = require("../blockchain");
|
|
14
13
|
class PropagationServer {
|
|
15
14
|
constructor(ipAddress, storeId) {
|
|
@@ -62,8 +61,11 @@ class PropagationServer {
|
|
|
62
61
|
return JSON.parse(statusJson);
|
|
63
62
|
}
|
|
64
63
|
// Method to check if a specific store exists (HEAD request)
|
|
65
|
-
async headStore() {
|
|
66
|
-
|
|
64
|
+
async headStore(options) {
|
|
65
|
+
let url = `https://${this.ipAddress}:${PropagationServer.port}/${this.storeId}`;
|
|
66
|
+
if (options?.hasRootHash) {
|
|
67
|
+
url += `?hasRootHash=${options.hasRootHash}`;
|
|
68
|
+
}
|
|
67
69
|
return this.head(url);
|
|
68
70
|
}
|
|
69
71
|
// In PropagationServer.ts:
|
|
@@ -122,51 +124,49 @@ class PropagationServer {
|
|
|
122
124
|
// Method to fetch upload details from the server
|
|
123
125
|
async fetchUploadDetails(username, password) {
|
|
124
126
|
const remote = `https://${this.ipAddress}:${PropagationServer.port}/${this.storeId}`;
|
|
125
|
-
return (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
reject(new Error("Missing required headers in the response."));
|
|
157
|
-
}
|
|
127
|
+
return new Promise((resolve, reject) => {
|
|
128
|
+
const url = new url_1.URL(remote);
|
|
129
|
+
const options = {
|
|
130
|
+
hostname: url.hostname,
|
|
131
|
+
port: url.port,
|
|
132
|
+
path: url.pathname,
|
|
133
|
+
method: "HEAD",
|
|
134
|
+
headers: {
|
|
135
|
+
Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`,
|
|
136
|
+
},
|
|
137
|
+
key: fs_1.default.readFileSync(PropagationServer.keyPath),
|
|
138
|
+
cert: fs_1.default.readFileSync(PropagationServer.certPath),
|
|
139
|
+
rejectUnauthorized: false, // Allow self-signed certificates
|
|
140
|
+
};
|
|
141
|
+
const req = https_1.default.request(options, (res) => {
|
|
142
|
+
if (res.statusCode === 200) {
|
|
143
|
+
// Check if the headers are present and valid
|
|
144
|
+
const nonce = res.headers["x-nonce"];
|
|
145
|
+
const lastUploadedHash = res.headers?.["x-last-uploaded-hash"] ||
|
|
146
|
+
"0000000000000000000000000000000000000000000000000000000000000000";
|
|
147
|
+
const generationIndex = res.headers?.["x-generation-index"] || 0;
|
|
148
|
+
console.log({ nonce, lastUploadedHash, generationIndex });
|
|
149
|
+
if (nonce) {
|
|
150
|
+
resolve({
|
|
151
|
+
nonce: nonce,
|
|
152
|
+
lastUploadedHash: lastUploadedHash,
|
|
153
|
+
generationIndex: Number(generationIndex),
|
|
154
|
+
});
|
|
158
155
|
}
|
|
159
156
|
else {
|
|
160
|
-
reject(new Error(
|
|
157
|
+
reject(new Error("Missing required headers in the response."));
|
|
161
158
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
reject(new Error(`Failed to perform preflight check: ${res.statusCode} ${res.statusMessage}`));
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
req.on("error", (err) => {
|
|
165
|
+
console.error(err.message);
|
|
166
|
+
resolve(false); // Resolve to false if there is an error
|
|
168
167
|
});
|
|
169
|
-
|
|
168
|
+
req.end();
|
|
169
|
+
});
|
|
170
170
|
}
|
|
171
171
|
// Core method to upload a file directly to the server using a stream
|
|
172
172
|
async uploadFileDirect(filePath, uploadUrl, username, password, keyOwnershipSig, publicKey, nonce) {
|
|
@@ -278,31 +278,63 @@ class PropagationServer {
|
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
280
|
// Helper method to perform HEAD requests
|
|
281
|
-
async head(url) {
|
|
281
|
+
async head(url, maxRedirects = 5) {
|
|
282
282
|
return new Promise((resolve, reject) => {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
283
|
+
try {
|
|
284
|
+
// Parse the input URL
|
|
285
|
+
const urlObj = new url_1.URL(url);
|
|
286
|
+
const requestOptions = {
|
|
287
|
+
hostname: urlObj.hostname,
|
|
288
|
+
port: urlObj.port || (urlObj.protocol === "https:" ? 443 : undefined),
|
|
289
|
+
path: urlObj.pathname + urlObj.search,
|
|
290
|
+
method: "HEAD",
|
|
291
|
+
key: fs_1.default.readFileSync(PropagationServer.keyPath),
|
|
292
|
+
cert: fs_1.default.readFileSync(PropagationServer.certPath),
|
|
293
|
+
rejectUnauthorized: false,
|
|
294
|
+
};
|
|
295
|
+
const request = https_1.default.request(requestOptions, (response) => {
|
|
296
|
+
const { statusCode, headers } = response;
|
|
297
|
+
// If status code is 2xx, return success
|
|
298
|
+
if (statusCode && statusCode >= 200 && statusCode < 300) {
|
|
299
|
+
resolve({ success: true, headers });
|
|
300
|
+
}
|
|
301
|
+
// Handle 3xx redirection
|
|
302
|
+
else if (statusCode && statusCode >= 300 && statusCode < 400 && headers.location) {
|
|
303
|
+
if (maxRedirects > 0) {
|
|
304
|
+
let redirectUrl = headers.location;
|
|
305
|
+
// Check if the redirect URL is relative
|
|
306
|
+
if (!/^https?:\/\//i.test(redirectUrl)) {
|
|
307
|
+
// Resolve the relative URL based on the original URL
|
|
308
|
+
redirectUrl = new url_1.URL(redirectUrl, url).toString();
|
|
309
|
+
console.log(`Resolved relative redirect to: ${redirectUrl}`);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
console.log(`Redirecting to: ${redirectUrl}`);
|
|
313
|
+
}
|
|
314
|
+
// Recursively follow the redirection
|
|
315
|
+
this.head(redirectUrl, maxRedirects - 1)
|
|
316
|
+
.then(resolve)
|
|
317
|
+
.catch(reject);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
reject({ success: false, message: "Too many redirects" });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
// For other status codes, consider it a failure
|
|
325
|
+
resolve({ success: false });
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
request.on("error", (error) => {
|
|
329
|
+
console.error(`Request error for ${url}:`, error);
|
|
330
|
+
reject({ success: false });
|
|
331
|
+
});
|
|
332
|
+
request.end();
|
|
333
|
+
}
|
|
334
|
+
catch (err) {
|
|
335
|
+
console.error(`Invalid URL: ${url}`, err);
|
|
336
|
+
reject({ success: false, message: "Invalid URL" });
|
|
337
|
+
}
|
|
306
338
|
});
|
|
307
339
|
}
|
|
308
340
|
// Helper method to fetch JSON data from a URL
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DataStore as DataStoreDriver, DataStoreMetadata } from "datalayer-driver";
|
|
1
|
+
import { DataStore as DataStoreDriver, DataStoreMetadata } from "@dignetwork/datalayer-driver";
|
|
2
2
|
import { RootHistoryItem } from "../types";
|
|
3
|
-
import { DataIntegrityTree, DataIntegrityTreeOptions } from "
|
|
3
|
+
import { DataIntegrityTree, DataIntegrityTreeOptions } from "../DataIntegrityTree";
|
|
4
4
|
import { CreateStoreUserInputs } from "../types";
|
|
5
5
|
export declare class DataStore {
|
|
6
6
|
private storeId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataStore.d.ts","sourceRoot":"","sources":["../../src/blockchain/DataStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,SAAS,IAAI,eAAe,EAE5B,iBAAiB,EAIlB,MAAM,
|
|
1
|
+
{"version":3,"file":"DataStore.d.ts","sourceRoot":"","sources":["../../src/blockchain/DataStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,SAAS,IAAI,eAAe,EAE5B,iBAAiB,EAIlB,MAAM,8BAA8B,CAAC;AAYtC,OAAO,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AAGpD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAQjD,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAAoB;gBAEpB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAiB/D,IAA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AC;IA+Cd,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAiChE,iBAAiB,IAAI,MAAM,EAAE;CAUrC"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DataStore = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const datalayer_driver_1 = require("datalayer-driver");
|
|
9
|
+
const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
|
|
10
10
|
const util_1 = require("util");
|
|
11
11
|
const FullNodePeer_1 = require("./FullNodePeer");
|
|
12
12
|
const Wallet_1 = require("./Wallet");
|
|
@@ -14,7 +14,7 @@ const config_1 = require("../utils/config");
|
|
|
14
14
|
const coins_1 = require("./coins");
|
|
15
15
|
const utils_1 = require("../utils");
|
|
16
16
|
const hashUtils_1 = require("../utils/hashUtils");
|
|
17
|
-
const
|
|
17
|
+
const DataIntegrityTree_1 = require("../DataIntegrityTree");
|
|
18
18
|
const prompts_1 = require("../prompts");
|
|
19
19
|
const FileCache_1 = require("../utils/FileCache");
|
|
20
20
|
const DataStoreSerializer_1 = require("./DataStoreSerializer");
|
|
@@ -33,7 +33,7 @@ class DataStore {
|
|
|
33
33
|
storeDir: config_1.STORE_PATH,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
this.tree = new
|
|
36
|
+
this.tree = new DataIntegrityTree_1.DataIntegrityTree(storeId, _options);
|
|
37
37
|
}
|
|
38
38
|
get StoreId() {
|
|
39
39
|
return this.storeId;
|
|
@@ -336,6 +336,7 @@ class DataStore {
|
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
let filesIntegrityIntact = true;
|
|
339
|
+
// At this point we have verified that the root history and manifest file match
|
|
339
340
|
for (const rootHash of manifestHashes) {
|
|
340
341
|
const datFilePath = path_1.default.join(config_1.STORE_PATH, this.storeId, `${rootHash}.dat`);
|
|
341
342
|
if (!fs_1.default.existsSync(datFilePath)) {
|
|
@@ -348,8 +349,11 @@ class DataStore {
|
|
|
348
349
|
return false;
|
|
349
350
|
}
|
|
350
351
|
for (const [fileKey, fileData] of Object.entries(datFileContent.files)) {
|
|
351
|
-
|
|
352
|
-
|
|
352
|
+
// We are going to check if the sha256 belongs to the tree, and then we are going to make sure
|
|
353
|
+
// that the file is in the data folder and that the sha256 of the file matches the one in the dat file
|
|
354
|
+
const belongsInTree = await this.Tree.verifyKeyIntegrity(fileData.sha256, rootHash);
|
|
355
|
+
const fileIntegrityCheck = (0, utils_1.validateFileSha256)(fileData.sha256, path_1.default.join(config_1.STORE_PATH, this.storeId, "data"));
|
|
356
|
+
if (!fileIntegrityCheck || !belongsInTree) {
|
|
353
357
|
filesIntegrityIntact = false;
|
|
354
358
|
}
|
|
355
359
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataStoreSerializer.d.ts","sourceRoot":"","sources":["../../src/blockchain/DataStoreSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAKV,MAAM,
|
|
1
|
+
{"version":3,"file":"DataStoreSerializer.d.ts","sourceRoot":"","sources":["../../src/blockchain/DataStoreSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAKV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAS;gBAEf,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAOnE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgDF,WAAW,CACvB,IAAI,EAAE;QACJ,WAAW,EAAE,GAAG,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;KACpB,GACA;QACD,WAAW,EAAE,SAAS,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;KACpB;CAuEF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Peer } from "datalayer-driver";
|
|
1
|
+
import { Peer } from "@dignetwork/datalayer-driver";
|
|
2
2
|
export declare class FullNodePeer {
|
|
3
3
|
private static cachedPeer;
|
|
4
4
|
private static memoizedFetchNewPeerIPs;
|
|
@@ -7,6 +7,13 @@ export declare class FullNodePeer {
|
|
|
7
7
|
static connect(): Promise<Peer>;
|
|
8
8
|
private static isPortReachable;
|
|
9
9
|
private static isValidIpAddress;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the TRUSTED_FULLNODE IP from the environment
|
|
12
|
+
* and verifies if it is a valid IP address.
|
|
13
|
+
*
|
|
14
|
+
* @returns {string | null} The valid IP address or null if invalid
|
|
15
|
+
*/
|
|
16
|
+
private static getTrustedFullNode;
|
|
10
17
|
private static fetchNewPeerIPs;
|
|
11
18
|
private static getPeerIPs;
|
|
12
19
|
private static createPeerProxy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullNodePeer.d.ts","sourceRoot":"","sources":["../../src/blockchain/FullNodePeer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"FullNodePeer.d.ts","sourceRoot":"","sources":["../../src/blockchain/FullNodePeer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAmBpD,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAkD;IAC3E,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAA0B;IAChE,OAAO,CAAC,IAAI,CAAO;IAQnB,OAAO;WAIa,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5C,OAAO,CAAC,MAAM,CAAC,eAAe;IAiB9B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAM/B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;mBASZ,eAAe;mBAiDf,UAAU;IAyB/B,OAAO,CAAC,MAAM,CAAC,eAAe;mBAgDT,WAAW;IAgGzB,OAAO,IAAI,IAAI;WAIF,mBAAmB,CACrC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC;CAwBpB"}
|
|
@@ -7,7 +7,7 @@ exports.FullNodePeer = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const datalayer_driver_1 = require("datalayer-driver");
|
|
10
|
+
const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
|
|
11
11
|
const chia_server_coin_1 = require("chia-server-coin");
|
|
12
12
|
const promises_1 = require("dns/promises");
|
|
13
13
|
const net_1 = __importDefault(require("net"));
|
|
@@ -48,12 +48,24 @@ class FullNodePeer {
|
|
|
48
48
|
const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
49
49
|
return ipv4Regex.test(ip);
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves the TRUSTED_FULLNODE IP from the environment
|
|
53
|
+
* and verifies if it is a valid IP address.
|
|
54
|
+
*
|
|
55
|
+
* @returns {string | null} The valid IP address or null if invalid
|
|
56
|
+
*/
|
|
57
|
+
static getTrustedFullNode() {
|
|
52
58
|
const trustedNodeIp = process.env.TRUSTED_FULLNODE || null;
|
|
59
|
+
if (trustedNodeIp && FullNodePeer.isValidIpAddress(trustedNodeIp)) {
|
|
60
|
+
return trustedNodeIp;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
static async fetchNewPeerIPs() {
|
|
65
|
+
const trustedNodeIp = FullNodePeer.getTrustedFullNode();
|
|
53
66
|
const priorityIps = [];
|
|
54
67
|
// Prioritize trustedNodeIp
|
|
55
68
|
if (trustedNodeIp &&
|
|
56
|
-
FullNodePeer.isValidIpAddress(trustedNodeIp) &&
|
|
57
69
|
(await FullNodePeer.isPortReachable(trustedNodeIp, FULLNODE_PORT))) {
|
|
58
70
|
priorityIps.push(trustedNodeIp);
|
|
59
71
|
}
|
|
@@ -107,18 +119,38 @@ class FullNodePeer {
|
|
|
107
119
|
}
|
|
108
120
|
return FullNodePeer.memoizedFetchNewPeerIPs();
|
|
109
121
|
}
|
|
110
|
-
static createPeerProxy(peer
|
|
122
|
+
static createPeerProxy(peer) {
|
|
111
123
|
return new Proxy(peer, {
|
|
112
124
|
get: (target, prop) => {
|
|
113
125
|
const originalMethod = target[prop];
|
|
114
126
|
if (typeof originalMethod === "function") {
|
|
115
127
|
return async (...args) => {
|
|
128
|
+
let timeoutId;
|
|
129
|
+
// Start the timeout to forget the peer after 1 minute
|
|
130
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
131
|
+
timeoutId = setTimeout(() => {
|
|
132
|
+
FullNodePeer.cachedPeer = null;
|
|
133
|
+
reject(new Error("Operation timed out. Reconnecting to a new peer."));
|
|
134
|
+
}, 60000); // 1 minute
|
|
135
|
+
});
|
|
116
136
|
try {
|
|
117
|
-
|
|
137
|
+
// Run the original method and race it against the timeout
|
|
138
|
+
const result = await Promise.race([
|
|
139
|
+
originalMethod.apply(target, args),
|
|
140
|
+
timeoutPromise,
|
|
141
|
+
]);
|
|
142
|
+
// Clear the timeout if the operation succeeded
|
|
143
|
+
if (timeoutId) {
|
|
144
|
+
clearTimeout(timeoutId);
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
118
147
|
}
|
|
119
148
|
catch (error) {
|
|
120
|
-
|
|
149
|
+
// If the error is WebSocket-related or timeout, reset the peer
|
|
150
|
+
if (error.message.includes("WebSocket") || error.message.includes("Operation timed out")) {
|
|
121
151
|
FullNodePeer.cachedPeer = null;
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
FullNodePeer.memoizedFetchNewPeerIPs.cache.clear();
|
|
122
154
|
const newPeer = await FullNodePeer.getBestPeer();
|
|
123
155
|
return newPeer[prop](...args);
|
|
124
156
|
}
|
|
@@ -149,7 +181,7 @@ class FullNodePeer {
|
|
|
149
181
|
if (ip) {
|
|
150
182
|
try {
|
|
151
183
|
const peer = await datalayer_driver_1.Peer.new(`${ip}:${FULLNODE_PORT}`, false, certFile, keyFile);
|
|
152
|
-
return FullNodePeer.createPeerProxy(peer
|
|
184
|
+
return FullNodePeer.createPeerProxy(peer);
|
|
153
185
|
}
|
|
154
186
|
catch (error) {
|
|
155
187
|
console.error(`Failed to create peer for IP ${ip}: ${error.message}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServerCoin as ServerCoinDriver } from "datalayer-driver";
|
|
1
|
+
import { ServerCoin as ServerCoinDriver } from "@dignetwork/datalayer-driver";
|
|
2
2
|
import { NconfManager } from "../utils/NconfManager";
|
|
3
3
|
export declare class ServerCoin {
|
|
4
4
|
private storeId;
|
|
@@ -8,14 +8,22 @@ export declare class ServerCoin {
|
|
|
8
8
|
saveServerCoinData(serverCoin: ServerCoinDriver, epoch: number, peerIp: string): Promise<void>;
|
|
9
9
|
melt(epoch: number, peerIp: string): Promise<void>;
|
|
10
10
|
private removeServerCoinData;
|
|
11
|
+
getAllEpochPeers(epoch: number, blacklist?: string[]): Promise<string[]>;
|
|
12
|
+
getActiveEpochPeers(blacklist?: string[]): Promise<string[]>;
|
|
11
13
|
sampleCurrentEpoch(sampleSize?: number, blacklist?: string[]): Promise<string[]>;
|
|
12
14
|
sampleServerCoinsByEpoch(epoch: number, sampleSize?: number, blacklist?: string[]): Promise<string[]>;
|
|
13
|
-
static getCurrentEpoch():
|
|
15
|
+
static getCurrentEpoch(): {
|
|
16
|
+
epoch: number;
|
|
17
|
+
round: number;
|
|
18
|
+
};
|
|
14
19
|
ensureServerCoinExists(peerIp: string): Promise<void>;
|
|
15
20
|
meltOutdatedEpochs(peerIp: string): Promise<void>;
|
|
16
21
|
static meltUntrackedStoreCoins(): Promise<void>;
|
|
17
22
|
private getServerCoinsForStore;
|
|
18
23
|
hasEpochCoinBeenCreated(currentEpoch: number, peerIp: string): Promise<boolean>;
|
|
19
|
-
static
|
|
24
|
+
static calculateEpochAndRound(currentTimestampUTC: Date): {
|
|
25
|
+
epoch: number;
|
|
26
|
+
round: number;
|
|
27
|
+
};
|
|
20
28
|
}
|
|
21
29
|
//# sourceMappingURL=ServerCoin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerCoin.d.ts","sourceRoot":"","sources":["../../src/blockchain/ServerCoin.ts"],"names":[],"mappings":"AACA,OAAO,EAML,UAAU,IAAI,gBAAgB,EAE/B,MAAM,
|
|
1
|
+
{"version":3,"file":"ServerCoin.d.ts","sourceRoot":"","sources":["../../src/blockchain/ServerCoin.ts"],"names":[],"mappings":"AACA,OAAO,EAML,UAAU,IAAI,gBAAgB,EAE/B,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAMrD,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,gBAAuB,iBAAiB,eAEtC;gBAEU,OAAO,EAAE,MAAM;IAKd,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2DzD,kBAAkB,CAC7B,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAqBH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAoDjD,oBAAoB;IAerB,gBAAgB,CAC3B,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;IAoCP,mBAAmB,CAC9B,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;IAMP,kBAAkB,CAC7B,UAAU,GAAE,MAAU,EACtB,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;IAMP,wBAAwB,CACnC,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAU,EACtB,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;WAMN,eAAe,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAKpD,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDrD,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WA+B1C,uBAAuB;YAkE7B,sBAAsB;IAWvB,uBAAuB,CAClC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;WAuBL,sBAAsB,CAAC,mBAAmB,EAAE,IAAI,GAAG;QAC/D,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf;CA2BF"}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ServerCoin = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const datalayer_driver_1 = require("datalayer-driver");
|
|
8
|
+
const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
|
|
9
9
|
const FullNodePeer_1 = require("./FullNodePeer");
|
|
10
10
|
const coins_1 = require("./coins");
|
|
11
11
|
const Wallet_1 = require("./Wallet");
|
|
@@ -23,7 +23,7 @@ class ServerCoin {
|
|
|
23
23
|
const wallet = await Wallet_1.Wallet.load("default");
|
|
24
24
|
const publicSyntheticKey = await wallet.getPublicSyntheticKey();
|
|
25
25
|
const serverCoinCreationCoins = await (0, coins_1.selectUnspentCoins)(peer, BigInt(serverCoinCollateral), BigInt(1000000));
|
|
26
|
-
const currentEpoch = ServerCoin.getCurrentEpoch();
|
|
26
|
+
const { epoch: currentEpoch } = ServerCoin.getCurrentEpoch();
|
|
27
27
|
const epochBasedHint = (0, datalayer_driver_1.morphLauncherId)(Buffer.from(this.storeId, "hex"), BigInt(currentEpoch));
|
|
28
28
|
const newServerCoin = (0, datalayer_driver_1.createServerCoin)(publicSyntheticKey, serverCoinCreationCoins, epochBasedHint, [peerIp], BigInt(serverCoinCollateral), BigInt(1000000));
|
|
29
29
|
const combinedCoinSpends = [...newServerCoin.coinSpends];
|
|
@@ -94,13 +94,7 @@ class ServerCoin {
|
|
|
94
94
|
serverCoins = serverCoins.filter((coin) => coin.coin.parentCoinInfo !== serverCoin.parentCoinInfo);
|
|
95
95
|
await ServerCoin.serverCoinManager.setConfigValue(`${this.storeId}:${peerIp}`, serverCoins);
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
async sampleCurrentEpoch(sampleSize = 5, blacklist = []) {
|
|
99
|
-
const epoch = ServerCoin.getCurrentEpoch();
|
|
100
|
-
return this.sampleServerCoinsByEpoch(epoch, sampleSize, blacklist);
|
|
101
|
-
}
|
|
102
|
-
// Sample server coins by epoch
|
|
103
|
-
async sampleServerCoinsByEpoch(epoch, sampleSize = 5, blacklist = []) {
|
|
97
|
+
async getAllEpochPeers(epoch, blacklist = []) {
|
|
104
98
|
const epochBasedHint = (0, datalayer_driver_1.morphLauncherId)(Buffer.from(this.storeId, "hex"), BigInt(epoch));
|
|
105
99
|
const peer = await FullNodePeer_1.FullNodePeer.connect();
|
|
106
100
|
const maxClvmCost = BigInt(11000000000);
|
|
@@ -118,18 +112,31 @@ class ServerCoin {
|
|
|
118
112
|
if (process.env.DIG_DEBUG === "1") {
|
|
119
113
|
console.log("Server Coin Peers: ", serverCoinPeers);
|
|
120
114
|
}
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
return Array.from(serverCoinPeers);
|
|
116
|
+
}
|
|
117
|
+
async getActiveEpochPeers(blacklist = []) {
|
|
118
|
+
const { epoch } = ServerCoin.getCurrentEpoch();
|
|
119
|
+
return this.getAllEpochPeers(epoch, blacklist);
|
|
120
|
+
}
|
|
121
|
+
// Sample server coins for the current epoch
|
|
122
|
+
async sampleCurrentEpoch(sampleSize = 5, blacklist = []) {
|
|
123
|
+
const { epoch } = ServerCoin.getCurrentEpoch();
|
|
124
|
+
return this.sampleServerCoinsByEpoch(epoch, sampleSize, blacklist);
|
|
125
|
+
}
|
|
126
|
+
// Sample server coins by epoch
|
|
127
|
+
async sampleServerCoinsByEpoch(epoch, sampleSize = 5, blacklist = []) {
|
|
128
|
+
const serverCoinPeers = await this.getAllEpochPeers(epoch, blacklist);
|
|
129
|
+
return lodash_1.default.sampleSize(serverCoinPeers, sampleSize);
|
|
123
130
|
}
|
|
124
131
|
// Get the current epoch based on the current timestamp
|
|
125
132
|
static getCurrentEpoch() {
|
|
126
|
-
return ServerCoin.
|
|
133
|
+
return ServerCoin.calculateEpochAndRound(new Date());
|
|
127
134
|
}
|
|
128
135
|
// Ensure server coin exists for the current epoch
|
|
129
136
|
async ensureServerCoinExists(peerIp) {
|
|
130
137
|
try {
|
|
131
138
|
console.log(`Ensuring server coin exists for store ${this.storeId}...`);
|
|
132
|
-
const currentEpoch = ServerCoin.getCurrentEpoch();
|
|
139
|
+
const { epoch: currentEpoch } = ServerCoin.getCurrentEpoch();
|
|
133
140
|
const serverCoins = await this.getServerCoinsForStore(peerIp);
|
|
134
141
|
// Check if a server coin already exists for the current epoch
|
|
135
142
|
const existingCoin = serverCoins.find((coin) => coin.epoch === currentEpoch);
|
|
@@ -160,7 +167,7 @@ class ServerCoin {
|
|
|
160
167
|
// Melt outdated server coins
|
|
161
168
|
async meltOutdatedEpochs(peerIp) {
|
|
162
169
|
try {
|
|
163
|
-
const currentEpoch = ServerCoin.getCurrentEpoch();
|
|
170
|
+
const { epoch: currentEpoch } = ServerCoin.getCurrentEpoch();
|
|
164
171
|
let serverCoins = await this.getServerCoinsForStore(peerIp);
|
|
165
172
|
// Filter out coins that are not in the current epoch
|
|
166
173
|
const outdatedCoins = serverCoins.filter((coin) => coin.epoch < currentEpoch);
|
|
@@ -244,17 +251,23 @@ class ServerCoin {
|
|
|
244
251
|
}
|
|
245
252
|
}
|
|
246
253
|
// Static method to calculate the current epoch
|
|
247
|
-
static
|
|
254
|
+
static calculateEpochAndRound(currentTimestampUTC) {
|
|
248
255
|
const firstEpochStart = new Date(Date.UTC(2024, 8, 3, 0, 0)); // Sept 3, 2024, 00:00 UTC
|
|
249
256
|
// Convert the current timestamp to milliseconds
|
|
250
257
|
const currentTimestampMillis = currentTimestampUTC.getTime();
|
|
251
258
|
// Calculate the number of milliseconds in one epoch (7 days)
|
|
252
|
-
const millisecondsInEpoch = 7 * 24 * 60 * 60 * 1000;
|
|
259
|
+
const millisecondsInEpoch = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds
|
|
253
260
|
// Calculate the difference in milliseconds between the current timestamp and the first epoch start
|
|
254
261
|
const differenceMillis = currentTimestampMillis - firstEpochStart.getTime();
|
|
255
262
|
// Calculate the current epoch number
|
|
256
263
|
const epochNumber = Math.floor(differenceMillis / millisecondsInEpoch) + 1;
|
|
257
|
-
|
|
264
|
+
// Calculate the milliseconds elapsed since the start of the current epoch
|
|
265
|
+
const elapsedMillisInCurrentEpoch = differenceMillis % millisecondsInEpoch;
|
|
266
|
+
// Calculate the number of milliseconds in a round (10 minutes)
|
|
267
|
+
const millisecondsInRound = 10 * 60 * 1000; // 10 minutes in milliseconds
|
|
268
|
+
// Calculate the current round number
|
|
269
|
+
const roundNumber = Math.floor(elapsedMillisInCurrentEpoch / millisecondsInRound) + 1;
|
|
270
|
+
return { epoch: epochNumber, round: roundNumber };
|
|
258
271
|
}
|
|
259
272
|
}
|
|
260
273
|
exports.ServerCoin = ServerCoin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
|
-
import { Peer, Coin, CoinSpend } from "datalayer-driver";
|
|
2
|
+
import { Peer, Coin, CoinSpend } from "@dignetwork/datalayer-driver";
|
|
3
3
|
export declare const DEFAULT_FEE_COIN_COST = 64000000;
|
|
4
4
|
export declare class Wallet {
|
|
5
5
|
private mnemonic;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wallet.d.ts","sourceRoot":"","sources":["../../src/blockchain/Wallet.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EASL,IAAI,EACJ,IAAI,EAEJ,SAAS,EAEV,MAAM,
|
|
1
|
+
{"version":3,"file":"Wallet.d.ts","sourceRoot":"","sources":["../../src/blockchain/Wallet.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EASL,IAAI,EACJ,IAAI,EAEJ,SAAS,EAEV,MAAM,8BAA8B,CAAC;AAMtC,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAOhD,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO;WAKa,IAAI,CACtB,UAAU,GAAE,MAAkB,EAC9B,iBAAiB,GAAE,OAAc,GAChC,OAAO,CAAC,MAAM,CAAC;IAsBX,WAAW,IAAI,MAAM;WAOR,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAMpD,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAShE,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA6BhE,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKrC,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAMxC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAMrC,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;WAK7B,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WASlD,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;mBAU/B,oBAAoB;mBAWpB,mBAAmB;IAM3B,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO3D,2BAA2B,CACtC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IASN,kBAAkB,CAC7B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,IAAI,EAAO,GACrB,OAAO,CAAC,IAAI,EAAE,CAAC;WAwCE,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;WAItF,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAOlF"}
|
|
@@ -38,7 +38,7 @@ const chia_root_resolver_1 = require("chia-root-resolver");
|
|
|
38
38
|
const chia_config_loader_1 = require("chia-config-loader");
|
|
39
39
|
const encryption_1 = require("../utils/encryption");
|
|
40
40
|
const buffer_1 = require("buffer");
|
|
41
|
-
const datalayer_driver_1 = require("datalayer-driver");
|
|
41
|
+
const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
|
|
42
42
|
const config_1 = require("../utils/config");
|
|
43
43
|
const FileCache_1 = require("../utils/FileCache");
|
|
44
44
|
const KEYRING_FILE = "keyring.json";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Peer, Coin, CoinSpend } from "datalayer-driver";
|
|
1
|
+
import { Peer, Coin, CoinSpend } from "@dignetwork/datalayer-driver";
|
|
2
2
|
export declare const DEFAULT_FEE_COIN_COST = 64000000;
|
|
3
3
|
export declare const calculateFeeForCoinSpends: (peer: Peer, coinSpends: CoinSpend[] | null) => Promise<bigint>;
|
|
4
4
|
export declare const selectUnspentCoins: (peer: Peer, coinAmount: bigint, feeBigInt: bigint, omitCoins?: Coin[], walletName?: string) => Promise<Coin[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coins.d.ts","sourceRoot":"","sources":["../../src/blockchain/coins.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EACJ,IAAI,EAEJ,SAAS,EAEV,MAAM,
|
|
1
|
+
{"version":3,"file":"coins.d.ts","sourceRoot":"","sources":["../../src/blockchain/coins.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EACJ,IAAI,EAEJ,SAAS,EAEV,MAAM,8BAA8B,CAAC;AAKtC,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAWhD,eAAO,MAAM,yBAAyB,SAC9B,IAAI,cACE,SAAS,EAAE,GAAG,IAAI,KAC7B,OAAO,CAAC,MAAM,CA4BhB,CAAC;AAEF,eAAO,MAAM,kBAAkB,SACvB,IAAI,cACE,MAAM,aACP,MAAM,cACN,IAAI,EAAE,eACL,MAAM,KACjB,OAAO,CAAC,IAAI,EAAE,CAoEhB,CAAC;AAGF,eAAO,MAAM,eAAe,SACpB,IAAI,UACF,MAAM,KACb,OAAO,CAAC,OAAO,CAWjB,CAAC"}
|
package/dist/blockchain/coins.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isCoinSpendable = exports.selectUnspentCoins = exports.calculateFeeForCoinSpends = exports.DEFAULT_FEE_COIN_COST = void 0;
|
|
4
|
-
const datalayer_driver_1 = require("datalayer-driver");
|
|
4
|
+
const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
|
|
5
5
|
const Wallet_1 = require("./Wallet");
|
|
6
6
|
const config_1 = require("../utils/config");
|
|
7
7
|
const FileCache_1 = require("../utils/FileCache");
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,4 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./blockchain"), exports);
|
|
18
18
|
__exportStar(require("./DigNetwork"), exports);
|
|
19
19
|
__exportStar(require("./utils"), exports);
|
|
20
|
-
__exportStar(require("
|
|
20
|
+
__exportStar(require("./DataIntegrityTree"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKrC,eAAO,MAAM,oBAAoB,qEACmC,CAAC;AAErE,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MA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