OSDN Git Service

feat: add cross-chain output (#56)
[bytom/vapor.git] / protocol / bc / types / txinput.go
index 8eaafaf..22e4485 100644 (file)
@@ -14,7 +14,6 @@ const (
        IssuanceInputType uint8 = iota
        SpendInputType
        CoinbaseInputType
-       ClainPeginInputType
 )
 
 type (
@@ -24,7 +23,6 @@ type (
                TypedInput
                CommitmentSuffix []byte
                WitnessSuffix    []byte
-               Peginwitness     [][]byte
        }
 
        // TypedInput return the txinput type.
@@ -46,8 +44,6 @@ func (t *TxInput) AssetAmount() bc.AssetAmount {
                }
        case *SpendInput:
                return inp.AssetAmount
-       case *ClaimInput:
-               return inp.AssetAmount
        }
        return bc.AssetAmount{}
 }
@@ -59,8 +55,6 @@ func (t *TxInput) AssetID() bc.AssetID {
                return inp.AssetID()
        case *SpendInput:
                return *inp.AssetId
-       case *ClaimInput:
-               return *inp.AssetId
 
        }
        return bc.AssetID{}
@@ -73,8 +67,6 @@ func (t *TxInput) Amount() uint64 {
                return inp.Amount
        case *SpendInput:
                return inp.Amount
-       case *ClaimInput:
-               return inp.Amount
        }
        return 0
 }
@@ -110,8 +102,6 @@ func (t *TxInput) Arguments() [][]byte {
                return inp.Arguments
        case *SpendInput:
                return inp.Arguments
-       case *ClaimInput:
-               return inp.Arguments
        }
        return nil
 }
@@ -123,8 +113,6 @@ func (t *TxInput) SetArguments(args [][]byte) {
                inp.Arguments = args
        case *SpendInput:
                inp.Arguments = args
-       case *ClaimInput:
-               inp.Arguments = args
        }
 }
 
@@ -141,9 +129,6 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) {
                return err
        }
 
-       if t.Peginwitness, err = blockchain.ReadVarstrList(r); err != nil {
-               return err
-       }
        var assetID bc.AssetID
        t.CommitmentSuffix, err = blockchain.ReadExtensibleString(r, func(r *blockchain.Reader) error {
                if t.AssetVersion != 1 {
@@ -174,18 +159,14 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) {
                        if si.SpendCommitmentSuffix, err = si.SpendCommitment.readFrom(r, 1); err != nil {
                                return err
                        }
-               case ClainPeginInputType:
-                       ci := new(ClaimInput)
-                       t.TypedInput = ci
-                       if ci.SpendCommitmentSuffix, err = ci.SpendCommitment.readFrom(r, 1); err != nil {
-                               return err
-                       }
+
                case CoinbaseInputType:
                        ci := new(CoinbaseInput)
                        t.TypedInput = ci
                        if ci.Arbitrary, err = blockchain.ReadVarstr31(r); err != nil {
                                return err
                        }
+
                default:
                        return fmt.Errorf("unsupported input type %d", icType[0])
                }
@@ -222,10 +203,6 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) {
                        if inp.Arguments, err = blockchain.ReadVarstrList(r); err != nil {
                                return err
                        }
-               case *ClaimInput:
-                       if inp.Arguments, err = blockchain.ReadVarstrList(r); err != nil {
-                               return err
-                       }
                }
                return nil
        })
@@ -238,9 +215,6 @@ func (t *TxInput) writeTo(w io.Writer) error {
                return errors.Wrap(err, "writing asset version")
        }
 
-       if _, err := blockchain.WriteVarstrList(w, t.Peginwitness); err != nil {
-               return errors.Wrap(err, "writing pegin witness")
-       }
        if _, err := blockchain.WriteExtensibleString(w, t.CommitmentSuffix, t.writeInputCommitment); err != nil {
                return errors.Wrap(err, "writing input commitment")
        }
@@ -274,11 +248,7 @@ func (t *TxInput) writeInputCommitment(w io.Writer) (err error) {
                        return err
                }
                return inp.SpendCommitment.writeExtensibleString(w, inp.SpendCommitmentSuffix, t.AssetVersion)
-       case *ClaimInput:
-               if _, err = w.Write([]byte{ClainPeginInputType}); err != nil {
-                       return err
-               }
-               return inp.SpendCommitment.writeExtensibleString(w, inp.SpendCommitmentSuffix, t.AssetVersion)
+
        case *CoinbaseInput:
                if _, err = w.Write([]byte{CoinbaseInputType}); err != nil {
                        return err
@@ -294,6 +264,7 @@ func (t *TxInput) writeInputWitness(w io.Writer) error {
        if t.AssetVersion != 1 {
                return nil
        }
+
        switch inp := t.TypedInput.(type) {
        case *IssuanceInput:
                if _, err := blockchain.WriteVarstr31(w, inp.AssetDefinition); err != nil {
@@ -311,10 +282,6 @@ func (t *TxInput) writeInputWitness(w io.Writer) error {
        case *SpendInput:
                _, err := blockchain.WriteVarstrList(w, inp.Arguments)
                return err
-       case *ClaimInput:
-               _, err := blockchain.WriteVarstrList(w, inp.Arguments)
-
-               return err
        }
        return nil
 }