mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-18 15:44:44 +00:00
e299a44983
It's no longer needed after the io.GetVarSize() improvement. It's duplicating a lot of EncodeBinary() logic also.
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package wrappers
|
|
|
|
import (
|
|
"github.com/CityOfZion/neo-go/pkg/core"
|
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
|
)
|
|
|
|
// TransactionOutputRaw is used as a wrapper to represents
|
|
// a Transaction.
|
|
type TransactionOutputRaw struct {
|
|
*transaction.Transaction
|
|
TxHash util.Uint256 `json:"txid"`
|
|
Size int `json:"size"`
|
|
SysFee util.Fixed8 `json:"sys_fee"`
|
|
NetFee util.Fixed8 `json:"net_fee"`
|
|
Blockhash util.Uint256 `json:"blockhash"`
|
|
Confirmations int `json:"confirmations"`
|
|
Timestamp uint32 `json:"blocktime"`
|
|
}
|
|
|
|
// NewTransactionOutputRaw returns a new ransactionOutputRaw object.
|
|
func NewTransactionOutputRaw(tx *transaction.Transaction, header *core.Header, chain core.Blockchainer) TransactionOutputRaw {
|
|
// confirmations formula
|
|
confirmations := int(chain.BlockHeight() - header.BlockBase.Index + 1)
|
|
// set index position
|
|
for i, o := range tx.Outputs {
|
|
o.Position = i
|
|
}
|
|
return TransactionOutputRaw{
|
|
Transaction: tx,
|
|
TxHash: tx.Hash(),
|
|
Size: io.GetVarSize(tx),
|
|
SysFee: chain.SystemFee(tx),
|
|
NetFee: chain.NetworkFee(tx),
|
|
Blockhash: header.Hash(),
|
|
Confirmations: confirmations,
|
|
Timestamp: header.Timestamp,
|
|
}
|
|
}
|