Commit 6fea6a822c06422806c410ed001c872285269aa2
Kernel: add nonce check
Alex Beregszaszi committed on 8/23/2016, 12:27:46 AMParent: 096148fb99184a312360d7114166031362ecc54b
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -142,8 +142,14 @@ | ||
142 | 142 | if (!fromAccount) { |
143 | 143 | throw new Error('Sender account not found: ' + tx.from.toString()) |
144 | 144 | } |
145 | 145 | |
146 | + if (fromAccount.get('nonce').gt(tx.nonce)) { | |
147 | + throw new Error(`Invalid nonce: ${fromAccount.get('nonce')} > ${tx.nonce}`) | |
148 | + } | |
149 | + | |
150 | + fromAccount.set('nonce', fromAccount.get('nonce').add(new U256(1))) | |
151 | + | |
146 | 152 | // Special case: contract deployment |
147 | 153 | if (tx.to.isZero()) { |
148 | 154 | if (tx.data.length !== 0) { |
149 | 155 | console.log('This is a contract deployment transaction') |
Built with git-ssb-web