code: func (v *Vin) MarshalJSON() ([]byte, error) {
  	if v.IsCoinBase() {
  		coinbaseStruct := struct {
  			Coinbase string   `json:"coinbase"`
  			Sequence uint32   `json:"sequence"`
  			Witness  []string `json:"witness,omitempty"`
  		}{
  			Coinbase: v.Coinbase,
  			Sequence: v.Sequence,
  			Witness:  v.Witness,
  		}
  		return json.Marshal(coinbaseStruct)
  	}
  
  	if v.HasWitness() {
  		txStruct := struct {
  			Txid      string     `json:"txid"`
  			Vout      uint32     `json:"vout"`
  			ScriptSig *ScriptSig `json:"scriptSig"`
  			Witness   []string   `json:"txinwitness"`
  			Sequence  uint32     `json:"sequence"`
  		}{
  			Txid:      v.Txid,
  			Vout:      v.Vout,
  			ScriptSig: v.ScriptSig,
  			Witness:   v.Witness,
  			Sequence:  v.Sequence,
  		}
  		return json.Marshal(txStruct)
  	}
  
  	txStruct := struct {
  		Txid      string     `json:"txid"`
  		Vout      uint32     `json:"vout"`
  		ScriptSig *ScriptSig `json:"scriptSig"`
  		Sequence  uint32     `json:"sequence"`
  	}{
  		Txid:      v.Txid,
  		Vout:      v.Vout,
  		ScriptSig: v.ScriptSig,
  		Sequence:  v.Sequence,
  	}
  	return json.Marshal(txStruct)
  }
docs: // MarshalJSON provides a custom Marshal method for Vin.