mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-26 09:43:49 +00:00
ddd1d92ff1
The idea here is to preserve the history of `dev` branch development and its code when merging with the `master`. Later this code could be moved into the masters code where appropriate.
43 lines
955 B
Go
43 lines
955 B
Go
package transaction
|
|
|
|
import (
|
|
"github.com/CityOfZion/neo-go/pkg/wire/payload/transaction/types"
|
|
"github.com/CityOfZion/neo-go/pkg/wire/payload/transaction/version"
|
|
"github.com/CityOfZion/neo-go/pkg/wire/util"
|
|
)
|
|
|
|
//Claim represents a claim transaction on the neo network
|
|
type Claim struct {
|
|
*Base
|
|
Claims []*Input
|
|
}
|
|
|
|
//NewClaim returns a ClaimTransaction
|
|
func NewClaim(ver version.TX) *Claim {
|
|
basicTrans := createBaseTransaction(types.Contract, ver)
|
|
|
|
claim := &Claim{}
|
|
claim.Base = basicTrans
|
|
claim.encodeExclusive = claim.encodeExcl
|
|
claim.decodeExclusive = claim.decodeExcl
|
|
return claim
|
|
}
|
|
|
|
func (c *Claim) encodeExcl(bw *util.BinWriter) {
|
|
|
|
bw.VarUint(uint64(len(c.Claims)))
|
|
for _, claim := range c.Claims {
|
|
claim.Encode(bw)
|
|
}
|
|
}
|
|
|
|
func (c *Claim) decodeExcl(br *util.BinReader) {
|
|
lenClaims := br.VarUint()
|
|
|
|
c.Claims = make([]*Input, lenClaims)
|
|
for i := 0; i < int(lenClaims); i++ {
|
|
c.Claims[i] = &Input{}
|
|
c.Claims[i].Decode(br)
|
|
}
|
|
|
|
}
|