diff --git a/assets/db b/assets/db new file mode 160000 index 0000000..e8da484 --- /dev/null +++ b/assets/db @@ -0,0 +1 @@ +Subproject commit e8da48494a68d5a2a7092fceb47eec525e91d88b diff --git a/assets/keys/miner.json b/assets/keys/miner.json index 1a5abc6..5c3f43a 100644 --- a/assets/keys/miner.json +++ b/assets/keys/miner.json @@ -1,4 +1,4 @@ { - "publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEANSRDCNj6yLHp3FS7zrRxLmuZbxPKq8ODi9wtmDZQg38=\n-----END PUBLIC KEY-----\n", - "privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIAkailpOIkIv09qeA3SOZRyXs7a4QTxK2cV8dYz6oTqd\n-----END PRIVATE KEY-----\n" + "publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAkQuBeAFQvPgDICJxIkk2Up0arCTc4FDxmUjz44Qrqis=\n-----END PUBLIC KEY-----\n", + "privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIGKBY2Dmd6PxPY5IFacryfKMCJAeBmJEZTPLRSV1gO1s\n-----END PRIVATE KEY-----\n" } \ No newline at end of file diff --git a/assets/keys/user.json b/assets/keys/user.json index 6244a05..553f3fa 100644 --- a/assets/keys/user.json +++ b/assets/keys/user.json @@ -1,4 +1,4 @@ { - "publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAtn+5QsDExPs6YttUNNYgfRQy7aoPvNluOWUdm9z9Ivs=\n-----END PUBLIC KEY-----\n", - "privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEILGts0FsxzD4jVOaI3rhzuYc1g4sZKEZtMx1yn5fIDZO\n-----END PRIVATE KEY-----\n" + "publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAn5pPbQNTuykfgK/Ooitl+pGGf0UJ8HGCBKyGgFen/04=\n-----END PUBLIC KEY-----\n", + "privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEINkpCsj3fChpvBrsctb1roCz0YA9oxRvLtsmHOY7eJr2\n-----END PRIVATE KEY-----\n" } \ No newline at end of file diff --git a/dist/API/blockchain.js b/dist/API/blockchain.js index f4bedbd..4932013 100644 --- a/dist/API/blockchain.js +++ b/dist/API/blockchain.js @@ -1,7 +1,7 @@ import Blockchain from "../library/main.js"; +import Wallet from "../library/wallet.js"; import Consensus from "../library/pow-consensus.js"; import { initJsonFile } from "../library/utils.js"; -import Wallet from "../library/wallet.js"; import { name, dbPath, minerKeysFile, hostUrl, nodesList } from "./config.js"; const consensus = new Consensus(); const minerKeys = initJsonFile(minerKeysFile, Wallet.generateKeyPair()); diff --git a/dist/API/blockchain.js.map b/dist/API/blockchain.js.map index f9d0d39..efef0cc 100644 --- a/dist/API/blockchain.js.map +++ b/dist/API/blockchain.js.map @@ -1 +1 @@ -{"version":3,"file":"blockchain.js","sourceRoot":"","sources":["../../src/API/blockchain.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9E,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;AAElC,MAAM,SAAS,GAAG,YAAY,CAAE,aAAa,EAAE,MAAM,CAAC,eAAe,EAAE,CAAE,CAAC;AAC1E,eAAe,IAAI,UAAU,CAAC;IAC7B,MAAM;IACN,KAAK,EAAE;QACN,IAAI,EAAE,SAAS;QACf,OAAO;KACP;IACD,SAAS,EAAE,IAAI;IACf,cAAc,EAAE,SAAS,CAAC,SAAS;IACnC,SAAS;CACT,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"blockchain.js","sourceRoot":"","sources":["../../src/API/blockchain.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9E,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;AAElC,MAAM,SAAS,GAAG,YAAY,CAAE,aAAa,EAAE,MAAM,CAAC,eAAe,EAAE,CAAE,CAAC;AAC1E,eAAe,IAAI,UAAU,CAAC;IAC7B,MAAM;IACN,KAAK,EAAE;QACN,IAAI,EAAE,SAAS;QACf,OAAO;KACP;IACD,SAAS,EAAE,IAAI;IACf,cAAc,EAAE,SAAS,CAAC,SAAS;IACnC,SAAS;CACT,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/API/routes/block.js b/dist/API/routes/block.js index da43a85..e65bc55 100644 --- a/dist/API/routes/block.js +++ b/dist/API/routes/block.js @@ -3,42 +3,37 @@ import axios from "axios"; import blockchain from "../blockchain.js"; import { toNum } from "../utils.js"; const router = express.Router(); -router.get("/", function (req, res) { - const { list } = req.query; - const { to, index, from, firstAndLast } = req.query; +router.get("/", (req, res) => { + const { list, to, index, from, firstAndLast } = req.query; if (!index && !from && !to && !list && !firstAndLast) { res.json(blockchain.chain.latestBlock); + return; } - else if (index) { - const blockIndex = toNum(index); - res.json(blockchain.chain.get(blockIndex)); + if (index) { + res.json(blockchain.chain.get(toNum(index))); + return; } - else if (from || to) { - const blockFrom = toNum(from); - const blockTo = toNum(to); - const blocks = blockchain.getBlocks(blockFrom, blockTo); - res.json(blocks); + if (from || to) { + res.json(blockchain.getBlocks(toNum(from), toNum(to))); + return; } - else if (list) { - const blockList = list.toString().split(","); - const blocks = []; - for (const blcokIndex of blockList) { - blocks.push(blockchain.chain.get(blcokIndex)); - } + if (list) { + const blocks = list.toString().split(",").map((index) => { + return blockchain.chain.get(toNum(index)); + }); res.json(blocks); + return; } - else if (firstAndLast) { - const blocks = []; - blocks.push(blockchain.chain.get(0)); - blocks.push(blockchain.chain.latestBlock); - res.json(blocks); + if (firstAndLast) { + res.json([blockchain.chain.get(0), blockchain.chain.latestBlock]); + return; } }); -router.post("/", function (req, res) { +router.post("/", (req, res) => { const block = blockchain.addBlock(req.body); - res.send(block); + res.json(block); }); -router.get("/broadcast", async function (req, res) { +router.get("/broadcast", async (req, res) => { for (const node of blockchain.nodes.list) { try { await axios.post(`${node}/block`, blockchain.chain.latestBlock); diff --git a/dist/API/routes/block.js.map b/dist/API/routes/block.js.map index d1d7627..c06f468 100644 --- a/dist/API/routes/block.js.map +++ b/dist/API/routes/block.js.map @@ -1 +1 @@ -{"version":3,"file":"block.js","sourceRoot":"","sources":["../../../src/API/routes/block.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AAEhC,MAAM,CAAC,GAAG,CAAE,GAAG,EAAE,UAAW,GAAG,EAAE,GAAG;IAEnC,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAC3B,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IACpD,IAAK,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,YAAY,EACrD,CAAC;QACA,GAAG,CAA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,GAAG,EAAE,CAAE,GAAG,EAAE,GAAG,EAAG,EAAE;IAEhC,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAE,GAAG,CAAC,IAAI,CAAE,CAAC;IAC9C,GAAG,CAAC,IAAI,CAAE,KAAK,CAAE,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,GAAG,CAAE,YAAY,EAAE,KAAK,EAAG,GAAG,EAAE,GAAG,EAAG,EAAE;IAE9C,KAAM,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,EACzC,CAAC;QACA,IACA,CAAC;YACA,MAAM,KAAK,CAAC,IAAI,CAAE,GAAG,IAAI,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC,WAAW,CAAE,CAAC;QACnE,CAAC;QACD,OAAQ,KAAK,EACb,CAAC;YACA,IAAK,KAAK,YAAY,KAAK,EAC3B,CAAC;gBACA,OAAO,CAAC,KAAK,CAAE,8BAA8B,IAAI,GAAG,EAAE,KAAK,CAAC,OAAO,CAAE,CAAC;YACvE,CAAC;iBAED,CAAC;gBACA,OAAO,CAAC,KAAK,CAAE,8BAA8B,IAAI,EAAE,EAAE,KAAK,CAAE,CAAC;YAC9D,CAAC;QACF,CAAC;IACF,CAAC;IACD,GAAG,CAAC,IAAI,CAAE,0BAA0B,CAAE,CAAC;AACxC,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"} \ No newline at end of file diff --git a/dist/library/transaction.js b/dist/library/transaction.js index 64b0910..62fc5f3 100644 --- a/dist/library/transaction.js +++ b/dist/library/transaction.js @@ -42,12 +42,12 @@ export default class Transaction { if (this.amount < 0) { throw new Error("Invalid amount"); } - if (this.isCoinBase()) { - return true; - } if (!this.to) { throw new Error("Invalid transaction: missing 'to' address"); } + if (this.isCoinBase()) { + return true; + } this.verifySignature(); return true; } diff --git a/dist/library/transaction.js.map b/dist/library/transaction.js.map index 10ef306..84896f6 100644 --- a/dist/library/transaction.js.map +++ b/dist/library/trans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AE,EAAE,UAAU,CAAE,CAAC;QAC9G,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAE,KAAK,CAAE,CAAC;QAC7C,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,UAAU;QAET,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;IAC3B,CAAC;CACD"} \ No newline at end of file +{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/library/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,WAAW;IAE/B,IAAI,CAAgB;IACpB,EAAE,CAAS;IACX,MAAM,CAAS;IACf,GAAG,CAAS;IACZ,kBAAkB,CAAS;IAC3B,SAAS,CAAiB;IAC1B,EAAE,CAAS;IAEX,YAAa,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,EAAE,SAAS,EAAE,EAAE,EAAmB;QAEzF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,YAAY,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,IAAI;QAEP,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,SAAS,EAAE,IAAI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AAE,CAAC;QACxC,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED,IAAI,CAAG,UAAkB;QAExB,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAE,IAAI,CAAC,SAAS,CAAE,IAAI,CAAC,oBAAoB,CAAE,CAAE,EAAE,UAAU,CAAE,CAAC;QAC9G,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAE,KAAK,CAAE,CAAC;QAC7C,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,UAAU;QAET,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;IAC3B,CAAC;CACD"} \ No newline at end of file diff --git a/src/library/transaction.ts b/src/library/transaction.ts index ac1f98a..6fc1f88 100644 --- a/src/library/transaction.ts +++ b/src/library/transaction.ts @@ -53,14 +53,14 @@ export default class Transaction { throw new Error( "Invalid amount" ); } - if ( this.isCoinBase() ) - { - return true; - } if ( !this.to ) { throw new Error( "Invalid transaction: missing 'to' address" ); } + if ( this.isCoinBase() ) + { + return true; + } this.verifySignature(); return true; }