ToJSON serializes the transaction to JSON bytes.
()
| 90 | |
| 91 | // ToJSON serializes the transaction to JSON bytes. |
| 92 | func (transaction *Transaction) ToJSON() ([]byte, error) { |
| 93 | _, span := tracer.Start(context.Background(), "ToJSON") |
| 94 | defer span.End() |
| 95 | |
| 96 | data, err := json.Marshal(transaction) |
| 97 | if err != nil { |
| 98 | span.RecordError(err) |
| 99 | return nil, err |
| 100 | } |
| 101 | span.AddEvent("Transaction serialized to JSON") |
| 102 | return data, nil |
| 103 | } |
| 104 | |
| 105 | // PrecisionBankersRound applies banker's rounding (round half to even) at the given precision scale factor. |
| 106 | func PrecisionBankersRound(num float64, precision float64) float64 { |