ErrMissingEntry = errors.New("missing entry")
)
-// Output try to get the output entry by given hash
-func (tx *Tx) Output(id Hash) (*Output, error) {
+// IntraChainOutput try to get the intra-chain output entry by given hash
+func (tx *Tx) IntraChainOutput(id Hash) (*IntraChainOutput, error) {
e, ok := tx.Entries[id]
if !ok || e == nil {
return nil, errors.Wrapf(ErrMissingEntry, "id %x", id.Bytes())
}
- o, ok := e.(*Output)
+ o, ok := e.(*IntraChainOutput)
if !ok {
return nil, errors.Wrapf(ErrEntryType, "entry %x has unexpected type %T", id.Bytes(), e)
}
return o, nil
}
+// CrossChainOutput try to get the cross-chain output entry by given hash
+func (tx *Tx) CrossChainOutput(id Hash) (*CrossChainOutput, error) {
+ e, ok := tx.Entries[id]
+ if !ok || e == nil {
+ return nil, errors.Wrapf(ErrMissingEntry, "id %x", id.Bytes())
+ }
+ o, ok := e.(*CrossChainOutput)
+ if !ok {
+ return nil, errors.Wrapf(ErrEntryType, "entry %x has unexpected type %T", id.Bytes(), e)
+ }
+ return o, nil
+}
+
+// Entry try to get the entry by given hash
+func (tx *Tx) Entry(id Hash) (Entry, error) {
+ e, ok := tx.Entries[id]
+ if !ok || e == nil {
+ return nil, errors.Wrapf(ErrMissingEntry, "id %x", id.Bytes())
+ }
+ return e, nil
+}
+
// Spend try to get the spend entry by given hash
func (tx *Tx) Spend(id Hash) (*Spend, error) {
e, ok := tx.Entries[id]
}
return iss, nil
}
+
+// VoteOutput try to get the vote output entry by given hash
+func (tx *Tx) VoteOutput(id Hash) (*VoteOutput, error) {
+ e, ok := tx.Entries[id]
+ if !ok || e == nil {
+ return nil, errors.Wrapf(ErrMissingEntry, "id %x", id.Bytes())
+ }
+ o, ok := e.(*VoteOutput)
+ if !ok {
+ return nil, errors.Wrapf(ErrEntryType, "entry %x has unexpected type %T", id.Bytes(), e)
+ }
+ return o, nil
+}