"github.com/vapor/encoding/blockchain"
"github.com/vapor/errors"
- "github.com/vapor/protocol/bc/types/bytom"
+ "github.com/vapor/protocol/bc"
+ "github.com/vapor/protocol/bc/types"
)
// serflag variables for input types.
var errBadAssetID = errors.New("asset ID does not match other issuance parameters")
// AssetAmount return the asset id and amount of the txinput.
-func (t *TxInput) AssetAmount() bytom.AssetAmount {
+func (t *TxInput) AssetAmount() bc.AssetAmount {
switch inp := t.TypedInput.(type) {
- case *IssuanceInput:
+ case *types.IssuanceInput:
assetID := inp.AssetID()
- return bytom.AssetAmount{
+ return bc.AssetAmount{
AssetId: &assetID,
Amount: inp.Amount,
}
case *SpendInput:
return inp.AssetAmount
}
- return bytom.AssetAmount{}
+ return bc.AssetAmount{}
}
// AssetID return the assetID of the txinput
-func (t *TxInput) AssetID() bytom.AssetID {
+func (t *TxInput) AssetID() bc.AssetID {
switch inp := t.TypedInput.(type) {
- case *IssuanceInput:
+ case *types.IssuanceInput:
return inp.AssetID()
case *SpendInput:
return *inp.AssetId
}
- return bytom.AssetID{}
+ return bc.AssetID{}
}
// Amount return the asset amount of the txinput
func (t *TxInput) Amount() uint64 {
switch inp := t.TypedInput.(type) {
- case *IssuanceInput:
+ case *types.IssuanceInput:
return inp.Amount
case *SpendInput:
return inp.Amount
// IssuanceProgram return the control program of the issuance input
func (t *TxInput) IssuanceProgram() []byte {
- if ii, ok := t.TypedInput.(*IssuanceInput); ok {
+ if ii, ok := t.TypedInput.(*types.IssuanceInput); ok {
return ii.IssuanceProgram
}
return nil
// Arguments get the args for the input
func (t *TxInput) Arguments() [][]byte {
switch inp := t.TypedInput.(type) {
- case *IssuanceInput:
+ case *types.IssuanceInput:
return inp.Arguments
case *SpendInput:
return inp.Arguments
// SetArguments set the args for the input
func (t *TxInput) SetArguments(args [][]byte) {
switch inp := t.TypedInput.(type) {
- case *IssuanceInput:
+ case *types.IssuanceInput:
inp.Arguments = args
case *SpendInput:
inp.Arguments = args
}
// SpentOutputID calculate the hash of spended output
-func (t *TxInput) SpentOutputID() (o bytom.Hash, err error) {
+func (t *TxInput) SpentOutputID() (o bc.Hash, err error) {
if si, ok := t.TypedInput.(*SpendInput); ok {
o, err = ComputeOutputID(&si.SpendCommitment)
}
return err
}
- var assetID bytom.AssetID
+ var assetID bc.AssetID
t.CommitmentSuffix, err = blockchain.ReadExtensibleString(r, func(r *blockchain.Reader) error {
if t.AssetVersion != 1 {
return nil
}
switch icType[0] {
case IssuanceInputType:
- ii := new(IssuanceInput)
+ ii := new(types.IssuanceInput)
t.TypedInput = ii
if ii.Nonce, err = blockchain.ReadVarstr31(r); err != nil {
}
switch inp := t.TypedInput.(type) {
- case *IssuanceInput:
+ case *types.IssuanceInput:
if inp.AssetDefinition, err = blockchain.ReadVarstr31(r); err != nil {
return err
}
}
switch inp := t.TypedInput.(type) {
- case *IssuanceInput:
+ case *types.IssuanceInput:
if _, err = w.Write([]byte{IssuanceInputType}); err != nil {
return err
}
return nil
}
switch inp := t.TypedInput.(type) {
- case *IssuanceInput:
+ case *types.IssuanceInput:
if _, err := blockchain.WriteVarstr31(w, inp.AssetDefinition); err != nil {
return err
}