@@ -40,6 +40,12 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ClosureRef) (ret
40
40
// Skipping transfer is used on testing for the initial call
41
41
if ! self .SkipTransfer {
42
42
err = env .Transfer (from , to , self .value )
43
+ if err != nil {
44
+ caller .ReturnGas (self .Gas , self .price )
45
+
46
+ err = fmt .Errorf ("Insufficient funds to transfer value. Req %v, has %v" , self .value , from .Balance )
47
+ return
48
+ }
43
49
}
44
50
45
51
snapshot := env .State ().Copy ()
@@ -50,23 +56,17 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ClosureRef) (ret
50
56
chainlogger .Debugf ("post state %x\n " , env .State ().Root ())
51
57
}()
52
58
53
- if err != nil {
54
- caller .ReturnGas (self .Gas , self .price )
55
-
56
- err = fmt .Errorf ("Insufficient funds to transfer value. Req %v, has %v" , self .value , from .Balance )
57
- } else {
58
- self .object = to
59
- // Pre-compiled contracts (address.go) 1, 2 & 3.
60
- naddr := ethutil .BigD (contextAddr ).Uint64 ()
61
- if p := vm .Precompiled [naddr ]; p != nil {
62
- if self .Gas .Cmp (p .Gas (len (self .input ))) >= 0 {
63
- ret = p .Call (self .input )
64
- self .vm .Printf ("NATIVE_FUNC(%x) => %x" , naddr , ret )
65
- self .vm .Endl ()
66
- }
67
- } else {
68
- ret , err = self .vm .Run (to , caller , code , self .value , self .Gas , self .price , self .input )
59
+ self .object = to
60
+ // Pre-compiled contracts (address.go) 1, 2 & 3.
61
+ naddr := ethutil .BigD (contextAddr ).Uint64 ()
62
+ if p := vm .Precompiled [naddr ]; p != nil {
63
+ if self .Gas .Cmp (p .Gas (len (self .input ))) >= 0 {
64
+ ret = p .Call (self .input )
65
+ self .vm .Printf ("NATIVE_FUNC(%x) => %x" , naddr , ret )
66
+ self .vm .Endl ()
69
67
}
68
+ } else {
69
+ ret , err = self .vm .Run (to , caller , code , self .value , self .Gas , self .price , self .input )
70
70
}
71
71
72
72
return
0 commit comments