@@ -17,65 +17,22 @@ import (
17
17
func (r * Reconciler1 ) GetStatements1 (pos * types.AppPosition , trans * types.Transaction ) ([]types.Statement , error ) {
18
18
results := make ([]types.Statement , 0 , 20 )
19
19
if ledger10 .AssetOfInterest (r .opts .AssetFilters , base .FAKE_ETH_ADDRESS ) {
20
- s := types.Statement {
21
- AccountedFor : r .opts .AccountFor ,
22
- Sender : trans .From ,
23
- Recipient : trans .To ,
24
- BlockNumber : trans .BlockNumber ,
25
- TransactionIndex : trans .TransactionIndex ,
26
- TransactionHash : trans .Hash ,
27
- LogIndex : 0 ,
28
- Timestamp : trans .Timestamp ,
29
- Asset : base .FAKE_ETH_ADDRESS ,
30
- Symbol : "WEI" ,
31
- Decimals : 18 ,
32
- SpotPrice : 0.0 ,
33
- PriceSource : "not-priced" ,
34
- }
35
- if r .opts .AsEther {
36
- s .Symbol = "ETH"
37
- }
38
- if trans .To .IsZero () && trans .Receipt != nil && ! trans .Receipt .ContractAddress .IsZero () {
39
- s .Recipient = trans .Receipt .ContractAddress
40
- }
41
-
20
+ var err error
42
21
reconciled := false
22
+ stmt := r .getStatementFromTransaction (trans )
43
23
if ! r .opts .UseTraces {
44
- if s .Sender == r .opts .AccountFor {
45
- gasUsed := new (base.Wei )
46
- if trans .Receipt != nil {
47
- gasUsed .SetUint64 (uint64 (trans .Receipt .GasUsed ))
48
- }
49
- gasPrice := new (base.Wei ).SetUint64 (uint64 (trans .GasPrice ))
50
- gasOut := new (base.Wei ).Mul (gasUsed , gasPrice )
51
- s .AmountOut = trans .Value
52
- s .GasOut = * gasOut
53
- }
54
-
55
- if s .Recipient == r .opts .AccountFor {
56
- if s .BlockNumber == 0 {
57
- s .PrefundIn = trans .Value
58
- } else {
59
- if trans .Rewards != nil {
60
- s .MinerBaseRewardIn = trans .Rewards .Block
61
- s .MinerNephewRewardIn = trans .Rewards .Nephew
62
- s .MinerTxFeeIn = trans .Rewards .TxFee
63
- s .MinerUncleRewardIn = trans .Rewards .Uncle
64
- } else {
65
- s .AmountIn = trans .Value
66
- }
24
+ if reconciled , err = r .trialBalance (pos , trans , stmt ); err != nil {
25
+ return nil , err
26
+ } else {
27
+ if reconciled && stmt .IsMaterial () {
28
+ results = append (results , * stmt )
67
29
}
68
30
}
69
-
70
- reconciled , _ = r .trialBalance (pos , trans , & s )
71
- if reconciled && s .IsMaterial () {
72
- results = append (results , s )
73
- }
74
31
}
75
32
76
33
if r .opts .UseTraces || ! reconciled {
77
34
results = make ([]types.Statement , 0 , 20 ) /* reset this */
78
- if stmt , err := r .getStatementFromTraces (pos , trans , & s ); err != nil {
35
+ if stmt , err := r .getStatementFromTraces (pos , trans , stmt ); err != nil {
79
36
logger .Warn (colors .Yellow + "Statement at " , fmt .Sprintf ("%d.%d" , trans .BlockNumber , trans .TransactionIndex ), " does not reconcile." + colors .Off )
80
37
} else {
81
38
if _ , err = r .trialBalance (pos , trans , stmt ); err != nil {
@@ -141,7 +98,32 @@ func (r *Reconciler1) NewStatement(trans *types.Transaction) *types.Statement {
141
98
}
142
99
143
100
func (r * Reconciler1 ) getStatementFromTransaction (trans * types.Transaction ) * types.Statement {
144
- return nil
101
+ stmt := r .NewStatement (trans )
102
+ if stmt .Sender == r .opts .AccountFor {
103
+ gasUsed := new (base.Wei )
104
+ if trans .Receipt != nil {
105
+ gasUsed .SetUint64 (uint64 (trans .Receipt .GasUsed ))
106
+ }
107
+ gasPrice := new (base.Wei ).SetUint64 (uint64 (trans .GasPrice ))
108
+ gasOut := new (base.Wei ).Mul (gasUsed , gasPrice )
109
+ stmt .AmountOut = trans .Value
110
+ stmt .GasOut = * gasOut
111
+ }
112
+ if stmt .Recipient == r .opts .AccountFor {
113
+ if stmt .BlockNumber == 0 {
114
+ stmt .PrefundIn = trans .Value
115
+ } else {
116
+ if trans .Rewards != nil {
117
+ stmt .MinerBaseRewardIn = trans .Rewards .Block
118
+ stmt .MinerNephewRewardIn = trans .Rewards .Nephew
119
+ stmt .MinerTxFeeIn = trans .Rewards .TxFee
120
+ stmt .MinerUncleRewardIn = trans .Rewards .Uncle
121
+ } else {
122
+ stmt .AmountIn = trans .Value
123
+ }
124
+ }
125
+ }
126
+ return stmt
145
127
}
146
128
147
129
func (r * Reconciler1 ) getStatementFromTraces (pos * types.AppPosition , trans * types.Transaction , s * types.Statement ) (* types.Statement , error ) {
0 commit comments