2019-02-25 22:44:14 +00:00
|
|
|
package payload
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/wire/command"
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/wire/payload/transaction"
|
|
|
|
)
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
// TXMessage represents a transaction message on the neo-network
|
2019-02-25 22:44:14 +00:00
|
|
|
type TXMessage struct {
|
|
|
|
Tx transaction.Transactioner
|
|
|
|
}
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
//NewTXMessage returns a new tx object
|
2019-02-25 22:44:14 +00:00
|
|
|
func NewTXMessage(tx transaction.Transactioner) (*TXMessage, error) {
|
|
|
|
|
|
|
|
Tx := &TXMessage{tx}
|
|
|
|
return Tx, nil
|
|
|
|
}
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
// DecodePayload Implements Messager interface
|
2019-02-25 22:44:14 +00:00
|
|
|
func (t *TXMessage) DecodePayload(r io.Reader) error {
|
|
|
|
return t.Tx.Decode(r)
|
|
|
|
}
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
// EncodePayload Implements messager interface
|
2019-02-25 22:44:14 +00:00
|
|
|
func (t *TXMessage) EncodePayload(w io.Writer) error {
|
|
|
|
return t.Tx.Encode(w)
|
|
|
|
}
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
// Command Implements messager interface
|
|
|
|
func (t *TXMessage) Command() command.Type {
|
2019-02-25 22:44:14 +00:00
|
|
|
return command.TX
|
|
|
|
}
|