Replace MustAddressToBech32 with AddressToBech32

pull/1686/head
flicker-harmony 5 years ago
parent 98116150bb
commit daeca66ef2
  1. 11
      api/service/explorer/structs.go

@ -119,13 +119,20 @@ func GetTransaction(tx *types.Transaction, addressBlock *types.Block) *Transacti
gasFee := big.NewInt(0)
gasFee = gasFee.Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas()))
to := ""
var err error
if msg.To() != nil {
to = common.MustAddressToBech32(*msg.To())
if to, err = common.AddressToBech32(*msg.To()); err != nil {
return nil
}
}
from := ""
if from, err = common.AddressToBech32(msg.From()); err != nil {
return nil
}
return &Transaction{
ID: tx.Hash().Hex(),
Timestamp: strconv.Itoa(int(addressBlock.Time().Int64() * 1000)),
From: common.MustAddressToBech32(msg.From()),
From: from,
To: to,
Value: msg.Value(),
Bytes: strconv.Itoa(int(tx.Size())),

Loading…
Cancel
Save