git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 4c7c54ec09858f22c767210f0814625380b32c55

Kernel: support parsing real transactions in runTx

Alex Beregszaszi committed on 8/23/2016, 12:27:46 AM
Parent: c37a0e4f79312b8d2c82aea3bfeee95a6f812586

Files changed

index.jschanged
index.jsView
@@ -23,8 +23,9 @@
2323
2424 const Address = require('./address.js')
2525 const U256 = require('./u256.js')
2626 const Utils = require('./utils.js')
27+const Transaction = require('./transaction.js')
2728
2829 module.exports = class Kernel {
2930 // runs some code in the VM
3031 constructor (environment = new Environment()) {
@@ -118,8 +119,15 @@
118119 //
119120 // { balance, codeHash, stateRoot }
120121 //
121122
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+
122130 // look up sender
123131 let fromAccount = this.environment.state.get(tx.from.toString())
124132 if (!fromAccount) {
125133 throw new Error('Sender account not found')

Built with git-ssb-web