Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 23 additions & 1 deletion blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ class Transaction {
* - signature: a unique signature generated from a combination of the
* other properties, signed with the provided private key
*/

constructor(privateKey, recipient, amount) {
// Enter your solution here

// var source = signing.getPublicKey(privateKey);
// var signature = signing.sign(privateKey, amount);
this.source = signing.getPublicKey(privateKey);
this.recipient = recipient;
this.amount = amount;
const toSign = this.source + recipient + amount;
this.signature = signing.sign(privateKey, toSign);
}
}

Expand All @@ -45,6 +52,11 @@ class Block {
*/
constructor(transactions, previousHash) {
// Your code here
// var nonce = 12
// var hash = calculateHash(nonce);
this.transactions = transactions;
this.previousHash = previousHash;
this.calculateHash(0);

}

Expand All @@ -59,7 +71,13 @@ class Block {
*/
calculateHash(nonce) {
// Your code here
// return crypto.createHash(nonce);
// const transactionString = this.transactions.map(t => t.signature).join('');
// const toHash = this.previousHash + transactionString + nonce;
// // Your code here

// this.nonce = nonce;
// this.hash = createHash('sha512').update(toHash).digest('hex');
}
}

Expand All @@ -79,6 +97,10 @@ class Blockchain {
*/
constructor() {
// Your code here
var previousHash = null;
var transactions = [];
var blooks = [];


}

Expand Down
12 changes: 12 additions & 0 deletions node_modules/.bin/_mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/_mocha.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/_mocha.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/he

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/he.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/he.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/mkdirp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/mkdirp.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/mkdirp.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/mocha.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/mocha.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/sha.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/sha.js.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/sha.js.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading