neo-go/pkg/rpc/response/result/tx_output.go
Roman Khimov 850d29060a result: assets are LE in JSON
LE/BE split is the worst NEO feature ever.
2021-02-18 17:28:19 +03:00

27 lines
723 B
Go

package result
import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/util"
)
// TransactionOutput is a wrapper to represent transaction's output.
type TransactionOutput struct {
N int `json:"n"`
Asset string `json:"asset"`
Value util.Fixed8 `json:"value"`
Address string `json:"address"`
}
// NewTxOutput converts out to a TransactionOutput.
func NewTxOutput(out *transaction.Output) *TransactionOutput {
addr := address.Uint160ToString(out.ScriptHash)
return &TransactionOutput{
N: out.Position,
Asset: "0x" + out.AssetID.StringLE(),
Value: out.Amount,
Address: addr,
}
}