Commit 4c7c54ec09858f22c767210f0814625380b32c55
Kernel: support parsing real transactions in runTx
Alex Beregszaszi committed on 8/23/2016, 12:27:46 AMParent: c37a0e4f79312b8d2c82aea3bfeee95a6f812586
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -23,8 +23,9 @@ | ||
23 | 23 | |
24 | 24 | const Address = require('./address.js') |
25 | 25 | const U256 = require('./u256.js') |
26 | 26 | const Utils = require('./utils.js') |
27 | +const Transaction = require('./transaction.js') | |
27 | 28 | |
28 | 29 | module.exports = class Kernel { |
29 | 30 | // runs some code in the VM |
30 | 31 | constructor (environment = new Environment()) { |
@@ -118,8 +119,15 @@ | ||
118 | 119 | // |
119 | 120 | // { balance, codeHash, stateRoot } |
120 | 121 | // |
121 | 122 | |
123 | + if (Buffer.isBuffer(tx) || typeof tx === 'string') { | |
124 | + tx = new Transaction(tx) | |
125 | + if (!tx.valid) { | |
126 | + throw new Error('Invalid transaction signature') | |
127 | + } | |
128 | + } | |
129 | + | |
122 | 130 | // look up sender |
123 | 131 | let fromAccount = this.environment.state.get(tx.from.toString()) |
124 | 132 | if (!fromAccount) { |
125 | 133 | throw new Error('Sender account not found') |
Built with git-ssb-web