Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reward transaction does not get signed #57

Closed
ozshm opened this issue Mar 15, 2022 · 0 comments
Closed

Reward transaction does not get signed #57

ozshm opened this issue Mar 15, 2022 · 0 comments

Comments

@ozshm
Copy link

ozshm commented Mar 15, 2022

Hello, great job on this project!

EDIT: Nevermind. A transaction is valid when a null sender is set.

Please, I would like to draw your attention to the Blockchain.minePendingTransactions() method (here):

minePendingTransactions(miningRewardAddress) {
    const rewardTx = new Transaction(null, miningRewardAddress, this.miningReward);
    this.pendingTransactions.push(rewardTx);

    const block = new Block(Date.now(), this.pendingTransactions, this.getLatestBlock().hash);
    block.mineBlock(this.difficulty);

    debug('Block successfully mined!');
    this.chain.push(block);
    this.pendingTransactions = []; 
}

The rewardTx is inserted into the pending transactions array without getting signed by the sender which causes the transaction to be invalid (when verified using the Transaction.isValid() method.)

@ozshm ozshm closed this as completed Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant