2020-01-13 10:21:44 +00:00
|
|
|
package result
|
2020-02-06 12:02:03 +00:00
|
|
|
|
|
|
|
import (
|
2020-03-03 14:21:42 +00:00
|
|
|
"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"
|
2020-02-06 12:02:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
}
|
|
|
|
}
|