mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-27 03:58:06 +00:00
27 lines
726 B
Go
27 lines
726 B
Go
package wrappers
|
|
|
|
import (
|
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
|
"github.com/CityOfZion/neo-go/pkg/encoding/address"
|
|
"github.com/CityOfZion/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.String(),
|
|
Value: out.Amount,
|
|
Address: addr,
|
|
}
|
|
}
|