OSDN Git Service

init for remove issue (#63)
[bytom/vapor.git] / protocol / bc / types / txinput.go
index 22e4485..c9b4e8e 100644 (file)
@@ -36,12 +36,6 @@ var errBadAssetID = errors.New("asset ID does not match other issuance parameter
 // AssetAmount return the asset id and amount of the txinput.
 func (t *TxInput) AssetAmount() bc.AssetAmount {
        switch inp := t.TypedInput.(type) {
-       case *IssuanceInput:
-               assetID := inp.AssetID()
-               return bc.AssetAmount{
-                       AssetId: &assetID,
-                       Amount:  inp.Amount,
-               }
        case *SpendInput:
                return inp.AssetAmount
        }
@@ -51,8 +45,6 @@ func (t *TxInput) AssetAmount() bc.AssetAmount {
 // AssetID return the assetID of the txinput
 func (t *TxInput) AssetID() bc.AssetID {
        switch inp := t.TypedInput.(type) {
-       case *IssuanceInput:
-               return inp.AssetID()
        case *SpendInput:
                return *inp.AssetId
 
@@ -63,8 +55,6 @@ func (t *TxInput) AssetID() bc.AssetID {
 // Amount return the asset amount of the txinput
 func (t *TxInput) Amount() uint64 {
        switch inp := t.TypedInput.(type) {
-       case *IssuanceInput:
-               return inp.Amount
        case *SpendInput:
                return inp.Amount
        }
@@ -79,27 +69,9 @@ func (t *TxInput) ControlProgram() []byte {
        return nil
 }
 
-// IssuanceProgram return the control program of the issuance input
-func (t *TxInput) IssuanceProgram() []byte {
-       if ii, ok := t.TypedInput.(*IssuanceInput); ok {
-               return ii.IssuanceProgram
-       }
-       return nil
-}
-
-// AssetDefinition return the asset definition of the issuance input
-func (t *TxInput) AssetDefinition() []byte {
-       if ii, ok := t.TypedInput.(*IssuanceInput); ok {
-               return ii.AssetDefinition
-       }
-       return nil
-}
-
 // Arguments get the args for the input
 func (t *TxInput) Arguments() [][]byte {
        switch inp := t.TypedInput.(type) {
-       case *IssuanceInput:
-               return inp.Arguments
        case *SpendInput:
                return inp.Arguments
        }
@@ -109,8 +81,6 @@ func (t *TxInput) Arguments() [][]byte {
 // SetArguments set the args for the input
 func (t *TxInput) SetArguments(args [][]byte) {
        switch inp := t.TypedInput.(type) {
-       case *IssuanceInput:
-               inp.Arguments = args
        case *SpendInput:
                inp.Arguments = args
        }
@@ -129,7 +99,6 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) {
                return err
        }
 
-       var assetID bc.AssetID
        t.CommitmentSuffix, err = blockchain.ReadExtensibleString(r, func(r *blockchain.Reader) error {
                if t.AssetVersion != 1 {
                        return nil
@@ -139,20 +108,6 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) {
                        return errors.Wrap(err, "reading input commitment type")
                }
                switch icType[0] {
-               case IssuanceInputType:
-                       ii := new(IssuanceInput)
-                       t.TypedInput = ii
-
-                       if ii.Nonce, err = blockchain.ReadVarstr31(r); err != nil {
-                               return err
-                       }
-                       if _, err = assetID.ReadFrom(r); err != nil {
-                               return err
-                       }
-                       if ii.Amount, err = blockchain.ReadVarint63(r); err != nil {
-                               return err
-                       }
-
                case SpendInputType:
                        si := new(SpendInput)
                        t.TypedInput = si
@@ -182,23 +137,6 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) {
                }
 
                switch inp := t.TypedInput.(type) {
-               case *IssuanceInput:
-                       if inp.AssetDefinition, err = blockchain.ReadVarstr31(r); err != nil {
-                               return err
-                       }
-                       if inp.VMVersion, err = blockchain.ReadVarint63(r); err != nil {
-                               return err
-                       }
-                       if inp.IssuanceProgram, err = blockchain.ReadVarstr31(r); err != nil {
-                               return err
-                       }
-                       if inp.AssetID() != assetID {
-                               return errBadAssetID
-                       }
-                       if inp.Arguments, err = blockchain.ReadVarstrList(r); err != nil {
-                               return err
-                       }
-
                case *SpendInput:
                        if inp.Arguments, err = blockchain.ReadVarstrList(r); err != nil {
                                return err
@@ -229,20 +167,6 @@ func (t *TxInput) writeInputCommitment(w io.Writer) (err error) {
        }
 
        switch inp := t.TypedInput.(type) {
-       case *IssuanceInput:
-               if _, err = w.Write([]byte{IssuanceInputType}); err != nil {
-                       return err
-               }
-               if _, err = blockchain.WriteVarstr31(w, inp.Nonce); err != nil {
-                       return err
-               }
-               assetID := t.AssetID()
-               if _, err = assetID.WriteTo(w); err != nil {
-                       return err
-               }
-               _, err = blockchain.WriteVarint63(w, inp.Amount)
-               return err
-
        case *SpendInput:
                if _, err = w.Write([]byte{SpendInputType}); err != nil {
                        return err
@@ -266,19 +190,6 @@ func (t *TxInput) writeInputWitness(w io.Writer) error {
        }
 
        switch inp := t.TypedInput.(type) {
-       case *IssuanceInput:
-               if _, err := blockchain.WriteVarstr31(w, inp.AssetDefinition); err != nil {
-                       return err
-               }
-               if _, err := blockchain.WriteVarint63(w, inp.VMVersion); err != nil {
-                       return err
-               }
-               if _, err := blockchain.WriteVarstr31(w, inp.IssuanceProgram); err != nil {
-                       return err
-               }
-               _, err := blockchain.WriteVarstrList(w, inp.Arguments)
-               return err
-
        case *SpendInput:
                _, err := blockchain.WriteVarstrList(w, inp.Arguments)
                return err